diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-10 03:19:52 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-10 03:19:52 +0200 |
commit | 7ac6af29202ec27dcdbf1ed5131a141be9958590 (patch) | |
tree | a20c0be935ea685b3b737471e691d39289c2333f /recipes-kernel/linux/files/patches/sched-nohz-Fix-overflow-error-in-scheduler_tick_max_.patch | |
download | meta-nohz-7ac6af29202ec27dcdbf1ed5131a141be9958590.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'recipes-kernel/linux/files/patches/sched-nohz-Fix-overflow-error-in-scheduler_tick_max_.patch')
-rw-r--r-- | recipes-kernel/linux/files/patches/sched-nohz-Fix-overflow-error-in-scheduler_tick_max_.patch | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/recipes-kernel/linux/files/patches/sched-nohz-Fix-overflow-error-in-scheduler_tick_max_.patch b/recipes-kernel/linux/files/patches/sched-nohz-Fix-overflow-error-in-scheduler_tick_max_.patch new file mode 100644 index 0000000..c279422 --- /dev/null +++ b/recipes-kernel/linux/files/patches/sched-nohz-Fix-overflow-error-in-scheduler_tick_max_.patch | |||
@@ -0,0 +1,76 @@ | |||
1 | From 189a149dfc3ab55282b38d2194a0d7def74d8dfa Mon Sep 17 00:00:00 2001 | ||
2 | From: Kevin Hilman <khilman@linaro.org> | ||
3 | Date: Wed, 15 Jan 2014 14:51:38 +0100 | ||
4 | Subject: [PATCH] sched/nohz: Fix overflow error in | ||
5 | scheduler_tick_max_deferment() | ||
6 | |||
7 | While calculating the scheduler tick max deferment, the delta is | ||
8 | converted from microseconds to nanoseconds through a multiplication | ||
9 | against NSEC_PER_USEC. | ||
10 | |||
11 | But this microseconds operand is an unsigned int, thus the result may | ||
12 | likely overflow. The result is cast to u64 but only once the operation | ||
13 | is completed, which is too late to avoid overflown result. | ||
14 | |||
15 | This is currently not a problem because the scheduler tick max deferment | ||
16 | is 1 second. But this may become an issue as we plan to make this | ||
17 | value tunable. | ||
18 | |||
19 | So lets fix this by casting the usecs value to u64 before multiplying by | ||
20 | NSECS_PER_USEC. | ||
21 | |||
22 | Also to prevent from this kind of mistake to happen again, move this | ||
23 | ad-hoc jiffies -> nsecs conversion to a new helper. | ||
24 | |||
25 | Signed-off-by: Kevin Hilman <khilman@linaro.org> | ||
26 | Cc: Thomas Gleixner <tglx@linutronix.de> | ||
27 | Cc: Ingo Molnar <mingo@kernel.org> | ||
28 | Cc: Peter Zijlstra <peterz@infradead.org> | ||
29 | Cc: Alex Shi <alex.shi@linaro.org> | ||
30 | Cc: Steven Rostedt <rostedt@goodmis.org> | ||
31 | Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> | ||
32 | Cc: John Stultz <john.stultz@linaro.org> | ||
33 | Cc: Kevin Hilman <khilman@linaro.org> | ||
34 | Link: http://lkml.kernel.org/r/1387315388-31676-2-git-send-email-khilman@linaro.org | ||
35 | [move ad-hoc conversion to jiffies_to_nsecs helper] | ||
36 | Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> | ||
37 | |||
38 | Signed-off-by: Mats Liljegren <mats.liljegren@enea.com> | ||
39 | --- | ||
40 | include/linux/jiffies.h | 6 ++++++ | ||
41 | kernel/sched/core.c | 2 +- | ||
42 | 2 files changed, 7 insertions(+), 1 deletion(-) | ||
43 | |||
44 | diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h | ||
45 | index 8fb8edf..4df91d4 100644 | ||
46 | --- a/include/linux/jiffies.h | ||
47 | +++ b/include/linux/jiffies.h | ||
48 | @@ -290,6 +290,12 @@ extern unsigned long preset_lpj; | ||
49 | */ | ||
50 | extern unsigned int jiffies_to_msecs(const unsigned long j); | ||
51 | extern unsigned int jiffies_to_usecs(const unsigned long j); | ||
52 | + | ||
53 | +static inline u64 jiffies_to_nsecs(const unsigned long j) | ||
54 | +{ | ||
55 | + return (u64)jiffies_to_usecs(j) * NSEC_PER_USEC; | ||
56 | +} | ||
57 | + | ||
58 | extern unsigned long msecs_to_jiffies(const unsigned int m); | ||
59 | extern unsigned long usecs_to_jiffies(const unsigned int u); | ||
60 | extern unsigned long timespec_to_jiffies(const struct timespec *value); | ||
61 | diff --git a/kernel/sched/core.c b/kernel/sched/core.c | ||
62 | index e8b3350..45c2cf1 100644 | ||
63 | --- a/kernel/sched/core.c | ||
64 | +++ b/kernel/sched/core.c | ||
65 | @@ -2774,7 +2774,7 @@ u64 scheduler_tick_max_deferment(void) | ||
66 | if (time_before_eq(next, now)) | ||
67 | return 0; | ||
68 | |||
69 | - return jiffies_to_usecs(next - now) * NSEC_PER_USEC; | ||
70 | + return jiffies_to_nsecs(next - now); | ||
71 | } | ||
72 | #endif | ||
73 | |||
74 | -- | ||
75 | 1.9.1 | ||
76 | |||