From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EE27C433EF for ; Thu, 5 May 2022 15:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354277AbiEEQBu (ORCPT ); Thu, 5 May 2022 12:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381560AbiEEQBS (ORCPT ); Thu, 5 May 2022 12:01:18 -0400 X-Greylist: delayed 519 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 05 May 2022 08:57:15 PDT Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 588B25C667 for ; Thu, 5 May 2022 08:57:14 -0700 (PDT) Received: from omf11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7E18621BEE; Thu, 5 May 2022 15:48:34 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA id E73062002D; Thu, 5 May 2022 15:48:32 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: warn about flushing system-wide workqueues From: Joe Perches To: Tetsuo Handa , Tejun Heo Cc: LKML , Linus Torvalds , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn Date: Thu, 05 May 2022 08:48:31 -0700 In-Reply-To: <738afe71-2983-05d5-f0fc-d94efbdf7634@I-love.SAKURA.ne.jp> References: <6e4ed62e-888b-6e7a-c13d-67656f39ca94@I-love.SAKURA.ne.jp> <738afe71-2983-05d5-f0fc-d94efbdf7634@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Stat-Signature: arimd99ims9sz1xexr6t1zgiaym4ssx6 X-Rspamd-Server: rspamout08 X-Rspamd-Queue-Id: E73062002D X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18U2wAxqfm+TPfR8ZOIlZZ2wsrQkLgB3BM= X-HE-Tag: 1651765712-606268 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2022-05-05 at 22:42 +0900, Tetsuo Handa wrote: > On 2022/04/25 9:33, Tetsuo Handa wrote: > > 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. > > I initially thought that also doing static checks by scripts/checkpatch.pl > is better than only doing runtime WARN_ON(). But not all patches are checked > by scripts/checkpatch.pl . Thus, as an attempt to check without exemptions, > I now think that doing static checks via BUILD_BUG_ON() is better than > scripts/checkpatch.pl . I sent below patch to linux-next.git , and so far > it seems working (I mean, no build failure reports caused by compilers). > > Subject: workqueue: Wrap flush_workqueue() using a macro > > A conversion to stop flushing kernel-global workqueues is in progress. > Wrap flush_workqueue() and inject BUILD_BUG_ON() checks, in order to > prevent users who are not aware of this conversion from again start > flushing kernel-global workqueues. [] > diff --git a/kernel/workqueue.c b/kernel/workqueue.c [] > @@ -2813,6 +2813,7 @@ static void warn_flush_attempt(struct workqueue_struct *wq) > * This function sleeps until all work items which were queued on entry > * have finished execution, but it is not livelocked by new incoming ones. > */ > +#undef flush_workqueue > void flush_workqueue(struct workqueue_struct *wq) The #undef flush_workqueue could be removed by using void (flush_workqueue)(struct workqueue_struct *wq) { ... }