workqueue: Override implicit ordered attribute in workqueue_apply_unbound_cpumask()
PATCH 1/1 workqueue: Override implicit ordered attribute in workqueue_apply_unbound_cpumask()
Commit 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") enabled implicit ordered attribute to be added to WQ_UNBOUND workqueues with max_active of 1. This prevented the changing of attributes to these workqueues leading to fix commit 0a94efb5acbb ("workqueue: implicit ordered attribute should be overridable").
However, workqueue_apply_unbound_cpumask() was not updated at that time. So sysfs changes to wq_unbound_cpumask has no effect on WQ_UNBOUND workqueues with implicit ordered attribute. Since not all WQ_UNBOUND workqueues are visible on sysfs, we are not able to make all the necessary cpumask changes even if we iterates all the workqueue cpumasks in sysfs and changing them one by one.
Fix this problem by applying the corresponding change made to apply_workqueue_attrs_locked() in the fix commit to workqueue_apply_unbound_cpumask().
--- kernel/workqueue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/workqueue.c +6 -2
@@ -5785,9 +5785,13 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask)list_for_each_entry (wq, &workqueues, list) {if (!(wq->flags &WQ_UNBOUND ))continue ; +/* creating multiple pwqs breaks ordering guarantee */ -if (wq->flags & __WQ_ORDERED) -continue ; +if (!list_empty (&wq->pwqs)) { +if (wq->flags & __WQ_ORDERED_EXPLICIT) +continue ; + wq->flags &= ~__WQ_ORDERED; + } ctx =apply_wqattrs_prepare (wq, wq->unbound_attrs, unbound_cpumask);if (IS_ERR (ctx)) {
Signature · 1 line
2.39.3
Lai Jiangshan
reviewerQuoted 14 lines · Waiman Long
Commit
5c0338c68706("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") enabled implicit ordered attribute to be added toWQ_UNBOUNDworkqueues withmax_activeof 1. This prevented the changing of attributes to these workqueues leading to fix commit0a94efb5acbb("workqueue: implicit ordered attribute should be overridable").However,
workqueue_apply_unbound_cpumask()was not updated at that time. So sysfs changes towq_unbound_cpumaskhas no effect onWQ_UNBOUNDworkqueues with implicit ordered attribute. Since not allWQ_UNBOUNDworkqueues are visible on sysfs, we are not able to make all the necessary cpumask changes even if we iterates all the workqueue cpumasks in sysfs and changing them one by one.
Quoted 6 lines
Fix this problem by applying the corresponding change made to
apply_workqueue_attrs_locked()in the fix commit toworkqueue_apply_unbound_cpumask().Fixes 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered")Signed-off-by Waiman Long <[email protected]>
Hello Waiman Long
Thanks for the fix.
Quoted 9 lines
--- kernel/workqueue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)kernel/workqueue.c +0
-0
kernel/workqueue.c static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask) · line 5790
Quoted 8 lines
kernel/workqueue.c +2
-2@@ -5785,9 +5785,13 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask)list_for_each_entry (wq, &workqueues, list) {if (!(wq->flags &WQ_UNBOUND ))continue ; +/* creating multiple pwqs breaks ordering guarantee */ -if (wq->flags & __WQ_ORDERED) -continue ; +if (!list_empty (&wq->pwqs)) {
I don't remember why the same test is needed in 0a94efb5acbb. And I can't figure it out now.
I think it needs some comments or to be removed.
Thanks
Lai
Quoted 44 lines · Lai Jiangshan
Quoted 13 lines · Waiman Long
Commit
5c0338c68706("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") enabled implicit ordered attribute to be added toWQ_UNBOUNDworkqueues withmax_activeof 1. This prevented the changing of attributes to these workqueues leading to fix commit0a94efb5acbb("workqueue: implicit ordered attribute should be overridable").However,
workqueue_apply_unbound_cpumask()was not updated at that time. So sysfs changes towq_unbound_cpumaskhas no effect onWQ_UNBOUNDworkqueues with implicit ordered attribute. Since not allWQ_UNBOUNDworkqueues are visible on sysfs, we are not able to make all the necessary cpumask changes even if we iterates all the workqueue cpumasks in sysfs and changing them one by one.Quoted 6 lines
Fix this problem by applying the corresponding change made to
apply_workqueue_attrs_locked()in the fix commit toworkqueue_apply_unbound_cpumask().Fixes 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered")Signed-off-by Waiman Long <[email protected]>Hello Waiman Long
Thanks for the fix.
Quoted 9 lines
--- kernel/workqueue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)kernel/workqueue.c +0
-0kernel/workqueue.c static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask) · line 5790
Quoted 8 lines
kernel/workqueue.c +2
-2@@ -5785,9 +5785,13 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask)list_for_each_entry (wq, &workqueues, list) {if (!(wq->flags &WQ_UNBOUND ))continue ; +/* creating multiple pwqs breaks ordering guarantee */ -if (wq->flags & __WQ_ORDERED) -continue ; +if (!list_empty (&wq->pwqs)) {I don't remember why the same test is needed in
0a94efb5acbb. And I can't figure it out now.
Quoted 1 line
I think it needs some comments or to be removed.
Is it because there will be no active work if there is no pool workqueue? Anyway, I just make it to be the same as that in apply_workqueue_attrs_locked() as the function call sequence are similar. If we remove the list_empty() test, we will have to remove it in both.
Cheers,
Longman
Quoted 4 lines
Thanks
Lai
Quoted 13 lines · Waiman Long
Commit
5c0338c68706("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") enabled implicit ordered attribute to be added toWQ_UNBOUNDworkqueues withmax_activeof 1. This prevented the changing of attributes to these workqueues leading to fix commit0a94efb5acbb("workqueue: implicit ordered attribute should be overridable").However,
workqueue_apply_unbound_cpumask()was not updated at that time. So sysfs changes towq_unbound_cpumaskhas no effect onWQ_UNBOUNDworkqueues with implicit ordered attribute. Since not allWQ_UNBOUNDworkqueues are visible on sysfs, we are not able to make all the necessary cpumask changes even if we iterates all the workqueue cpumasks in sysfs and changing them one by one.
Quoted 6 lines
Fix this problem by applying the corresponding change made to
apply_workqueue_attrs_locked()in the fix commit toworkqueue_apply_unbound_cpumask().Fixes 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered")Signed-off-by Waiman Long <[email protected]>
Applied to wq/for-6.6-fixes.
Thanks.
Signature · 1 line
tejun