From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD66823B63C for ; Sun, 8 Feb 2026 18:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770576280; cv=none; b=jT6863dnkN3pwj3r8ehhcD4Dro/TeocRMSL5PeqL7JiVokoqHgvfaFcYFlZwAhpK+s1bzYtqEo5GWr+SS2gYxTpwcNykcZMHNy4beLUY3VNGZyvV7o6BE1y0OhBMFU/2lafPlO2ahvUv74N9ciw0espYfR+uy0DlhNm5T+6F/dA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770576280; c=relaxed/simple; bh=26UUhXBN4KXSgrrBBMnrSUNrCymgI/IqtktDTv2aAHs=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=GC03JloNxZBM67IyhJf6oYfrK77QHJZsizbbcIGT74W9bXyC10KhgeBxHJQROq0bJyR0WCMzA1yAZVeNQCzxKVVIluUbSMUXj2lv70PsA+qWkj4oqBcOi3BqiFMpYERDfvgdGkCWsX89sNloGx69nsKqcvBcIs+oeSvfE+r/3nI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B383C1405B2; Sun, 8 Feb 2026 18:44:33 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA id 7FF142000D; Sun, 8 Feb 2026 18:44:31 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: suggest fsleep() for short msleep() calls From: Joe Perches To: Neel Bullywon , apw@canonical.com Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, andriy.shevchenko@intel.com, linux-kernel@vger.kernel.org Date: Sun, 08 Feb 2026 10:44:30 -0800 In-Reply-To: <67577c238ead009b3b061a43d443dc69da2aee64.camel@perches.com> References: <20260208155935.72687-1-neelb2403@gmail.com> <67577c238ead009b3b061a43d443dc69da2aee64.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 7FF142000D X-Stat-Signature: i591tui9mssph86wju6kozpiyrzdgkoc X-Rspamd-Server: rspamout08 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+wOLVULTii9yIAWypJPCniringZpBRILc= X-HE-Tag: 1770576271-896294 X-HE-Meta: U2FsdGVkX191MS7YGb4bYvM7I/h853hYj1r5V3u2Ofw06b5KQ/gx32gPsL9GXimSsnQS1Cs6/Ihnz0mUa4whrYYw401mEka05t5Pfzqze0EyMNAQnNOXVD7+7r0fvpQfglF6PBha/RrY6uOdYKOzrFbK4vkKo44VCzrVG+7OHCqGyDUnC48S+ljWTygTuzGKMG30lsrzsAkxqCaGmiCIZFMM4VEJ+GrVl2kG5JCqoq1+Ga77YGdILeNNfeZSmiafHJ97snpxCBzAhNl2a2ZH/3OCUfW7AEe2fCdXL8zeBA7RL54hivjDkIo2KelKG1RS On Sun, 2026-02-08 at 08:36 -0800, Joe Perches wrote: > 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 =3D~ /\bmsleep\s*\((\d+)\);/) { > > if ($1 < 20) { > > WARN("MSLEEP", > > - "msleep < 20ms can sleep for up to 20ms; see function descrip= tion of msleep().\n" . $herecurr); > > + "msleep < 20ms can sleep for up to 20ms; see function descrip= tion of fsleep().\n" . $herecurr); > > } > > } >=20 > maybe change msleep to a #define macro so if the argument is > constant call fsleep instead >=20 > Something like: >=20 > #define msleep(msecs) \ > do { \ > if (__builtin_constant_p(msecs) && (msecs) < 20) \ > fsleep((msecs) * 1000UL); \ > else \ > msleep(msecs); \ > } while (0) >=20 > and change the definition of void msleep(unsigned int msecs) to >=20 > void (msleep)(unsigned int msecs) > { > etc... > } >=20 > and remove the checkpatch test. And there are quite a lot of msleep(<20) $ git grep -Pon '\bmsleep\s*\(\s*(?:\d+)\s*\)' | \ awk -F'(' '{ if (strtonum($2) < 20) print; }' | \ wc -l 1709