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 0411338B7BD for ; Wed, 12 Aug 2026 16:06:18 +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=1786550780; cv=none; b=Kb7NpktgZP1mPTsXPsQ+LQiZQBa5hCiCgVIKFGU2Mrg7r/LpT0pw1yJRdI8ierURDk7NecNcAGVpvSZOZCAjm11r/TnY8BEyGXAJio+bkGXDCQnujoLQUM2Z+MZZ8VisiBG6i3yV9H2Y0pSgXY287LI8e5Cay6R7Wh7YRd5TpLw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786550780; c=relaxed/simple; bh=/nxG08IJHJnK3T9ujbCs2S4Twnv+7zn3QAKMNGm9VlQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ObbvB097kbw256dlVWZPJYlaQdsb6R1Vyc9RRYcMY0GR6TtKGJIsacSqKaFhi9Rmpa6m7Lu0qHjINmFnDFs+4yA+IncItz4Hee30Q3uRj0cIdF78gplBQFSX7vUsFwb11k57SKh8eBg4MQtrOO+x6o/56y054P2V+N1smcrL0DQ= 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=FjkITe26; 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="FjkITe26" 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:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=mes2dCXEp9rCBbWGSRp6NQvOEUpVwdisirC8ceYqxHk=; b=FjkITe26mTJ9RjRM0uPhzm/Dvc xdh5j30p9LlvQDgHVwVYxyVx/3rUORt2N6GfOm4OtDmGXltzck0QeQpggUVJHZhLwikWJlVf9eUUX qVPh0oKlsnPvP9CajnmcR/02oNDbIFl6mXtatXtuRdAClOk28GC8Cj2GPfSQ7Luo9p+O7hMucSJFX ZTb8nZcWq1h6NdTXqW2RSbbsnewR/jj46Xfdp8Cy3z4ZysZL8IlsuJWNJO87syR7kym68h1DICOno VqhQwbPeGnlv61E4vgbZE21qrFLG/HkcGrvz1FsIKVQC3btAzSj+HoqTkQDomeOu4ukoUUaBxS+6P OrKnJ1RA==; 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 1wuBT3-004SGU-0e; Wed, 12 Aug 2026 16:06:13 +0000 From: Breno Leitao Date: Wed, 12 Aug 2026 09:03:19 -0700 Subject: [PATCH 2/3] workqueue: use RCU accessors when populating wq->cpu_pwq 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 Message-Id: <20260812-wq_fix-v1-2-f7effcfa8d37@debian.org> References: <20260812-wq_fix-v1-0-f7effcfa8d37@debian.org> In-Reply-To: <20260812-wq_fix-v1-0-f7effcfa8d37@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com, kernel test robot X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=2665; i=leitao@debian.org; h=from:subject:message-id; bh=/nxG08IJHJnK3T9ujbCs2S4Twnv+7zn3QAKMNGm9VlQ=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqfJnqyhhaQbrzcfXxU/mRC5qRqYNff0jKHkZrO b413AbJrZqJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanyZ6gAKCRA1o5Of/Hh3 bSfJD/95SnFy8AkO6r0m9bOJO6OjUAEznTp7s5UfKCQFGEqQv9gIXwtmPHNMZQRnRZcnFPOi2Kf +lzWV8EX7WiyOD1sgFUtw1rT6xE5q/s3NGckKK7AqOxVuS0DEykhsEklrZ5dF5wiYOAbjRP7jVC TJtsV2PUcOxyQg/GNZsVOiZ+j1jwY/887SmERmknfhClVjHz591M0MrjfvwfeTR+7vcEgUWXofi Gr2dtqccWmJxq3jXYlpm15WvGx43GHoxXi/CPl9/eW/cv8gM4AzP9AH3txRgA0uUtJ0NasfG/8N V8iB8/PW2vsg8jbKEYs3NaS6d6cV3CV2XyGnozayHU4hRmQ5rM94ihLM7cEY7CHPkmGUDIAmSUR seZloG7W3BCMDKalUbTgyxaQg7L2TeRjIT7Qwr80iToVSlTlOL4n4oiXzx92UVwyqCiNF00wem8 ng7VGCnKvoNFICr0pSo2GQKcUTxn2sIeNhToR7cbXEJkff1xzA/hEzheKvPQxkSx33lmHszD8Ns 7U/f1AfTn2MTHbHtQEdgV5TlQlr3+t3xmQURMQqprtMVwDV8HZBTCud/qj9ymPIJkmhDxGVIhVx XgbNivX2hO4iRBV8lnA/STU+j147OThd1KDzC0Xw3ym2d4FctJ1Skskq7smRyA6f295pvPCP1KV 5aL2ldJz0k1aw+A== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao wq->cpu_pwq holds RCU-protected pwq pointers, but the percpu allocation path fills it in with plain loads and stores, which sparse flags: kernel/workqueue.c:5682:57: sparse: incorrect type in initializer (different address spaces) @@ expected struct pool_workqueue **pwq_p @@ got struct pool_workqueue [noderef] __rcu ** @@ Allocate the array as __rcu pointers and publish each pwq with rcu_assign_pointer() once it is initialized and linked, the order install_unbound_pwq() uses. The warnings are not new: commit 79f23600bc7b ("workqueue: factor out get_percpu_pool()") only turned the flagged assignment into an initializer. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202608120931.tvTzq1gD-lkp@intel.com/ Signed-off-by: Breno Leitao --- kernel/workqueue.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 1748ef5541a26..83aced28523b5 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5681,21 +5681,23 @@ static void unbound_wq_update_pwq(struct workqueue_struct *wq, int cpu) static int alloc_and_link_percpu_pwqs(struct workqueue_struct *wq) { + struct pool_workqueue *pwq; int cpu; for_each_possible_cpu(cpu) { - struct pool_workqueue **pwq_p = per_cpu_ptr(wq->cpu_pwq, cpu); struct worker_pool *pool = get_percpu_pool(wq, cpu); - *pwq_p = kmem_cache_alloc_node(pwq_cache, GFP_KERNEL, pool->node); - if (!*pwq_p) + pwq = kmem_cache_alloc_node(pwq_cache, GFP_KERNEL, pool->node); + if (!pwq) return -ENOMEM; - init_pwq(*pwq_p, wq, pool); + init_pwq(pwq, wq, pool); mutex_lock(&wq->mutex); - link_pwq(*pwq_p); + link_pwq(pwq); mutex_unlock(&wq->mutex); + + rcu_assign_pointer(*per_cpu_ptr(wq->cpu_pwq, cpu), pwq); } return 0; @@ -5708,7 +5710,7 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) lockdep_assert_held(&wq_pool_mutex); - wq->cpu_pwq = alloc_percpu(struct pool_workqueue *); + wq->cpu_pwq = alloc_percpu(struct pool_workqueue __rcu *); if (!wq->cpu_pwq) goto enomem; @@ -5734,8 +5736,11 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) enomem: if (wq->cpu_pwq) { for_each_possible_cpu(cpu) { - struct pool_workqueue *pwq = *per_cpu_ptr(wq->cpu_pwq, cpu); + struct pool_workqueue __rcu **slot; + struct pool_workqueue *pwq; + slot = per_cpu_ptr(wq->cpu_pwq, cpu); + pwq = rcu_access_pointer(*slot); if (pwq) { /* * Unlink pwq from wq->pwqs since link_pwq() -- 2.53.0-Meta