[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <YTBPR01MB3262E37307F17B3374B64CF6C4A20@YTBPR01MB3262.CANPRD01.PROD.OUTLOOK.COM>
Date: Wed, 20 Jan 2021 18:58:47 +0000
From: "Zhou Ti (x2019cwm)" <x2019cwm@...x.ca>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] fix the issue that the tick_nohz_get_sleep_length() function
could return a negative value
Fix the issue that the tick_nohz_get_sleep_length() function could return
a negative value.
The variable "next_event" has a small possibility to be smaller than the
variable "now" during running. Since both the menu idle governor and the
teo idle governor use u64 to store the return value of the function, this
may result in an extremely large and invalid value.
One can easily detect the existence of this issue by using printk to
output a warning.
Signed-off-by: Ti Zhou <x2019cwm@...x.ca>
---
--- tip/kernel/time/tick-sched.c.orig 2021-01-20 05:34:25.151325912 -0400
+++ tip/kernel/time/tick-sched.c 2021-01-20 07:09:15.060980886 -0400
@@ -1156,6 +1156,9 @@ ktime_t tick_nohz_get_sleep_length(ktime
next_event = min_t(u64, next_event,
hrtimer_next_event_without(&ts->sched_timer));
+ if (unlikely(next_event < now))
+ next_event = now;
+
return ktime_sub(next_event, now);
}
Powered by blists - more mailing lists