From: Frederic Weisbecker <frederic@kernel.org>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, Len Brown <len.brown@intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
rust-for-linux@vger.kernel.org, Alice Ryhl <aliceryhl@google.com>,
FUJITA Tomonori <fujita.tomonori@gmail.com>,
Andrew Lunn <andrew@lunn.ch>, Miguel Ojeda <ojeda@kernel.org>,
Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>
Subject: Re: [PATCH v3 16/16] checkpatch: Remove broken sleep/delay related checks
Date: Tue, 15 Oct 2024 16:22:23 +0200 [thread overview]
Message-ID: <Zw56n9P0Io1bMb0y@localhost.localdomain> (raw)
In-Reply-To: <20241014-devel-anna-maria-b4-timers-flseep-v3-16-dc8b907cb62f@linutronix.de>
Le Mon, Oct 14, 2024 at 10:22:33AM +0200, Anna-Maria Behnsen a écrit :
> checkpatch.pl checks for several things related to sleep and delay
> functions. In all warnings the outdated documentation is referenced. All
> broken parts are listed one by one in the following with an explanation why
> this check is broken. For a basic background of those functions please also
> refere to the updated function descriptions of udelay(), nsleep_range() and
> msleep().
>
> Be aware: The change is done with a perl knowledge of the level "I'm able
> to spell perl".
>
> The following checks are broken:
>
> - Check: (! ($delay < 10) )
> Message: "usleep_range is preferred over udelay;
> see Documentation/timers/timers-howto.rst\n"
> Why is the check broken: When it is an atomic context, udelay() is
> mandatory.
>
> - Check: ($min eq $max)
> Message: "usleep_range should not use min == max args;
> see Documentation/timers/timers-howto.rst\n"
> Why is the check broken: When the requested accuracy for the sleep
> duration requires it, it is also valid to use
> min == max.
>
> - Check: ($delay > 2000)
> Message: "long udelay - prefer mdelay;
> see arch/arm/include/asm/delay.h\n"
> Why is the check broken: The threshold when to start using mdelay() to
> prevent an overflow depends on
> MAX_UDELAY_MS. This value is architecture
> dependent. The used value for the check and
> reference is arm specific. Generic would be 5ms,
> but this would "break" arm, loongarch and mips
> and also the arm value might "break" mips and
> loongarch in some configurations.
>
> - Check: ($1 < 20)
> Message: "msleep < 20ms can sleep for up to 20ms;
> see Documentation/timers/timers-howto.rst\n"
> Why is the check broken: msleep(1) might sleep up to 20ms but only on a
> HZ=100 system. On a HZ=1000 system this will be
> 2ms. This means, the threshold cannot be hard
> coded as it depends on HZ (jiffy granularity and
> timer wheel bucket/level granularity) and also
> on the required accuracy of the callsite. See
> msleep() and also the USLEEP_RANGE_UPPER_BOUND
> value.
>
> Remove all broken checks. Update checkpatch documentation accordingly.
>
> Cc: Andy Whitcroft <apw@canonical.com>
> Cc: Joe Perches <joe@perches.com>
> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
> ---
> v3: Move it to the end of the queue and adapt it to the new patch which
> removes the link to the outdated documentation before.
> v2: Rephrase commit message
> ---
> Documentation/dev-tools/checkpatch.rst | 4 ----
> scripts/checkpatch.pl | 38 ----------------------------------
> 2 files changed, 42 deletions(-)
>
> diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
> index abb3ff682076..f5c27be9e673 100644
> --- a/Documentation/dev-tools/checkpatch.rst
> +++ b/Documentation/dev-tools/checkpatch.rst
> @@ -466,10 +466,6 @@ API usage
> **UAPI_INCLUDE**
> No #include statements in include/uapi should use a uapi/ path.
>
> - **USLEEP_RANGE**
> - usleep_range() should be preferred over udelay(). The proper way of
> - using usleep_range() is mentioned in the kernel docs.
> -
>
> Comments
> --------
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 98790fe5115d..34d4b5beda29 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -6591,28 +6591,6 @@ sub process {
> }
> }
>
> -# prefer usleep_range over udelay
> - if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
> - my $delay = $1;
> - # ignore udelay's < 10, however
> - if (! ($delay < 10) ) {
> - CHK("USLEEP_RANGE",
> - "usleep_range is preferred over udelay; see function description of usleep_range() and udelay().\n" . $herecurr);
> - }
> - if ($delay > 2000) {
> - WARN("LONG_UDELAY",
> - "long udelay - prefer mdelay; see function description of mdelay().\n" . $herecurr);
> - }
> - }
> -
> -# warn about unexpectedly long msleep's
> - 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);
> - }
> - }
> -
> # check for comparisons of jiffies
> if ($line =~ /\bjiffies\s*$Compare|$Compare\s*jiffies\b/) {
> WARN("JIFFIES_COMPARISON",
> @@ -7069,22 +7047,6 @@ sub process {
> }
> }
>
> -# check usleep_range arguments
> - if ($perl_version_ok &&
> - defined $stat &&
> - $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) {
> - my $min = $1;
> - my $max = $7;
> - if ($min eq $max) {
> - WARN("USLEEP_RANGE",
> - "usleep_range should not use min == max args; see function description of usleep_range().\n" . "$here\n$stat\n");
> - } elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ &&
> - $min > $max) {
> - WARN("USLEEP_RANGE",
> - "usleep_range args reversed, use min then max; see function description of usleep_range().\n" . "$here\n$stat\n");
Why not keep the min > max static check?
Thanks.
> - }
> - }
> -
> # check for naked sscanf
> if ($perl_version_ok &&
> defined $stat &&
>
> --
> 2.39.5
>
next prev parent reply other threads:[~2024-10-15 14:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 8:22 [PATCH v3 00/16] timers: Cleanup delay/sleep related mess Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 01/16] MAINTAINERS: Add missing file include/linux/delay.h Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 02/16] timers: Move *sleep*() and timeout functions into a separate file Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 03/16] timers: Update schedule_[hr]timeout*() related function descriptions Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 04/16] timers: Rename usleep_idle_range() to usleep_range_idle() Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 05/16] timers: Update function descriptions of sleep/delay related functions Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 06/16] delay: Rework udelay and ndelay Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 07/16] timers: Adjust flseep() to reflect reality Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 08/16] mm/damon/core: Use generic upper bound recommondation for usleep_range() Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 09/16] timers: Add a warning to usleep_range_state() for wrong order of arguments Anna-Maria Behnsen
2024-10-15 13:54 ` Frederic Weisbecker
2024-10-14 8:22 ` [PATCH v3 10/16] checkpatch: Remove links to outdated documentation Anna-Maria Behnsen
2024-10-15 14:08 ` Frederic Weisbecker
2024-10-14 8:22 ` [PATCH v3 11/16] regulator: core: Use fsleep() to get best sleep mechanism Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 12/16] iopoll/regmap/phy/snd: Fix comment referencing outdated timer documentation Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 13/16] powerpc/rtas: Use fsleep() to minimize additional sleep duration Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 14/16] media: anysee: Fix and remove outdated comment Anna-Maria Behnsen
2024-10-15 14:11 ` Frederic Weisbecker
2024-10-14 8:22 ` [PATCH v3 15/16] timers/Documentation: Cleanup delay/sleep documentation Anna-Maria Behnsen
2024-10-14 8:22 ` [PATCH v3 16/16] checkpatch: Remove broken sleep/delay related checks Anna-Maria Behnsen
2024-10-15 14:22 ` Frederic Weisbecker [this message]
2024-10-16 9:55 ` Anna-Maria Behnsen
2024-10-16 10:05 ` [PATCH v4] " Anna-Maria Behnsen
2024-10-18 12:31 ` Frederic Weisbecker
2024-10-14 16:22 ` (subset) [PATCH v3 00/16] timers: Cleanup delay/sleep related mess Mark Brown
2024-10-18 8:06 ` Anna-Maria Behnsen
2024-10-18 18:57 ` Mark Brown
2024-10-18 18:58 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zw56n9P0Io1bMb0y@localhost.localdomain \
--to=frederic@kernel.org \
--cc=aliceryhl@google.com \
--cc=andrew@lunn.ch \
--cc=anna-maria@linutronix.de \
--cc=apw@canonical.com \
--cc=corbet@lwn.net \
--cc=dwaipayanray1@gmail.com \
--cc=fujita.tomonori@gmail.com \
--cc=joe@perches.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).