Messages in this thread Patch in this message | | | Date | Mon, 25 Apr 2022 09:33:30 +0900 | Subject | Re: [PATCH] checkpatch: warn about flushing system-wide workqueues | From | Tetsuo Handa <> |
| |
On 2022/04/25 8:45, Joe Perches wrote: > And it's probably more readable using separate lines and it looks as > if the 3rd test is unnecessary as it could be combined with the 2nd. > > if ($line =~ /\bflush_scheduled_work\s*\(/ || > $line =~ /\bflush_workqueue\s*\(\s*system(_\w*)?_wq\s*\)/) {
We don't need to worry about possibility like
flush_workqueue(system_module1_wq);
? Then, we can simplify like you suggested.
From 06a4c861eed2062ba58c3023ec28b1b3020bd1f8 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Date: Mon, 25 Apr 2022 09:28:27 +0900 Subject: [PATCH v2] checkpatch: warn about flushing system-wide workqueues
Flushing the system-wide WQ has possibility of deadlock, for the caller waits for completion of all works in that WQ even if the caller cannot wait for completion of one of works due to locking dependency. Since it is difficult to catch such attempts using lockdep, try to catch also using checkpatch.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> --- Changes in v2: Simplify matching, suggested by Joe Perches <joe@perches.com>
scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 577e02998701..88491cfcfd59 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7226,6 +7226,13 @@ sub process { "Deprecated use of '$deprecated_api', prefer '$new_api' instead\n" . $herecurr); } +# check for flushing system-wide workqueues + if ($line =~ /\bflush_scheduled_work\s*\(/ || + $line =~ /\bflush_workqueue\s*\(\s*system(_\w*)?_wq\s*\)/) { + ERROR("DEPRECATED_API", + "Flushing system-wide workqueues is dangerous and will be forbidden - see https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236\@I-love.SAKURA.ne.jp\n" . $herecurr); + } + # check for various structs that are normally const (ops, kgdb, device_tree) # and avoid what seem like struct definitions 'struct foo {' if (defined($const_structs) && -- 2.34.1
| |