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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67577c238ead009b3b061a43d443dc69da2aee64.camel@perches.com>
Date: Sun, 08 Feb 2026 08:36:05 -0800
From: Joe Perches <joe@...ches.com>
To: Neel Bullywon <neelb2403@...il.com>, apw@...onical.com
Cc: dwaipayanray1@...il.com, lukas.bulwahn@...il.com, 
	andriy.shevchenko@...el.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] checkpatch: suggest fsleep() for short msleep() calls

On Sun, 2026-02-08 at 10:59 -0500, Neel Bullywon wrote:
> Update the MSLEEP warning to suggest fsleep() as a duration based
> sleep API. fsleep() autoselects the best sleep mechanism (udelay,
> usleep_range, or msleep) based on the requested duration, making
> it the preferred replacement for short msleep() calls.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -6636,7 +6636,7 @@ sub process {
>  		if ($line =~ /\bmsleep\s*\((\d+)\);/) {
>  			if ($1 < 20) {
>  				WARN("MSLEEP",
> -				     "msleep < 20ms can sleep for up to 20ms; see function description of msleep().\n" . $herecurr);
> +				     "msleep < 20ms can sleep for up to 20ms; see function description of fsleep().\n" . $herecurr);
>  			}
>  		}

maybe change msleep to a #define macro so if the argument is
constant call fsleep instead

Something like:

#define msleep(msecs)						\
do {								\
	if (__builtin_constant_p(msecs) && (msecs) < 20)	\
		fsleep((msecs) * 1000UL);			\
	else							\
		msleep(msecs);					\
} while (0)

and change the definition of void msleep(unsigned int msecs) to

void (msleep)(unsigned int msecs)
{
	etc...
}

and remove the checkpatch test.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ