Messages in this thread Patch in this message |  | | Date | Mon, 25 Apr 2022 08:31:51 +0900 | From | Tetsuo Handa <> | Subject | [PATCH] 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> --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 577e02998701..d114652ba837 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\b\s*\(/ || $line =~ /\bflush_workqueue\b\s*\(\s*\bsystem_wq\b\s*\)/ || + $line =~ /\bflush_workqueue\b\s*\(\s*\bsystem_(highpri|long|unbound|freezable|power_efficient|freezable_power_efficient)_wq\b\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
|  |