From: Tejun Heo <tj@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
linux-kernel@vger.kernel.org, Juri Lelli <juri.lelli@redhat.com>,
Cestmir Kalina <ckalina@redhat.com>,
Alex Gladkov <agladkov@redhat.com>, Phil Auld <pauld@redhat.com>,
Costa Shulyupin <cshulyup@redhat.com>
Subject: Re: [PATCH wq/for-6.9 v4 2/4] workqueue: Enable unbound cpumask update on ordered workqueues
Date: Wed, 7 Feb 2024 07:25:12 -1000 [thread overview]
Message-ID: <ZcO8-JDXkoDeMFVT@slm.duckdns.org> (raw)
In-Reply-To: <20240207011911.975608-3-longman@redhat.com>
Hello, Waiman.
On Tue, Feb 06, 2024 at 08:19:09PM -0500, Waiman Long wrote:
...
> + * The unplugging is done either in apply_wqattrs_cleanup() [fast path] when
> + * the workqueue was idle or in pwq_release_workfn() [slow path] when the
> + * workqueue was busy.
I'm not sure the distinction between fast and slow paths is all that useful
here. Both are really cold paths.
> +static void unplug_oldest_pwq(struct workqueue_struct *wq,
> + struct pool_workqueue *exlude_pwq)
> +{
> + struct pool_workqueue *pwq;
> + unsigned long flags;
> + bool found = false;
> +
> + for_each_pwq(pwq, wq) {
> + if (pwq == exlude_pwq)
> + continue;
> + if (!pwq->plugged)
> + return; /* No unplug needed */
> + found = true;
> + break;
> + }
> + if (WARN_ON_ONCE(!found))
> + return;
> +
> + raw_spin_lock_irqsave(&pwq->pool->lock, flags);
> + if (!pwq->plugged)
> + goto out_unlock;
> + pwq->plugged = false;
> + if (pwq_activate_first_inactive(pwq, true))
> + kick_pool(pwq->pool);
> +out_unlock:
> + raw_spin_unlock_irqrestore(&pwq->pool->lock, flags);
> +}
I don't quite understand why this needs iteration and @exclude_pwq.
Shouldn't something like the following be enough?
static void unplug_oldest_pwq(struct workqueue_struct *wq)
{
struct pool_workqueue *pwq;
raw_spin_lock_irq(&pwq->pool->lock);
pwq = list_first_entry_or_null(&pwq->pwqs, ...);
if (pwq)
pwq->plugged = false;
raw_spin_unlock_irq(&pwq->pool->lock);
}
> @@ -4740,6 +4796,13 @@ static void pwq_release_workfn(struct kthread_work *work)
> mutex_lock(&wq->mutex);
> list_del_rcu(&pwq->pwqs_node);
> is_last = list_empty(&wq->pwqs);
> +
> + /*
> + * For ordered workqueue with a plugged dfl_pwq, restart it now.
> + */
> + if (!is_last && (wq->flags & __WQ_ORDERED))
> + unplug_oldest_pwq(wq, NULL);
This makes sense.
> @@ -4906,8 +4969,26 @@ static void apply_wqattrs_cleanup(struct apply_wqattrs_ctx *ctx)
...
> + /*
> + * It is possible that ctx->dfl_pwq (previous wq->dfl_pwq)
> + * may not be the oldest one with the plugged flag still set.
> + * unplug_oldest_pwq() will still do the right thing to allow
> + * only one unplugged pwq in the workqueue.
> + */
> + if ((ctx->wq->flags & __WQ_ORDERED) &&
> + ctx->dfl_pwq && !ctx->dfl_pwq->refcnt)
> + unplug_oldest_pwq(ctx->wq, ctx->dfl_pwq);
> + rcu_read_unlock();
But why do we need this? Isn't all that needed to call unplug_oldest during
workqueue initialization and chaining unplugging from pwq release from there
on?
Thanks.
--
tejun
next prev parent reply other threads:[~2024-02-07 17:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 1:19 [PATCH wq/for-6.9 v4 0/4] workqueue: Enable unbound cpumask update on ordered workqueues Waiman Long
2024-02-07 1:19 ` [PATCH wq/for-6.9 v4 1/4] workqueue: Link pwq's into wq->pwqs from oldest to newest Waiman Long
2024-02-07 1:19 ` [PATCH wq/for-6.9 v4 2/4] workqueue: Enable unbound cpumask update on ordered workqueues Waiman Long
2024-02-07 17:25 ` Tejun Heo [this message]
2024-02-07 20:59 ` Waiman Long
2024-02-07 21:18 ` Tejun Heo
2024-02-07 1:19 ` [PATCH wq/for-6.9 v4 3/4] kernel/workqueue: Let rescuers follow unbound wq cpumask changes Waiman Long
2024-02-07 1:19 ` [PATCH wq/for-6.9 v4 4/4] workqueue: Bind unbound workqueue rescuer to wq_unbound_cpumask Waiman Long
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=ZcO8-JDXkoDeMFVT@slm.duckdns.org \
--to=tj@kernel.org \
--cc=agladkov@redhat.com \
--cc=ckalina@redhat.com \
--cc=cshulyup@redhat.com \
--cc=jiangshanlai@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=pauld@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