All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hotfix: make sysfs of unbound kworker cpumask more clever
@ 2021-10-14  3:06 menglong8.dong
  2021-10-14 21:23 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: menglong8.dong @ 2021-10-14  3:06 UTC (permalink / raw)
  To: tj; +Cc: jiangshanlai, linux-kernel, Mengen Sun

From: Mengen Sun <mengensun@tencent.com>

some unfriendly component eg, dpdk, write the same mask to unbound
kworker cpumask again and agin. every time it write to this interface
some work is queue to cpu, by rr evenly the mask is same with the
original mask.

so, fix it, if the writing cpumask is equal with the old cpumask
just return success and do nothing.

Signed-off-by: Mengen Sun <mengensun@tencent.com>
---
 kernel/workqueue.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1b3eb1e9531f..8216fc45c77b 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5394,6 +5394,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
 	cpumask_and(cpumask, cpumask, cpu_possible_mask);
 	if (!cpumask_empty(cpumask)) {
 		apply_wqattrs_lock();
+		if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
+			apply_wqattrs_unlock();
+			free_cpumask_var(saved_cpumask);
+			return 0;
+		}
 
 		/* save the old wq_unbound_cpumask. */
 		cpumask_copy(saved_cpumask, wq_unbound_cpumask);
-- 
2.27.0


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

* Re: [PATCH] hotfix: make sysfs of unbound kworker cpumask more clever
  2021-10-14  3:06 [PATCH] hotfix: make sysfs of unbound kworker cpumask more clever menglong8.dong
@ 2021-10-14 21:23 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2021-10-14 21:23 UTC (permalink / raw)
  To: menglong8.dong; +Cc: jiangshanlai, linux-kernel, Mengen Sun

Hello,

On Thu, Oct 14, 2021 at 11:06:41AM +0800, menglong8.dong@gmail.com wrote:
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 1b3eb1e9531f..8216fc45c77b 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -5394,6 +5394,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
>  	cpumask_and(cpumask, cpumask, cpu_possible_mask);
>  	if (!cpumask_empty(cpumask)) {
>  		apply_wqattrs_lock();
> +		if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
> +			apply_wqattrs_unlock();
> +			free_cpumask_var(saved_cpumask);

A few nitpicks:

* Please replace "hotfix:" with "workqueue:".

* Can you reorganize the code so that it doesn't have to alloc and free the
  saved_mask?

Thanks.

-- 
tejun

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

end of thread, other threads:[~2021-10-14 21:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14  3:06 [PATCH] hotfix: make sysfs of unbound kworker cpumask more clever menglong8.dong
2021-10-14 21:23 ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.