Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2071654pxp; Mon, 21 Mar 2022 10:37:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyflkIKuNZb0ZRG3zIKH4rYg6NiL/NdzO5eQ99QUD3lC8prWI9YABiMnVQEsW9DEwN+RRZe X-Received: by 2002:a17:902:cecb:b0:154:68b6:cf61 with SMTP id d11-20020a170902cecb00b0015468b6cf61mr3719223plg.12.1647884273933; Mon, 21 Mar 2022 10:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647884273; cv=none; d=google.com; s=arc-20160816; b=fhxWLQRSuDgII7I/nxzifMUfnH4zUyaI8Q8TjRrjcxFiiOxWnF3fxDFNR3GgFouDy8 jcOiUCXOBO8knatTglj7Qo1kHAO7xNS0q9tB2Vi9t3r8wjmr7HJqLahwFhEghhUSEfpp 0vK6JnRbrO35hnVP183F8lyNSkD51SrvlyrqqHJCjqf+EgsaQewHCN78r/nFurHbfuXz KxNFCqiZ1nv0sK/nn1VebMEfTxd59y6DlYS6BXIYBDf9pH/QxJ7SYmmo8UMw8NJLxLqa 1HKliMLI3SgJjxh6kDVgxbmQCXNoj157uKFCNYIoNW3EGJUXG5dkZ12GuV6SYYsK7Pby 0SZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ywV9XezMCx96rb4VrZooCjtIbQpi7/ARRh5JvVZdJYE=; b=Zlyxo8+3bcVaRLQdHFvo4by8YsM+jnoQjA9N9Pk3ktRQhykmLsU5NA7oiq7kJpHgHd dozAk/SflHBZQfO46QTsNge4R9qRW9ekTduHShsmM0HTfeABgYOKoLCrXj7z3XpxhERj m4z44FcapBbs5XW+JFPK5Zc/F5/I6IHj7R2WD66G6DOxoSwUMq0x+ZNdywju5n9dvZDk I028ZlnlKukPnPrZ+sBcwe+Skb+FSugSx+fEObxYkPsoTjSekWTqIS0nFaK2zasopRfr qlQuztYRkSdg10Ij+nepwvytKD0xnDTfVCqi7IqiDRUom6NvoNjFP0tsMIDy6qJtwCNE RL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=iKqZ2o7G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a170902ac8700b00153b2d1646esi11317557plr.118.2022.03.21.10.37.40; Mon, 21 Mar 2022 10:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=iKqZ2o7G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242528AbiCSRRm (ORCPT + 99 others); Sat, 19 Mar 2022 13:17:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233507AbiCSRRj (ORCPT ); Sat, 19 Mar 2022 13:17:39 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F333292D8E for ; Sat, 19 Mar 2022 10:16:18 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id h7so1180062lfl.2 for ; Sat, 19 Mar 2022 10:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ywV9XezMCx96rb4VrZooCjtIbQpi7/ARRh5JvVZdJYE=; b=iKqZ2o7G85SB3bYZDrttGen1nkl6dTn5mjWR9h1otmceslBE1UK0h4hpkSAePhgwAC 2ZyEy5c49q2rTc/zTUrorAFPhJVKJLxhErUuQs0PuA/zWyhAwY3EIUIpsbKPotmmC/rw Hkmw/8Hu76komc+A1QTfhAIXburQEBsFompOg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ywV9XezMCx96rb4VrZooCjtIbQpi7/ARRh5JvVZdJYE=; b=N3f2HDtZqGvSPexykXXWNISrzMD2eLGBnD3Y1BLqaWH79XVrCoKfxXGi6/C/KBfoqY TbpTJG/64siWuQej1cNn/lrphrbYblEQhl9fZAeZgxle0PSQECDVlDlV+35DL7bB2dfR vBRXYFmh3q248byOtZa6Ib2eL16OLpzuQtO6ccbCjC2XTC1UsecGuBoiUr7U2xHRMFcE Zm1XTTC64xRsx9GQUsFpeickYvwvt3V0AhIa8Pxkw9r6b4/BM4eC/nyFXD15krt7ggd5 b6Wf7EOkPl0/KBrdVai6PKDIFkX7Fm5BhqDKLB7QEOZpamQzex5ia/M7681r/hhq0hcW s+Bg== X-Gm-Message-State: AOAM5319srt7swhtZn9O2oVG90/R2jcjn+A43/rJQJSoNZcWEYe+MTVg HCnX9OcEvtnbI8Xv2HjLUhekGg5KSuZf0t6MUfg= X-Received: by 2002:a05:6512:3043:b0:448:4c96:b812 with SMTP id b3-20020a056512304300b004484c96b812mr9322745lfb.275.1647710175972; Sat, 19 Mar 2022 10:16:15 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id w18-20020ac254b2000000b00448324df809sm1342621lfk.86.2022.03.19.10.16.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Mar 2022 10:16:15 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id s25so14984870lji.5 for ; Sat, 19 Mar 2022 10:16:14 -0700 (PDT) X-Received: by 2002:a2e:6f17:0:b0:248:124:9c08 with SMTP id k23-20020a2e6f17000000b0024801249c08mr9823629ljc.506.1647710174683; Sat, 19 Mar 2022 10:16:14 -0700 (PDT) MIME-Version: 1.0 References: <2efd5461-fccd-f1d9-7138-0a6767cbf5fe@I-love.SAKURA.ne.jp> In-Reply-To: <2efd5461-fccd-f1d9-7138-0a6767cbf5fe@I-love.SAKURA.ne.jp> From: Linus Torvalds Date: Sat, 19 Mar 2022 10:15:58 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 (repost)] workqueue: Warn flushing of kernel-global workqueues To: Tetsuo Handa Cc: Tejun Heo , Lai Jiangshan , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, Mar 18, 2022 at 9:43 PM Tetsuo Handa wrote: > > Since flush operation synchronously waits for completion, flushing > kernel-global WQs (e.g. system_wq) might introduce possibility of deadlock > due to unexpected locking dependency. Tejun Heo commented that it makes no > sense at all to call flush_workqueue() on the shared WQs as the caller has > no idea what it's gonna end up waiting for. NAK on this patch for a very simple reason: static inline void flush_scheduled_work(void) { flush_workqueue(system_wq); } and now grep for flush_scheduled_work(). The *other* system workqueue flushes may be rare and "that subsystem should just be converted to do its own workqueue". But flush_scheduled_work() is literally exported as an explicit and separate interface, The fact that the function has a big warning in the comment above it doesn't change that fact. At the very least, this patch has to be preceded by a couple of other patches that fix a couple of subsystems and document "this is what you should do". Because suddenly saying "hey, we gave you this interface, now we're warning about it because it's going to go away" without actually showing how to do it instead is not acceptable. And honestly, I don't personally see a good conversion. We literally have all those "schedule_{delayed_}work{_on}()" etc helper functions that are *designed* to use this system_wq. People *need* the ability to flush those things, even if it's only for module unload. So I really think this patch on its own is completely broken. It'd not pointing to a way forward, it's just saying "don't do this" with no really acceptable way to not do it. Removing flush_scheduled_work() needs to be paired with removing the "schedule_{delayed_}work{_on}()" helpers too. And I don't see you having a good alternative. So until that clear way forward exists, NAK. Linus