lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1470991213-12086-1-git-send-email-ville.syrjala@linux.intel.com>
Date:	Fri, 12 Aug 2016 11:40:13 +0300
From:	ville.syrjala@...ux.intel.com
To:	linux-kernel@...r.kernel.org
Cc:	Thomas Gleixner <tglx@...utronix.de>,
	John Stultz <john.stultz@...aro.org>,
	Ville Syrjälä 
	<ville.syrjala@...ux.intel.com>
Subject: [PATCH] timer: Make msleep(0) a nop

From: Ville Syrjälä <ville.syrjala@...ux.intel.com>

Thanks to the msecs_to_jiffies()+1 msleep(0) may actually sleep for up
to one jiffy. Presumably the caller should be satisfied if we "sleep"
for 0 jiffies instead of 0-1 jiffies, so let's just turn msleep(0)
into a nop.

This can simplify some callers as they don't have to check for the
0 msecs case themselves anymore. Or if they're not checking for 0,
they might avoid a needless sleep occasionally.

A slight concern might be that someone is calling msleep(0) and
depending on some delay being there. But that can clearly blow up
even without this change, so I'm not overly worried about it.

Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: John Stultz <john.stultz@...aro.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@...ux.intel.com>
---
 kernel/time/timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 555670a5143c..1f9ccfccb68f 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1870,7 +1870,7 @@ void __init init_timers(void)
  */
 void msleep(unsigned int msecs)
 {
-	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
+	unsigned long timeout = msecs ? msecs_to_jiffies(msecs) + 1 : 0;
 
 	while (timeout)
 		timeout = schedule_timeout_uninterruptible(timeout);
@@ -1884,7 +1884,7 @@ EXPORT_SYMBOL(msleep);
  */
 unsigned long msleep_interruptible(unsigned int msecs)
 {
-	unsigned long timeout = msecs_to_jiffies(msecs) + 1;
+	unsigned long timeout = msecs ? msecs_to_jiffies(msecs) + 1 : 0;
 
 	while (timeout && !signal_pending(current))
 		timeout = schedule_timeout_interruptible(timeout);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ