workqueue: Remove the unbound release work from the per-cpu type
PATCH 1/1 workqueue: Remove the unbound release work from the per-cpu type
Both the per-cpu and unbound workqueue will call init_pwq(...) currently, the latter will init an unbound release work for the pwq which is unnecessary for the per-cpu type workqueue.
This commit will remove this work item from the per-cpu workqueue by checking the wq->flags in init_pwq(...), the work is still reserved for the unbound workqueue.
--- kernel/workqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +2 -1
@@ -3807,7 +3807,8 @@ static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq,INIT_LIST_HEAD (&pwq->inactive_works);INIT_LIST_HEAD (&pwq->pwqs_node);INIT_LIST_HEAD (&pwq->mayday_node); -INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); +if (wq->flags &WQ_UNBOUND ) +INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); }/* sync @pwq with the current state of its associated wq and link it */
Signature · 1 line
2.37.2
Hi Tejun,
Would you pls help take a look at this? Or point to someone who is maintaining the workqueue subsystem, I can ping him/her...
Richard
Quoted 31 lines · Richard Clark
Both the per-cpu and unbound workqueue will call
init_pwq(...)currently, the latter will init an unbound release work for the pwq which is unnecessary for the per-cpu type workqueue.
This commit will remove this work item from the per-cpu workqueue by checking thewq->flagsininit_pwq(...), the work is still reserved for the unbound workqueue.Signed-off-by Richard Clark <[email protected]>Cc Tejun Heo <[email protected]>Cc Lai Jiangshan <[email protected]>--- kernel/workqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/workqueue.c +2
-2@@ -3807,7 +3807,8 @@ static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq,INIT_LIST_HEAD (&pwq->inactive_works);INIT_LIST_HEAD (&pwq->pwqs_node);INIT_LIST_HEAD (&pwq->mayday_node); -INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); +if (wq->flags &WQ_UNBOUND ) +INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); }/* sync @pwq with the current state of its associated wq and link it */ --2.37.2
Lai Jiangshan
reviewerQuoted 7 lines · richard clark
Hi Tejun,
Would you pls help take a look at this? Or point to someone who is maintaining the workqueue subsystem, I can ping him/her...
Richard
Hello, Richard
Thank you for reviewing the code of workqueue and trying to improve it.
But INIT_WORK() has no unwanted effect and it is better to initialize the field even if it is unused.
The patch would not be accepted.
Thanks.
Lai
Quoted 34 lines
Quoted 31 lines · Richard Clark
Both the per-cpu and unbound workqueue will call
init_pwq(...)currently, the latter will init an unbound release work for the pwq which is unnecessary for the per-cpu type workqueue.
This commit will remove this work item from the per-cpu workqueue by checking thewq->flagsininit_pwq(...), the work is still reserved for the unbound workqueue.Signed-off-by Richard Clark <[email protected]>Cc Tejun Heo <[email protected]>Cc Lai Jiangshan <[email protected]>--- kernel/workqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/workqueue.c +2
-2@@ -3807,7 +3807,8 @@ static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq,INIT_LIST_HEAD (&pwq->inactive_works);INIT_LIST_HEAD (&pwq->pwqs_node);INIT_LIST_HEAD (&pwq->mayday_node); -INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); +if (wq->flags &WQ_UNBOUND ) +INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); }/* sync @pwq with the current state of its associated wq and link it */ --2.37.2
Hi Lai,
Quoted 9 lines · Lai Jiangshan
Quoted 6 lines · richard clark
Hi Tejun,
Would you pls help take a look at this? Or point to someone who is maintaining the workqueue subsystem, I can ping him/her...
Quoted 9 lines
Quoted 1 line
Richard
Hello, Richard
Thank you for reviewing the code of workqueue and trying to improve it.
But
INIT_WORK()has no unwanted effect and it is better to initialize the field even if it is unused.
IMO, what you said is a perfect 'logical paradox', you think it 'even if it is unused', then the interesting conclusion is 'it is better to' use it, would you pls help to justify the underlying logic here? 'unused' but 'better', hmmm...
Quoted 2 lines
The patch would not be accepted.
That's definitely fine, forgive me for being a perfectionist to see the codes... Please note that I've no intention to offend you, trust me :)
Thanks,
Richard
Quoted 38 lines
Thanks.
LaiQuoted 34 lines
Quoted 31 lines · Richard Clark
Both the per-cpu and unbound workqueue will call
init_pwq(...)currently, the latter will init an unbound release work for the pwq which is unnecessary for the per-cpu type workqueue.
This commit will remove this work item from the per-cpu workqueue by checking thewq->flagsininit_pwq(...), the work is still reserved for the unbound workqueue.Signed-off-by Richard Clark <[email protected]>Cc Tejun Heo <[email protected]>Cc Lai Jiangshan <[email protected]>--- kernel/workqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/workqueue.c +2
-2@@ -3807,7 +3807,8 @@ static void init_pwq(struct pool_workqueue *pwq, struct workqueue_struct *wq,INIT_LIST_HEAD (&pwq->inactive_works);INIT_LIST_HEAD (&pwq->pwqs_node);INIT_LIST_HEAD (&pwq->mayday_node); -INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); +if (wq->flags &WQ_UNBOUND ) +INIT_WORK (&pwq->unbound_release_work, pwq_unbound_release_workfn); }/* sync @pwq with the current state of its associated wq and link it */ --2.37.2