[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <YTBPR01MB3262A1EAA009500DF6DD2132C4A20@YTBPR01MB3262.CANPRD01.PROD.OUTLOOK.COM>
Date: Wed, 20 Jan 2021 23:49:38 +0000
From: "Zhou Ti (x2019cwm)" <x2019cwm@...x.ca>
To: "fweisbec@...il.com" <fweisbec@...il.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...nel.org" <mingo@...nel.org>,
"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 "dev->next_event" has a small possibility to be smaller than
the variable "now" during running, which would result in a negative value
of "*delta_next". The variable "next_event" also has a small posibility to
be smaller than the variable "now". Both case could lead to a negative
return of function tick_nohz_get_sleep_length().
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 19:44:28.238538380 -0400
@@ -1142,6 +1142,9 @@ ktime_t tick_nohz_get_sleep_length(ktime
*delta_next = ktime_sub(dev->next_event, now);
+ if (unlikely(*delta_next < 0))
+ *delta_next = 0;
+
if (!can_stop_idle_tick(cpu, ts))
return *delta_next;
@@ -1156,6 +1159,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