Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp987844iob; Fri, 13 May 2022 18:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykR8DNSRt4xYeRsh8nV+rAac4t9IJdovWW/OG08VGVGWeQJwR64mWj4/I57nZtV3PjxM4e X-Received: by 2002:adf:f7cb:0:b0:20c:9dbd:49be with SMTP id a11-20020adff7cb000000b0020c9dbd49bemr5948235wrq.250.1652492587747; Fri, 13 May 2022 18:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652492587; cv=none; d=google.com; s=arc-20160816; b=zfv4ymFtgCqLQIR1IDwrENLG+Fxvv9ppPznOWgws03YjTkMAgN8A9ms9ORwo2eBbqa l11V/UmFY0rsEfr3HE5a8OXCZA+AOZU5ss92aXrh6cLlhptpUdlm+JD+qA6dqnTMJVkM wqw3RyrP4ggEN3D8nnXRiR+kbWrMXoWU+Rl0jPN2VJ4L+gF/wq0FeJaTO+kMP40rcfO0 ay2R/UbgUXLSdmDLfpSr3/Qr/+sr8eA9I55wL7BUK7RYB/b3SkM/XHa1AMmnhLINkbjs M8IXOkz4Go1qttNKch0zwNTHFtfsNZL1JXyAC3h5/ilOGK3rTpABTbQOTNy8geQxK6+D 3k6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=5OoxfjRX9z3/3iTTxGYkSSPQaoH6JSvu/8nr0RyFKhM=; b=q5+zZUaGsTuAI1IysaXGuV6Tl9PGx5ZNwhfYwfXvGHyc1O9xffCtZPSZaqsutEwfkh FEfkV2Sbo+N+Oh5+V7F7tYuG9mtAJx5CvNiePMvu0Vpa4wdWljatKh9wsZtL3JsCOeLU mGnPIXZ4xSY8a3ke/vPgJnmlrfWJc3eF9I30mGj23q3jfhge0RBRhcv2OzoT9v9hcDtb CUGGot2kOV9/I2otayEyxDfoaK3ZvXkAUMcfJWKh/T+sXtIdy5R+DXOW2P2+8aDWFNCA eMOQ1PdJiVerDAfHIegUvoSLUi45IHbnu4DVt2BIU2OeL4Pn0MJTgtEPeP8Zzs1t0k+D 37Ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p11-20020a5d638b000000b0020c612861c6si3256597wru.333.2022.05.13.18.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1BBA742DC0D; Fri, 13 May 2022 17:08:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353125AbiELLca (ORCPT + 99 others); Thu, 12 May 2022 07:32:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231782AbiELLc2 (ORCPT ); Thu, 12 May 2022 07:32:28 -0400 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF8F69CCB for ; Thu, 12 May 2022 04:32:27 -0700 (PDT) Received: from fsav119.sakura.ne.jp (fsav119.sakura.ne.jp [27.133.134.246]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 24CBWBHs087089; Thu, 12 May 2022 20:32:11 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav119.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav119.sakura.ne.jp); Thu, 12 May 2022 20:32:11 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav119.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 24CBWAoq087076 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Thu, 12 May 2022 20:32:11 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <33772dcb-c5dd-c5e7-30c8-d2397d21b26c@I-love.SAKURA.ne.jp> Date: Thu, 12 May 2022 20:32:10 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v3 (repost)] workqueue: Warn flushing of kernel-global workqueues Content-Language: en-US To: Dmitry Torokhov Cc: Linus Torvalds , Lai Jiangshan , LKML , Tejun Heo References: <2efd5461-fccd-f1d9-7138-0a6767cbf5fe@I-love.SAKURA.ne.jp> From: Tetsuo Handa In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/05/12 19:38, Dmitry Torokhov wrote: > Hi Tejun, > > On Mon, Mar 21, 2022 at 07:02:45AM -1000, Tejun Heo wrote: >> I'm willing to bet that the majority of the use cases can be converted to >> use flush_work() and that'd be the preference. We need a separate workqueue >> iff the flush requrement is complex (e.g. there are multiple dynamic work >> items in flight which need to be flushed together) or the work items needs >> some special attributes (such as MEM_RECLAIM or HIGHPRI) which don't apply >> to the system_wq users in the first place. > > This means that now the code has to keep track of all work items that it > allocated, instead of being able "fire and forget" works (when dealing > with extremely infrequent events) and rely on flush_workqueue() to > cleanup. Yes. Moreover, a patch to catch and refuse at compile time was proposed at https://lkml.kernel.org/r/738afe71-2983-05d5-f0fc-d94efbdf7634@I-love.SAKURA.ne.jp . > That flush typically happens in module unload path, and I > wonder if the restriction on flush_workqueue() could be relaxed to allow > calling it on unload. A patch for drivers/input/mouse/psmouse-smbus.c is waiting for your response at https://lkml.kernel.org/r/25e2b787-cb2c-fb0d-d62c-6577ad1cd9df@I-love.SAKURA.ne.jp . Like many modules, flush_workqueue() happens on only module unload in your case. We currently don't have a flag to tell whether the caller is inside module unload path. And even inside module unload path, flushing the system-wide workqueue is problematic under e.g. GFP_NOFS/GFP_NOIO context. Therefore, I don't think that the caller is inside module unload path as a good exception. Removing flush_scheduled_work() is for proactively avoiding new problems like https://lkml.kernel.org/r/385ce718-f965-4005-56b6-34922c4533b8@I-love.SAKURA.ne.jp and https://lkml.kernel.org/r/20220225112405.355599-10-Jerome.Pouiller@silabs.com . Using local WQ also helps for documentation purpose. This change makes clear where the work's dependency is. Please grep the linux-next.git tree. Some have been already converted. Any chance you have too many out-of-tree modules to convert?