From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8A183630B7 for ; Tue, 14 Jul 2026 11:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784029327; cv=none; b=Ss4Sjzz7Hd+MCjbRRok5U9PaTdcDnI9iG0x8NfcseUh87Dr18A5dRo9Ju4r8D/VTdrYkUhtqL9M+9IYuGwONvgmkyMPzdC4VYVBYz4Y9SzM3HOVB/Y4BAZSxskn856ggIPf4mWW/xFcZn8dpAGf0mATsdBbw9kM9LqFFsP2522Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784029327; c=relaxed/simple; bh=hsfx9O3+7POCKbkENHGUyAmlTLc3BmVehMU+QXGvC9E=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=DREE9ZSniMFag26mU1s+xmdWfGZ+8bvP7aVOoEZWO0EzQRlZE11VfjPOc/LBYVH9XzZKI3uRU3uBBVVvCvDpsfMDWjxcNVklsp2Us0eeqyFCXAR8ltvUsBzdmVQ4Z2CypPrwnRQMvGfP0G1VLPIpjOjbheiR6GvN8GJ2vIGqPos= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=m2I1eSe3; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="m2I1eSe3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:From:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=u8pWTs+m4MLnCJ6yT6GXkMUz0zRNhbEplIyshMShXjM=; b=m2I1eSe3/F2VuoAdW0UDWXRw2l k43wysWSSb9PYH97voz9kQnt8Yw1wQOVw9MIHxjS/jWwedSLFEdTTR2PGPP6jhZT1A2KLp48fojyI ZM8Y1uHoZBBhNLy1YYJ8aXb620omEaXtPd3IFOD6XjrkXsNBtaOnckH0Kmvdt7wySYmboy3n/j7Sw PLrL5cFzXvjYE7KMFO9xkNWdEAZVbdXQLn0ST7oj1NQtOBr86TqFXWCNtqZ8snBgcRExekV10a9oe Cj5odfE2k43vIn5I6zDa3Rd/50LqdZG75O6DspNCIvs//GftyH/ofqZhUkTk+oYpmHPCXsdt0+xt1 Ewh4KZvA==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wjbWK-002FZ4-2R; Tue, 14 Jul 2026 11:41:53 +0000 From: Breno Leitao Subject: [PATCH RFC 0/3] Refactor the workqueue allocations Date: Tue, 14 Jul 2026 04:41:46 -0700 Message-Id: <20260714-tejun1-v1-0-024d59241386@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAHsgVmoC/6tWKk4tykwtVrJSqFYqSi3LLM7Mz1OyUjDUUVBKz kjMS0/VzUxRslJQMjIwMjMwN7DULUnNKs0z1E02SkxMMzZLMzVJNFHSUVAqKEpNy6wAGxStFOT mrBRbWwsAT2ymsl0AAAA= X-Change-ID: 20260709-tejun1-c2aaf36f54a4 To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, frederic@kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=2134; i=leitao@debian.org; h=from:subject:message-id; bh=hsfx9O3+7POCKbkENHGUyAmlTLc3BmVehMU+QXGvC9E=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqViB8s4vQbuhWmfPRRSq9IozLoWAWqg3AOTFOh pk/Sz0kmf2JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCalYgfAAKCRA1o5Of/Hh3 bT9rD/9q3xm1EENuoL7XCu1S8xJqDNphgFrFuiwzwb7HPmsnm67m/O/BDziCuw2rvuYqjrGS0E9 AIxx1dKZy8Wjm1FCDMVXkg+di6+iUSHkLZb4ewl9mYunCtlN9Of8J74Ec5E3eWaZILJ/dPUeAou 6i0Mv1oK9Kg61SL2C7BYPh84McbcID9ioWBNZacQTbQ3q+2EnM+cT3dOUtve+8UzfaGtbUgMq1W 2Cbka6KGjPRq5BeqqtXQ5Y89sYmUMtfajiXSbvxbud/5iRoUnxG1Lilc0jSYEFFJHKu4AKX1vHl owAEHwcBXn9ySBxujfDTJmUbTnteaL2ipBCgyCCxLGM80HHgAmyZS3Zyf4rLuuA/zGlfcdkyEed vab1RW7jIbV7U/00cLxl8pZ9CUL51gJK8SBgqswNEmI7d30y/ojWMp9NDO7NG2zyrUhGnYNS21A XzctXptJaNUGmtbmKCUABewCwopnXep2KTlJRxRBdNQXVQuwQnJjIzeqdv/JpBafgOpkY8GZ4NV NNT+JkE1SWOocR45uuUVWqPXG2ZxQ+HmdR9trn0qLrXdOjnawJWGYQvVp84zje9N7uHdfZsLvFk rGLr16qm2T2obP1l8j5CDWJuwcVqUz1W1bpym655K/0QGsjwhbph0dkwPkKtgCL4/HchaqH4Aib JfYcbHfGTm1p9nA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao POC for Tejun's idea to unify the per-cpu and unbound workqueues, as suggested in http://lkml.kernel.org/r/ak569WYSm3ygKl1-@slm.duckdns.org This series only unifies the allocation part (alloc_pwq()). It makes alloc_pwq() a single allocator that returns a pwq backed by either a static per-cpu pool (get_percpu_pool) or an unbound pool (get_unbound_pool), reusing the existing static per-cpu pools. The install/link path is unchanged and all patches are behavior-neutral. This sets things up to unify the install side later. Is this the right direction? Questions to follow up: 1) wqattrs is an unbound concept and apply_workqueue_attrs_locked() rejects non-unbound wqs. Should we leverage wqattrs in per-cpu workqueues as well, so the unification can happen later (apply_workqueue_attrs_locked())? 2) If percpu becomes a WQ_AFFN_CPU affinity setting, how should max_active be treated? WQ_AFFN_CPU is unbound today, so it would inherit per-node accounting (wq_node_nr_active) and lose percpu's per-cpu max_active (pwq->nr_active). 3) What end state are you aiming for? Keep WQ_PERCPU as a thin flag over unified internals (single install path, per-cpu accounting special-cased) with WQ_UNBOUND staying for now -- or something more radical (the flags gone entirely, percpu purely an affinity value)? Tests: 1) I've tested this on x86 and arm64, with regular tests 2) I've hacked up a workqueue test suite, which has a bunch of tests, and this is what I am using to test these changes: https://github.com/leitao/wqtest Thanks, -breno Signed-off-by: Breno Leitao --- Breno Leitao (3): workqueue: introduce alloc_pwq() workqueue: allocate percpu pwqs through alloc_pwq() workqueue: factor out alloc_and_link_percpu_pwqs() kernel/workqueue.c | 96 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 36 deletions(-) --- base-commit: b9810cd75b9fb56a3425d391cba3f608502bd474 change-id: 20260709-tejun1-c2aaf36f54a4 Best regards, -- Breno Leitao