Skip to content

Commit

Permalink
timers: Remove historical extra jiffie for timeout in msleep()
Browse files Browse the repository at this point in the history
msleep() and msleep_interruptible() add a jiffie to the requested timeout.

This extra jiffie was introduced to ensure that the timeout will not happen
earlier than specified.

Since the rework of the timer wheel, the enqueue path already takes care of
this. So the extra jiffie added by msleep*() is pointless now.

Remove this extra jiffie in msleep() and msleep_interruptible().

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/all/20240829074133.4547-1-anna-maria@linutronix.de
  • Loading branch information
Anna-Maria Behnsen authored and Thomas Gleixner committed Aug 29, 2024
1 parent ed4fb6d commit 4381b89
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/time/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2732,7 +2732,7 @@ void __init init_timers(void)
*/
void msleep(unsigned int msecs)
{
unsigned long timeout = msecs_to_jiffies(msecs) + 1;
unsigned long timeout = msecs_to_jiffies(msecs);

while (timeout)
timeout = schedule_timeout_uninterruptible(timeout);
Expand All @@ -2746,7 +2746,7 @@ EXPORT_SYMBOL(msleep);
*/
unsigned long msleep_interruptible(unsigned int msecs)
{
unsigned long timeout = msecs_to_jiffies(msecs) + 1;
unsigned long timeout = msecs_to_jiffies(msecs);

while (timeout && !signal_pending(current))
timeout = schedule_timeout_interruptible(timeout);
Expand Down

0 comments on commit 4381b89

Please sign in to comment.