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 96A303783BB for ; Mon, 11 May 2026 12:14:53 +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=1778501695; cv=none; b=scZ4JJyS3z6rUl9uwQh9gzPKtzINV4l5TrspaWLE9UPh7gyvNqLR5HI8nlyjFAqjkWACQCiW5l4kgZlLc4ZFKiumZUUFtH/5PfMgB12P/0hSMOPcduYv+SQM/7Epg8rNX967aS8z4v28cYCcIKAlDTBHgu/pqmgtIp3JFd/aX0o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778501695; c=relaxed/simple; bh=i7lmGRBCkYot6X68mqCb8Qt6ARKvELPOKShDZqzh68c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=DbxL+4dLhHhuVFwh5mhAa9Jf9q39bCY/WHGYrSxlra8nwZrrt4MNlx5ucj1Meaeg3KZQgABvykAfIZiDJ1HSWY+xWoSxDSIX6WL0KaB28S4vsk6RMESSqlY0puUocntl/6uNhDKbkDp6TQqjL3Oc2dlSSye861hQhMYoogR8Wv4= 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=oRMjFa0U; 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="oRMjFa0U" 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:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=UKcueVgf1AMI7ZTJXtIQOOxlfYxih4ZVQDRBfBAgPng=; b=oRMjFa0U4o/tqtIQy0SMub5mI5 oKOFUmP5wZVzHrPMHDNTlDS0tjQ3OTDCjiUPWKtFLZh4w5YaBHJEn0XiECEaDYigtzzH72x50VeUG x2ASE46YuKAZVnfku5LUblSDmQCa87DFRZOc1GpccS4DPN5MnPMlZteVvTV4FosuZIO0saVCIqlVd FCrRwjiJ8QJjj8r47e0cOMOALCYv2IzEXT+jS5E1p71F/MyAIKzIqfD8+k7I33b1MPEwIUV86xMv6 4KilsoaiYGv6cJsjFFycB7sop68tIm0IXvvwSw/EaCZTEAc3ZEhTSekAmo6huWjl4afFkWl5xpT4Y CTrQZICA==; 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 1wMPX7-001aiR-2X; Mon, 11 May 2026 12:14:50 +0000 From: Breno Leitao Date: Mon, 11 May 2026 05:14:18 -0700 Subject: [PATCH] workqueue: drop apply_wqattrs_lock()/unlock() wrappers 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: <20260511-workqueue_drop-v1-1-d34c01d736ae@debian.org> X-B4-Tracking: v=1; b=H4sIABnIAWoC/yXMQQrCMBAF0KsMf91AJrZFchURsc2oo9DUiVGh9 O6iLt/mLShiKgWRFpg8tWieEIkbwng5TmdxmhAJwYfed8zule12r1LlkCzPrh9av+HUbrkLaAi zyUnfv3C3/7vU4Srj47tgXT+U8p8GcgAAAA== X-Change-ID: 20260511-workqueue_drop-6b4031d48152 To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, Breno Leitao X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=5624; i=leitao@debian.org; h=from:subject:message-id; bh=i7lmGRBCkYot6X68mqCb8Qt6ARKvELPOKShDZqzh68c=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqAcg2Mr4xx1g2Wv/H0HAW6e1MHrxip2bcqqpzE j3hW9WZu/6JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCagHINgAKCRA1o5Of/Hh3 bcOxD/9AJDlx1oLAY3yG9GQzmxhNHN5YcZuvVR95B7qE++fdngFmeuFez/5I+IRcTgPun2ND9Fp VmW3csdnl8Tz+Ny5D+g90nKvtVvyeoam0U4K5Gb4XKzDSJP8B3J2Zy3kemhseKruyujEgtU9GEc M/io6bvqsYOnk0yE5S9/gyBWDpfQheVs7uJnoq/xVSls4xtAJIaNEf1Lgo9bxmlnNvLRKK1nvr9 1tSJF7wQrYln4cnS2kAe+mVngzdonwLFSBgR6ZnmQYhUoHWhMhw3MPb+RM/Q/kaIuXOGpTpKwre JaWZ//NvBVuzrhbmhiNQpa9lnpcyuLJelaKOy0VlOsXeOf3hSpsR2aLvyakruADse9uL/EvP9AJ Dqy98tyCK9WGyl+5QuTHA27q9gudQNlMHTaXZWY5WmMkzoAYdJ2Lfz8EDGC0pBCDgEHtZfvfqh8 B7Bf0yb+vHBUTGL/3Df2gOxHpsEC6tSzSchgbTyVWLMrlgt+1PDLldZRs5yr7hGvEmA7NMlwc3F IatTwLfdGsrYT6wkG2cNWsmeTWatpP5X+lEOVhKR9yOlwuKSYYi7ApaZk+d1PzHHySOGywgHNMs JOncJByuuXVM/x24pFLZuXMqEhTjMo2Vs5IQD3oVMOkKSb0L+9DsNuCkk4L2+3eY+QUeyJ7DQ1L wpf9/QUCO1GTO+w== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao The apply_wqattrs_lock()/unlock() helpers were introduced by commit a0111cf6710b ("workqueue: separate out and refactor the locking of applying attrs") to encapsulate the get_online_cpus() (later cpus_read_lock()) + mutex_lock(&wq_pool_mutex) acquire pair that was duplicated across the apply-attrs paths. Since commit 19af45757383 ("workqueue: Remove cpus_read_lock() from apply_wqattrs_lock()") removed the cpus_read_lock() (pwq creation and installation now operate on wq_online_cpumask, so CPU hotplug no longer needs to be excluded), the wrappers have been one-line forwarders to mutex_lock(&wq_pool_mutex)/mutex_unlock(&wq_pool_mutex). They no longer encode any non-trivial locking rule and obscure the fact that callers just take the existing wq_pool_mutex. This align with the "unnecessary" helpers that got discussed in [1] Inline the eight call sites and remove the wrappers. No functional change. Link: https://lore.kernel.org/all/afs_44-6ToJJVZTn@gmail.com/ [1] Signed-off-by: Breno Leitao --- kernel/workqueue.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 15d98f4b4179d..61a34be6797e0 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5316,16 +5316,6 @@ static struct pool_workqueue *alloc_unbound_pwq(struct workqueue_struct *wq, return pwq; } -static void apply_wqattrs_lock(void) -{ - mutex_lock(&wq_pool_mutex); -} - -static void apply_wqattrs_unlock(void) -{ - mutex_unlock(&wq_pool_mutex); -} - /** * wq_calc_pod_cpumask - calculate a wq_attrs' cpumask for a pod * @attrs: the wq_attrs of the default pwq of the target workqueue @@ -5881,7 +5871,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt, * wq_pool_mutex protects the workqueues list, allocations of PWQs, * and the global freeze state. */ - apply_wqattrs_lock(); + mutex_lock(&wq_pool_mutex); if (alloc_and_link_pwqs(wq) < 0) goto err_unlock_free_node_nr_active; @@ -5895,7 +5885,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt, if (wq_online && init_rescuer(wq) < 0) goto err_unlock_destroy; - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq)) goto err_destroy; @@ -5903,7 +5893,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt, return wq; err_unlock_free_node_nr_active: - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); /* * Failed alloc_and_link_pwqs() may leave pending pwq->release_work, * flushing the pwq_release_worker ensures that the pwq_release_workfn() @@ -5918,7 +5908,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt, kfree(wq); return NULL; err_unlock_destroy: - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); err_destroy: destroy_workqueue(wq); return NULL; @@ -7319,7 +7309,7 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr, struct workqueue_attrs *attrs; int ret = -ENOMEM; - apply_wqattrs_lock(); + mutex_lock(&wq_pool_mutex); attrs = wq_sysfs_prep_attrs(wq); if (!attrs) @@ -7332,7 +7322,7 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr, ret = -EINVAL; out_unlock: - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); free_workqueue_attrs(attrs); return ret ?: count; } @@ -7358,7 +7348,7 @@ static ssize_t wq_cpumask_store(struct device *dev, struct workqueue_attrs *attrs; int ret = -ENOMEM; - apply_wqattrs_lock(); + mutex_lock(&wq_pool_mutex); attrs = wq_sysfs_prep_attrs(wq); if (!attrs) @@ -7369,7 +7359,7 @@ static ssize_t wq_cpumask_store(struct device *dev, ret = apply_workqueue_attrs_locked(wq, attrs); out_unlock: - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); free_workqueue_attrs(attrs); return ret ?: count; } @@ -7405,13 +7395,13 @@ static ssize_t wq_affn_scope_store(struct device *dev, if (affn < 0) return affn; - apply_wqattrs_lock(); + mutex_lock(&wq_pool_mutex); attrs = wq_sysfs_prep_attrs(wq); if (attrs) { attrs->affn_scope = affn; ret = apply_workqueue_attrs_locked(wq, attrs); } - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); free_workqueue_attrs(attrs); return ret ?: count; } @@ -7436,13 +7426,13 @@ static ssize_t wq_affinity_strict_store(struct device *dev, if (sscanf(buf, "%d", &v) != 1) return -EINVAL; - apply_wqattrs_lock(); + mutex_lock(&wq_pool_mutex); attrs = wq_sysfs_prep_attrs(wq); if (attrs) { attrs->affn_strict = (bool)v; ret = apply_workqueue_attrs_locked(wq, attrs); } - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); free_workqueue_attrs(attrs); return ret ?: count; } @@ -7483,12 +7473,12 @@ static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask) cpumask_and(cpumask, cpumask, cpu_possible_mask); if (!cpumask_empty(cpumask)) { ret = 0; - apply_wqattrs_lock(); + mutex_lock(&wq_pool_mutex); if (!cpumask_equal(cpumask, wq_unbound_cpumask)) ret = workqueue_apply_unbound_cpumask(cpumask); if (!ret) cpumask_copy(wq_requested_unbound_cpumask, cpumask); - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); } return ret; --- base-commit: 84db6d7197f3e2922e26938f1c2adb3b0fe225fc change-id: 20260511-workqueue_drop-6b4031d48152 Best regards, -- Breno Leitao