From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB4A7403155 for ; Tue, 26 May 2026 15:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807688; cv=none; b=WYi4y8vI0t7k5IDS8BWJvuet5TWc5ka+N5QdbHQ3W49tg3zJFE52WPh1GAtp/1E+mMiOvi7ocxYuFwUOQuSuz8rIqdWp4ZYZw6Dbfs0jeH3eAlZUlCKXzx4wScTGkry5TWbuREKCb09u4DycB4MzkxUfWeaoAF8GBD1NnvzHs/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807688; c=relaxed/simple; bh=7fqF8wPuMdvOYLtQJV5oksjv897cu/VBFTWwzP2VxxE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lgx0fw/FwoVltFJ1McVLhOYQq1jTgA86rfdzQCXclcwntH9MBOYFu6rZjRQv2X4PjcOa0pGqUY699OHp8MYsQmtAxAdzs4waAi1o6lVUm1u8oQkeW1g8v9VimRxcp/qOhhU5YphSNk6PU6D61VTIcaoDTSSWUfI7Y8ms7n9BBf4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=X0WtIsoP; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="X0WtIsoP" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so34745055e9.0 for ; Tue, 26 May 2026 08:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1779807685; x=1780412485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iGRmf066qXCz9WHWhHDiq2wFPvpv41Fo2uyMaoNqLIA=; b=X0WtIsoPFNmEyyPjxtrPfzgPwXduowAXQxbeBen81qKQhu5icG7Ck41tSTjzf+4Q99 NLiPg65j8pOdrvkZKvclzKB7B9yBW/pAYI97vXOFg/DQAdgKG4JQ8srMV0WGjF78EkYa 2tWiM5d9z3tDKaLfJ/uoA9Tgxk97vvBc0mZ4mYoCxJCo1/km3K/L5SK1lvpXWyBWUhbg PiwwSiXZMHJo0s6PnrU2PKRI6Xe9kezPn4R6pHuDQ3QOcEjW0wrblNDJUd1KqMLgWUb2 NmQX/4kE7fGDHijySEcADXpveKtWhJpbWcPpcRBD5q6Agb/K7FWnTVBXYHvU1ONSyS61 sgOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779807685; x=1780412485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iGRmf066qXCz9WHWhHDiq2wFPvpv41Fo2uyMaoNqLIA=; b=ezKJZ9wnccteMLTIxh92EmrcFxMrEfISr4lujjohvpD+HwIEuNTl0iy78icwZlnDrl hVUWZUvVO/LeneY4huBZBMxe+zhWBqfJ0A8lcWW4ZxsW4TtkF7Nmx3Fk82ggkvyCFgQ8 2VspAlhTIb4z3pWWjGldbJY+vtxK97dAm1vFB8B+BcDJxWCGiJYbMpCxhXG/3bZ+dkE2 eFn/Nj3cf+Hh03mo+GdCaPUpyvAH4O/Jg2O4ny9wEDRR2/nNRziLNYSdBjplm79MZlRE tiRAkvqpFwRdwMR1SZ2WWOIMGaLSbyu83TxTnEhqmizJS5Dwy5zMR+vL9R3Kg2sz62IT 0v5w== X-Gm-Message-State: AOJu0Yz5mkAXpush17EBBYxzWJME4kcM4skOC4b+jotSDKBZnq8cE3lH WO3I4TpglCs9r5CvLYRFDQuMGpoWeveTZqbdm6iJnpQ46ffFxf3PUKZ0LxPaLLCpvt+pUxBc+Bz /bRmC054= X-Gm-Gg: Acq92OHA9EAc9lHkOEHP1SK13AKSieyf+FUY8Zdc7SB/s9+gwcpdttUyo/qWxjCJzli /3hBa5M09hG16bM2rrPJO1RHTgHJeih3EwVe0VPRdzFhvz/mbey6EoPz94SC/fXGViYmKuDkPac 3XV78RXqHEpjPzKYPyRfH9NjqdEAJlfUsk/S12vtX/m7VCJFe0ykesfbmQ0jt6NYGpuIkk1UkSj S2EwfbH5iZITPeiJPHjfzoLhxu+gIylicCuwcdGNqJfXxftIC/rwZqAWP/fza0D9nOikIpGNSXv e0zMm27fKWYFRys0nWGK40y1xh+BcQBDdmvIv96qoAiW3Lx3bBxythQ3ieuJzEZqptev36hhLX3 dCSLm/kv8sg+4FCuyRhW2y/JPLZcDSUGdcZEeRnh53cTjaF1qD8H/q16l23CQwPmgX8mBMc+zVO I7bSE41UByeV4/vXTyMqwe9RR4Y4/kss59F1L4olI5Fh9GdTkR9y5Vhr9mag== X-Received: by 2002:a05:600c:4510:b0:490:3d2e:b67d with SMTP id 5b1f17b1804b1-490428eb9aamr292508865e9.30.1779807670919; Tue, 26 May 2026 08:01:10 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490428e6d68sm113956585e9.22.2026.05.26.08.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 08:01:10 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Breno Leitao Subject: [RFC PATCH v2 1/2] workqueue: Add warnings and fallback if system_{unbound}_wq is used Date: Tue, 26 May 2026 17:00:40 +0200 Message-ID: <20260526150041.365392-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150041.365392-1-marco.crivellari@suse.com> References: <20260526150041.365392-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently many users transitioned already to the new introduced workqueue (system_percpu_wq, system_dfl_wq), but there are new users who still use the older system_wq and system_unbound_wq. This change try to push this transition forward, by warning whether the old workqueus are used and redirecting them old used workqueue with the appropriate new one. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- kernel/workqueue.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 33b721a9af02..e17617e205b1 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2437,6 +2437,24 @@ bool queue_work_on(int cpu, struct workqueue_struct *wq, bool ret = false; unsigned long irq_flags; + /* + * NOTE: These checks are here to assure that no users will still + * rely on system_wq and system_unbound_wq. + * They can be removed along with those workqueue when the + * time comes. + */ + if (unlikely(wq == system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_percpu_wq; + } else if (unlikely(wq == system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_dfl_wq; + } + local_irq_save(irq_flags); if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) && @@ -2604,6 +2622,24 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, bool ret = false; unsigned long irq_flags; + /* + * NOTE: These checks are here to assure that no users will still + * rely on system_wq and system_unbound_wq. + * They can be removed along with those workqueue when the + * time comes. + */ + if (unlikely(wq == system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_percpu_wq; + } else if (unlikely(wq == system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_dfl_wq; + } + /* read the comment in __queue_work() */ local_irq_save(irq_flags); @@ -2642,6 +2678,24 @@ bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq, unsigned long irq_flags; bool ret; + /* + * NOTE: These checks are here to assure that no users will still + * rely on system_wq and system_unbound_wq. + * They can be removed along with those workqueue when the + * time comes. + */ + if (unlikely(wq == system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_percpu_wq; + } else if (unlikely(wq == system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_dfl_wq; + } + ret = work_grab_pending(&dwork->work, WORK_CANCEL_DELAYED, &irq_flags); if (!clear_pending_if_disabled(&dwork->work)) @@ -2676,6 +2730,24 @@ bool queue_rcu_work(struct workqueue_struct *wq, struct rcu_work *rwork) { struct work_struct *work = &rwork->work; + /* + * NOTE: These checks are here to assure that no users will still + * rely on system_wq and system_unbound_wq. + * They can be removed along with those workqueue when the + * time comes. + */ + if (unlikely(wq == system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_percpu_wq; + } else if (unlikely(wq == system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq = system_dfl_wq; + } + /* * rcu_work can't be canceled or disabled. Warn if the user reached * inside @rwork and disabled the inner work. -- 2.54.0