From: Tejun Heo <tj@kernel.org>
To: Juri Lelli <juri.lelli@redhat.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
Aaron Tomlin <atomlin@atomlin.com>,
Valentin Schneider <vschneid@redhat.com>,
Waiman Long <longman@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/4] kernel/workqueue: Distinguish between general unbound and WQ_SYSFS cpumask changes
Date: Tue, 16 Jan 2024 08:57:24 -1000 [thread overview]
Message-ID: <ZabRlEklmuqwFPj-@slm.duckdns.org> (raw)
In-Reply-To: <20240116161929.232885-4-juri.lelli@redhat.com>
Hello, Juri.
On Tue, Jan 16, 2024 at 05:19:28PM +0100, Juri Lelli wrote:
> Both general unbound cpumask and per-wq (WQ_SYSFS) cpumask changes end
> up calling apply_wqattrs_prepare for preparing for the change, but this
> doesn't work well for general unbound cpumask changes as current
> implementation won't be looking at the new unbound_cpumask.
>
> Fix the prepare phase for general unbound cpumask changes by checking
> which type of attributes (general vs. WQ_SYSFS) are actually changing.
>
> Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
> ---
> kernel/workqueue.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 3a1d5a67bd66a..2ef6573909070 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -4359,7 +4359,17 @@ apply_wqattrs_prepare(struct workqueue_struct *wq,
> * it even if we don't use it immediately.
> */
> copy_workqueue_attrs(new_attrs, attrs);
> - wqattrs_actualize_cpumask(new_attrs, unbound_cpumask);
> +
> + /*
> + * Is the user changing the general unbound_cpumask or is this a
> + * WQ_SYSFS cpumask change?
> + */
> + if (attrs == wq->unbound_attrs)
> + cpumask_copy(new_attrs->cpumask, unbound_cpumask);
> + else
> + wqattrs_actualize_cpumask(new_attrs, unbound_cpumask);
> +
> + cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask);
This looks rather hacky. Can you elaborate how the current code misbehaves
with an example? For the unbound_cpumask update path, the intention is
supplying the current ->attrs (wq user's request) and the new
unbound_cpumask expecting wqattrs_actualize_cpumask() to do the right thing.
Is the problem that you want to have access to the effective cpumask for the
entire workqueue? If so, we don't want to do that with ctx->attrs as that's
supposed to carry the user's requested configuration rather than the
currently effective. We can just add a new field.
> cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask);
> ctx->dfl_pwq = alloc_unbound_pwq(wq, new_attrs);
> if (!ctx->dfl_pwq)
> @@ -4377,12 +4387,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq,
> }
> }
>
> - /* save the user configured attrs and sanitize it. */
> - copy_workqueue_attrs(new_attrs, attrs);
> - cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask);
> - cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask);
> ctx->attrs = new_attrs;
This part exists to store the user requested configuration rather than the
applied effective configuration, so that e.g. later if the unbound_cpumask
changes, we can apply the effective mask according to the user's latest
requested configuration. I'm not sure why this is being dropped.
Thanks.
--
tejun
next prev parent reply other threads:[~2024-01-16 18:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 16:19 [RFC PATCH 0/4] Fix handling of rescuers affinity Juri Lelli
2024-01-16 16:19 ` [RFC PATCH 1/4] tools/workqueue: Add rescuers printing to wq_dump.py Juri Lelli
2024-01-16 16:19 ` [RFC PATCH 2/4] kernel/workqueue: Bind rescuer to unbound cpumask for WQ_UNBOUND Juri Lelli
2024-01-16 18:47 ` Tejun Heo
2024-01-17 6:30 ` Juri Lelli
2024-01-16 16:19 ` [RFC PATCH 3/4] kernel/workqueue: Distinguish between general unbound and WQ_SYSFS cpumask changes Juri Lelli
2024-01-16 18:57 ` Tejun Heo [this message]
2024-01-17 13:06 ` Juri Lelli
2024-01-17 17:12 ` Tejun Heo
2024-01-17 19:32 ` Waiman Long
2024-01-17 19:42 ` Tejun Heo
2024-01-18 12:52 ` Juri Lelli
2024-01-16 16:19 ` [RFC PATCH 4/4] kernel/workqueue: Let rescuers follow unbound wq " Juri Lelli
2024-01-17 3:56 ` Lai Jiangshan
2024-01-17 6:30 ` Juri Lelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZabRlEklmuqwFPj-@slm.duckdns.org \
--to=tj@kernel.org \
--cc=atomlin@atomlin.com \
--cc=jiangshanlai@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®