From: Uladzislau Rezki <urezki@gmail.com>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
RCU <rcu@vger.kernel.org>,
Neeraj upadhyay <Neeraj.Upadhyay@amd.com>,
Boqun Feng <boqun.feng@gmail.com>,
Hillf Danton <hdanton@sina.com>,
Joel Fernandes <joel@joelfernandes.org>,
LKML <linux-kernel@vger.kernel.org>,
Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>
Subject: Re: [PATCH 1/3] rcu: Reduce synchronize_rcu() waiting time
Date: Thu, 26 Oct 2023 15:00:25 +0200 [thread overview]
Message-ID: <ZTpi6diP4h84PtWE@pc636> (raw)
In-Reply-To: <ZTkwl0bzTTCy8g5N@localhost.localdomain>
On Wed, Oct 25, 2023 at 05:13:27PM +0200, Frederic Weisbecker wrote:
> Le Wed, Oct 25, 2023 at 04:09:13PM +0200, Uladzislau Rezki (Sony) a écrit :
> > +/*
> > + * Helper function for rcu_gp_cleanup().
> > + */
> > +static void rcu_sr_normal_gp_cleanup(void)
> > +{
> > + struct llist_node *head, *tail, *pos;
> > + int i = 0;
> > +
> > + tail = READ_ONCE(sr.wait_tail);
> > + head = llist_del_all(&sr.wait);
>
> This could be llist_empty() first to do a quick
> cheap check. And then __llist_del_all() here because
> it appears nothing else than gp kthread can touch sr.wait.
>
No problem i can fix it. Initially i had a check first!
> > +
> > + llist_for_each_safe(pos, head, head) {
>
> Two times head intended here? There should be some
> temporary storage in the middle.
>
Yes. It is intentially done. The head is updated, i.e. shifted to a next,
because we directly process users from a GP. The number is limited to 5
all the rest is deferred.
> > + rcu_sr_normal_complete(pos);
> > +
> > + if (++i == MAX_SR_WAKE_FROM_GP) {
> > + /* If last, process it also. */
> > + if (head && !head->next)
> > + continue;
> > + break;
> > + }
> > + }
> > +
> > + if (head) {
> > + /* Can be not empty. */
> > + llist_add_batch(head, tail, &sr.done);
> > + queue_work(system_highpri_wq, &sr_normal_gp_cleanup);
>
> So you can have:
>
> * Queue to sr.curr is atomic fully ordered
> * Check and move from sr.curr to sr.wait is atomic fully ordered
> * Check from sr.wait can have a quick unatomic unordered
> llist_empty() check. Then extract unatomic unordered as well.
> * If too many, move atomic/ordered to sr.done.
>
> Am I missing something?
>
If too many move to done and kick the helper. The sr.wait can not
be touched until the rcu_sr_normal_gp_cleanup() is completed, i.e.:
<snip>
GP-kthread(same and one task context):
rcu_sr_normal_gp_cleanup();
wait for a grace period;
rcu_sr_normal_gp_cleanup();
<snip>
Am i missing your point?
--
Uladzislau Rezki
next prev parent reply other threads:[~2023-10-26 13:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 14:09 [PATCH 0/3] reduce latency of synchronize_rcu() Uladzislau Rezki (Sony)
2023-10-25 14:09 ` [PATCH 1/3] rcu: Reduce synchronize_rcu() waiting time Uladzislau Rezki (Sony)
2023-10-25 15:13 ` Frederic Weisbecker
2023-10-26 13:00 ` Uladzislau Rezki [this message]
2023-10-26 14:22 ` Frederic Weisbecker
2023-10-26 15:14 ` Uladzislau Rezki
2023-10-25 17:17 ` Boqun Feng
2023-10-26 13:09 ` Uladzislau Rezki
2023-10-29 18:21 ` Boqun Feng
2023-11-01 10:33 ` Uladzislau Rezki
2023-11-01 15:35 ` Uladzislau Rezki
2023-11-02 1:04 ` Boqun Feng
2023-11-02 12:35 ` Uladzislau Rezki
2023-10-25 14:09 ` [PATCH 2/3] rcu: Add a trace event for synchronize_rcu_normal() Uladzislau Rezki (Sony)
2023-10-25 14:09 ` [PATCH 3/3] doc: Add rcutree.rcu_normal_wake_from_gp to kernel-parameters.txt Uladzislau Rezki (Sony)
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=ZTpi6diP4h84PtWE@pc636 \
--to=urezki@gmail.com \
--cc=Neeraj.Upadhyay@amd.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=hdanton@sina.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksiy.avramchenko@sony.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
/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