From 9b3c7b568f99e18c8d6dad23b4571d786175fd85 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 4 Nov 2016 09:25:54 +1100 Subject: [PATCH 04/14] Convert msleep to use hrtimers when active. --- kernel/time/timer.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index cd067bc..7651d47 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1887,7 +1887,13 @@ void __init init_timers(void) */ void msleep(unsigned int msecs) { - unsigned long timeout = msecs_to_jiffies(msecs) + 1; + unsigned long timeout; + + if (likely(hrtimer_resolution < NSEC_PER_SEC / HZ)) { + while (msecs) + msecs = schedule_msec_hrtimeout_uninterruptible(msecs); + } + timeout = msecs_to_jiffies(msecs) + 1; while (timeout) timeout = schedule_timeout_uninterruptible(timeout); @@ -1901,7 +1907,14 @@ EXPORT_SYMBOL(msleep); */ unsigned long msleep_interruptible(unsigned int msecs) { - unsigned long timeout = msecs_to_jiffies(msecs) + 1; + unsigned long timeout; + + if (likely(hrtimer_resolution < NSEC_PER_SEC / HZ)) { + while (msecs && !signal_pending(current)) + msecs = schedule_msec_hrtimeout_interruptible(msecs); + return msecs; + } + timeout = msecs_to_jiffies(msecs) + 1; while (timeout && !signal_pending(current)) timeout = schedule_timeout_interruptible(timeout); -- 2.7.4