mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks
@ 2024-07-02  4:14 Lai Jiangshan
  2024-07-02  4:14 ` [PATCH 1/2] workqueue: Update cpumasks after only applying it successfully Lai Jiangshan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lai Jiangshan @ 2024-07-02  4:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lai Jiangshan, Tejun Heo, Waiman Long

From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

Simple fix and cleanup for the commit fe28f631fa94("workqueue:
Add workqueue_unbound_exclude_cpumask() to exclude CPUs from
wq_unbound_cpumask")

Lai Jiangshan (2):
  workqueue: Update cpumasks after only applying it successfully
  workqueue: Simplify goto statement

Cc: Tejun Heo <tj@kernel.org>
Cc: Waiman Long <longman@redhat.com>

 kernel/workqueue.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] workqueue: Update cpumasks after only applying it successfully
  2024-07-02  4:14 [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Lai Jiangshan
@ 2024-07-02  4:14 ` Lai Jiangshan
  2024-07-02  4:14 ` [PATCH 2/2] workqueue: Simplify goto statement Lai Jiangshan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lai Jiangshan @ 2024-07-02  4:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lai Jiangshan, Waiman Long, Tejun Heo, Lai Jiangshan

From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

Make workqueue_unbound_exclude_cpumask() and workqueue_set_unbound_cpumask()
only update wq_isolated_cpumask and wq_requested_unbound_cpumask when
workqueue_apply_unbound_cpumask() returns successfully.

Fixes: fe28f631fa94("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask")
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
 kernel/workqueue.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index dc9acf8ecd0c..a3f9ff4fe657 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -6853,9 +6853,6 @@ int workqueue_unbound_exclude_cpumask(cpumask_var_t exclude_cpumask)
 	lockdep_assert_cpus_held();
 	mutex_lock(&wq_pool_mutex);
 
-	/* Save the current isolated cpumask & export it via sysfs */
-	cpumask_copy(wq_isolated_cpumask, exclude_cpumask);
-
 	/*
 	 * If the operation fails, it will fall back to
 	 * wq_requested_unbound_cpumask which is initially set to
@@ -6867,6 +6864,10 @@ int workqueue_unbound_exclude_cpumask(cpumask_var_t exclude_cpumask)
 	if (!cpumask_equal(cpumask, wq_unbound_cpumask))
 		ret = workqueue_apply_unbound_cpumask(cpumask);
 
+	/* Save the current isolated cpumask & export it via sysfs */
+	if (!ret)
+		cpumask_copy(wq_isolated_cpumask, exclude_cpumask);
+
 	mutex_unlock(&wq_pool_mutex);
 	free_cpumask_var(cpumask);
 	return ret;
@@ -7202,7 +7203,6 @@ static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
 	cpumask_and(cpumask, cpumask, cpu_possible_mask);
 	if (!cpumask_empty(cpumask)) {
 		apply_wqattrs_lock();
-		cpumask_copy(wq_requested_unbound_cpumask, cpumask);
 		if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
 			ret = 0;
 			goto out_unlock;
@@ -7211,6 +7211,8 @@ static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
 		ret = workqueue_apply_unbound_cpumask(cpumask);
 
 out_unlock:
+		if (!ret)
+			cpumask_copy(wq_requested_unbound_cpumask, cpumask);
 		apply_wqattrs_unlock();
 	}
 
-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] workqueue: Simplify goto statement
  2024-07-02  4:14 [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Lai Jiangshan
  2024-07-02  4:14 ` [PATCH 1/2] workqueue: Update cpumasks after only applying it successfully Lai Jiangshan
@ 2024-07-02  4:14 ` Lai Jiangshan
  2024-07-02 17:17 ` [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Tejun Heo
  2024-07-02 17:24 ` Waiman Long
  3 siblings, 0 replies; 5+ messages in thread
From: Lai Jiangshan @ 2024-07-02  4:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lai Jiangshan, Waiman Long, Tejun Heo, Lai Jiangshan

From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

Use a simple if-statement to replace the cumbersome goto-statement in
workqueue_set_unbound_cpumask().

Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
 kernel/workqueue.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a3f9ff4fe657..7a33f958dcb2 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -7202,15 +7202,10 @@ 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();
-		if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
-			ret = 0;
-			goto out_unlock;
-		}
-
-		ret = workqueue_apply_unbound_cpumask(cpumask);
-
-out_unlock:
+		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();
-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks
  2024-07-02  4:14 [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Lai Jiangshan
  2024-07-02  4:14 ` [PATCH 1/2] workqueue: Update cpumasks after only applying it successfully Lai Jiangshan
  2024-07-02  4:14 ` [PATCH 2/2] workqueue: Simplify goto statement Lai Jiangshan
@ 2024-07-02 17:17 ` Tejun Heo
  2024-07-02 17:24 ` Waiman Long
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2024-07-02 17:17 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: linux-kernel, Lai Jiangshan, Waiman Long

On Tue, Jul 02, 2024 at 12:14:54PM +0800, Lai Jiangshan wrote:
> From: Lai Jiangshan <jiangshan.ljs@antgroup.com>
> 
> Simple fix and cleanup for the commit fe28f631fa94("workqueue:
> Add workqueue_unbound_exclude_cpumask() to exclude CPUs from
> wq_unbound_cpumask")
> 
> Lai Jiangshan (2):
>   workqueue: Update cpumasks after only applying it successfully
>   workqueue: Simplify goto statement

Applied 1-2 to wq/for-6.11.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks
  2024-07-02  4:14 [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Lai Jiangshan
                   ` (2 preceding siblings ...)
  2024-07-02 17:17 ` [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Tejun Heo
@ 2024-07-02 17:24 ` Waiman Long
  3 siblings, 0 replies; 5+ messages in thread
From: Waiman Long @ 2024-07-02 17:24 UTC (permalink / raw)
  To: Lai Jiangshan, linux-kernel; +Cc: Lai Jiangshan, Tejun Heo

On 7/2/24 00:14, Lai Jiangshan wrote:
> From: Lai Jiangshan <jiangshan.ljs@antgroup.com>
>
> Simple fix and cleanup for the commit fe28f631fa94("workqueue:
> Add workqueue_unbound_exclude_cpumask() to exclude CPUs from
> wq_unbound_cpumask")
>
> Lai Jiangshan (2):
>    workqueue: Update cpumasks after only applying it successfully
>    workqueue: Simplify goto statement
>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Waiman Long <longman@redhat.com>
>
>   kernel/workqueue.c | 21 +++++++++------------
>   1 file changed, 9 insertions(+), 12 deletions(-)
>
Thanks for the improvements.

For the series,

Acked-by: Waiman Long <longman@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-02 17:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-02  4:14 [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Lai Jiangshan
2024-07-02  4:14 ` [PATCH 1/2] workqueue: Update cpumasks after only applying it successfully Lai Jiangshan
2024-07-02  4:14 ` [PATCH 2/2] workqueue: Simplify goto statement Lai Jiangshan
2024-07-02 17:17 ` [PATCH 0/2] workqueue: Simple fix and cleanup for exclusive cpumasks Tejun Heo
2024-07-02 17:24 ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®