sched: cleanup, use NSEC_PER_MSEC and NSEC_PER_SEC

1) hardcoded 1000000000 value is used five times in places where
NSEC_PER_SEC might be more readable.

2) A conversion from nsec to msec uses the hardcoded 1000000 value,
which is a candidate for NSEC_PER_MSEC.

no code changed:

text data bss dec hex filename
44359 3326 36 47721 ba69 sched.o.before
44359 3326 36 47721 ba69 sched.o.after

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Eric Dumazet and committed by Ingo Molnar d6322faf 19978ca6

+6 -6
+4 -4
kernel/sched.c
··· 75 */ 76 unsigned long long __attribute__((weak)) sched_clock(void) 77 { 78 - return (unsigned long long)jiffies * (1000000000 / HZ); 79 } 80 81 /* ··· 99 /* 100 * Some helpers for converting nanosecond timing to jiffy resolution 101 */ 102 - #define NS_TO_JIFFIES(TIME) ((unsigned long)(TIME) / (1000000000 / HZ)) 103 - #define JIFFIES_TO_NS(TIME) ((TIME) * (1000000000 / HZ)) 104 105 #define NICE_0_LOAD SCHED_LOAD_SCALE 106 #define NICE_0_SHIFT SCHED_LOAD_SHIFT ··· 7256 spin_unlock_irqrestore(&cpu_rq(i)->lock, flags); 7257 } 7258 /* Convert from ns to ms */ 7259 - do_div(res, 1000000); 7260 7261 return res; 7262 }
··· 75 */ 76 unsigned long long __attribute__((weak)) sched_clock(void) 77 { 78 + return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ); 79 } 80 81 /* ··· 99 /* 100 * Some helpers for converting nanosecond timing to jiffy resolution 101 */ 102 + #define NS_TO_JIFFIES(TIME) ((unsigned long)(TIME) / (NSEC_PER_SEC / HZ)) 103 + #define JIFFIES_TO_NS(TIME) ((TIME) * (NSEC_PER_SEC / HZ)) 104 105 #define NICE_0_LOAD SCHED_LOAD_SCALE 106 #define NICE_0_SHIFT SCHED_LOAD_SHIFT ··· 7256 spin_unlock_irqrestore(&cpu_rq(i)->lock, flags); 7257 } 7258 /* Convert from ns to ms */ 7259 + do_div(res, NSEC_PER_MSEC); 7260 7261 return res; 7262 }
+2 -2
kernel/sysctl.c
··· 226 227 #ifdef CONFIG_SCHED_DEBUG 228 static unsigned long min_sched_granularity_ns = 100000; /* 100 usecs */ 229 - static unsigned long max_sched_granularity_ns = 1000000000; /* 1 second */ 230 static unsigned long min_wakeup_granularity_ns; /* 0 usecs */ 231 - static unsigned long max_wakeup_granularity_ns = 1000000000; /* 1 second */ 232 #endif 233 234 static struct ctl_table kern_table[] = {
··· 226 227 #ifdef CONFIG_SCHED_DEBUG 228 static unsigned long min_sched_granularity_ns = 100000; /* 100 usecs */ 229 + static unsigned long max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 230 static unsigned long min_wakeup_granularity_ns; /* 0 usecs */ 231 + static unsigned long max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 232 #endif 233 234 static struct ctl_table kern_table[] = {