From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 864673B2FE6 for ; Tue, 26 May 2026 15:01:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807673; cv=none; b=s3XHi88QlV+fLIiwJZqt0cQbmIVTvdEGvyLMiVaFkpPCG/iaBnPIBByUoWkybGQmTzz4YRWjLY7yymaRGXQskc8npQMa6Msq7TGNB7QAR4INIpiTGnuSg+PHN3yeMbv538xdW4QDbLQl5eWdP3rZ0xHxMdH/Mi9eK5J1/8SuuTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807673; c=relaxed/simple; bh=+ZLS0dUfw2afhq64SSEkO4ZyCTbkHI9fCNIXvU6GRnw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=M61jvK5rO11MgGxU8yGzekbXmm0hBfRMUWO1PWirUjHTZ3ViecCKWEC+cg/AyXAcR/m8+nfvkT1inchR7De24EBJklMJz1qf8ivAjbTuzY4hz0XBzVoxaJtU0+6XFSjIQ67JzUlembr3xcgvrZtD5xJUDk3kA0EFTzTAaYIJNuI= 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=bjjvVgyi; arc=none smtp.client-ip=209.85.128.41 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="bjjvVgyi" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4896c22fcbaso91543735e9.0 for ; Tue, 26 May 2026 08:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1779807670; x=1780412470; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pZzrKz8Zp1l8ePvPwhvnM6S3nmGT5LvQZeWsQvhCd3s=; b=bjjvVgyiHC/Rqo/BYs+MnY9wwmyifdjgs3/xtuZvuXIY8Ln0oQdbzTO6fga57tTsdc vj5LxF6RK12+HLpnP7TXhHlHQwgAZVbYw/i7fq/zjekUoMyQXIRvfyShUmWrbrOfOdBQ vRr6yorOZJlKkYVfM3f+Js/+irRqVnqFpuDm+8mSx9VWpna/j81i4rb2wnUYg3dt3CIs 0pCmRdPNFhIV1NQt+9SGtijr9ZqF2UlvCOq2yXgZFAuT7oHq314CeiXxpjWvT/W7R5zr K8m7DOgWTIjLGDy7MYiFsbfbvmeDgYHLAB3rwYF8yDdQvWHHuk+BAUxcGoqycn1bkojP sYKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779807670; x=1780412470; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pZzrKz8Zp1l8ePvPwhvnM6S3nmGT5LvQZeWsQvhCd3s=; b=Kr03V00wWHnRetzreiJT8b6V0M9EyaZobFzuNvZJFTiNY38IZlqqD0cdPZP0Vc4/iu 0mWs2JOpBoD43lzOYAhpFpvG2Xd19SC8aE0hT02Y8LLAAavZxCXB9qyFxKLZJgLa4fuN s8i6hJlsr17I5wCFOXU1MNZCf4WsfxI+939431/uD+Tgqokh65T5FVWiKmLh+NsDeNDP U/eEzH+G1f+JsOEEl4owE/YaBuoi037BLh+O0biuKLW6KY/3KYpH7o7jxcTERrmcgvlp LgwhyfXoRJIVlZpZSSb7+na+0QINEr2/+pdLJOAwbT12VYdvWTuOWFjaUz1n0fLlR3rX HuKg== X-Gm-Message-State: AOJu0YwuPVpRqWNjDNYNl3UqAo53sZelxW8YcnwD1DxIKvnUg4zZFFC9 /CQWEvr5p/FNKOlKeuvNyg/+6EHheG0miUs1D6VYfADxi0pUkO5PQVqimMs8tFOZK22+0kIdgQO WyTfrFSo= X-Gm-Gg: Acq92OG6yTgO2RJ6KvNsrwe5JVDgJBCeYzc5YaLAXnZCOiqP8vgZg65pJaVBKV2eHMQ qHTjTA7SYqveZa8a8PIZZU0l87WDL7BuWKVtMrRNfA63/oMRuG0J76g02P02zjhdDsVcP7KPYZP viWgyrL8vVwYcMWLvWboLhRzr3L25vGJJoOXXKqbfqf0pCn254vYyOxHEgV0owsSG00NTAkJFaH XWHr13rcSqu+8PlpaVxq9iyo49kaIk+B3wgP0ZMgH6isCOgyPvUrv7LOLBVF/3T+FKT/8gs8Iuh PfF3i2ubgL++DoMtAJkVyLxepkcy/I5/9qzfMy0GYaFQFwyedMW44jlNSQggZBfJAA5/nC4uiK4 DLNY6dz5jHlFDTjrv1Cd8pqx/bgcPFdCd6IyX//AvvNMt14a1JXTLWp9LqSfqfKfoiJWd8WOD8K SFEpppW17xlYbziMmZUZ+8AbOmEgRqQtNDYVPPDwwyDFCg4jg= X-Received: by 2002:a05:600c:6085:b0:490:6869:ef13 with SMTP id 5b1f17b1804b1-4906869f118mr142368395e9.14.1779807669588; Tue, 26 May 2026 08:01:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 08:01:08 -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 0/2] workqueue: Add warnings and check WQ flags usage Date: Tue, 26 May 2026 17:00:39 +0200 Message-ID: <20260526150041.365392-1-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, Currently system_wq and system_unbound_wq can still be used and no message is printed. To avoid further use of them, add a warning and route the workqueue on system_percpu_wq or system_dfl_wq. Similar scenario for WQ_PERCPU and WQ_UNBOUND. Currently there are still users that use alloc_workqueue(,0,). To avoid such situations, a couple of checks have been added: - if neither of the flag is present, set WQ_PERCPU - if both are present, remove WQ_PERCPU Along with these, a warning will be printed. ~~~~ Few things to note, and that's the main reason because it is an RFC: 1. I wanted to use a compile time error, but considering the new users still relying on the old workqueue or using alloc_workqueue() without one of the flags, it means break the code. So I decided to avoid. 2. there are no compile-time warnings: should we add something? 3. __alloc_workqueue() prints the WQ_* messages with pr_warn_ratelimited(); I used this because otherwise with the _once version we're going to see only the 1st. 4. another option would have been make the workqueue unbound by default, but of course, it's still not possible due to point 1. Thanks! Marco Crivellari (2): workqueue: Add warnings and fallback if system_{unbound}_wq is used workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present kernel/workqueue.c | 91 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) --- Changes in v2: - rebased on v7.1-rc5 - fixed typo in the text - cleared WQ_PERCPU when wq_pwer_efficient flag is set, to avoid triggering a warning - if statement to route old workqueue to newer also added in queue_rcu_work() Link to v1: https://lore.kernel.org/all/20260514092354.125149-1-marco.crivellari@suse.com/ -- 2.54.0