From: Uladzislau Rezki <urezki@gmail.com>
To: Hillf Danton <hdanton@sina.com>
Cc: Uladzislau Rezki <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>,
LKML <linux-kernel@vger.kernel.org>,
Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>,
Frederic Weisbecker <frederic@kernel.org>
Subject: Re: [PATCH v3 1/1] rcu: Reduce synchronize_rcu() waiting time
Date: Thu, 19 Oct 2023 17:44:23 +0200 [thread overview]
Message-ID: <ZTFO17eNKvDNokpe@pc636> (raw)
In-Reply-To: <20231019114432.1995-1-hdanton@sina.com>
On Thu, Oct 19, 2023 at 07:44:32PM +0800, Hillf Danton wrote:
> On Wed, 18 Oct 2023 13:20:49 +0200 Uladzislau Rezki (Sony) <urezki@gmail.com> wrote:
> > > On Mon, Oct 16, 2023 at 1:30 PM Uladzislau Rezki (Sony) <urezki@gmail.com> wrote:
> > > > +static void rcu_sr_normal_gp_init(void)
> > > > +{
> > > > + struct llist_node *llnode, *rcu;
> > > > + int ret;
> > > > +
> > > > + if (llist_empty(&sr.curr))
> > > > + return;
> > >
> > > This empty check erases the curr_tail race below instead of
> > > atomic_inc_return(&sr.active), because llist_add() will never return true
> > > after this check.
> > >
> > I use "active" counter to guarantee that a tail was updated in the
> > rcu_sr_normal_add_req(), i.e. the list might be not empty whereas the
> > tail updating might be in progress. llist_add() success and the task gets
> > preemted as an example.
>
> You are right - the preempt is what I missed.
>
> Then another question rising - the adding order of sync requests is changed
> at wakeup time, as shown by the two functions below with sr.curr_tail and
> sr.active cut off.
>
> static void rcu_sr_normal_gp_init(void)
> {
> struct llist_node *llnode, *rcu;
>
> llnode = llist_del_all(&sr.curr);
> rcu = llist_reverse_order(llnode);
> if (!rcu)
> return;
> /*
> * A waiting list of GP should be empty on this step,
> * since a GP-kthread, rcu_gp_init() -> gp_cleanup(),
> * rolls it over. If not, it is a BUG, warn a user.
> */
> WARN_ON_ONCE(!llist_empty(&sr.wait));
>
> WRITE_ONCE(sr.wait_tail, llnode);
>
> llist_add_batch(rcu, llnode, &sr.wait);
> }
>
> static void rcu_sr_normal_add_req(struct rcu_synchronize *rs)
> {
> llist_add((struct llist_node *) &rs->head, &sr.curr);
> }
>
This is what i was thinking of in the beginning but i had decided
to make it more complex and maintain the current tail. We will get
a slight penalty in performance on a synthetic test but i have compared
it and this is negligible in fact.
Another good thing with it is we process users in a reverse order,
i.e. the most waiting users to less ones, this is from a waiting time
point of view.
I like it better and it is more simple. Anyway we can improve it
further.
Thank you for the proposal!
--
Uladzislau Rezki
prev parent reply other threads:[~2023-10-19 15:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 17:30 [PATCH v3 1/1] rcu: Reduce synchronize_rcu() waiting time Uladzislau Rezki (Sony)
2023-10-17 1:28 ` Joel Fernandes
2023-10-17 14:06 ` Uladzislau Rezki
2023-10-18 14:32 ` Joel Fernandes
2023-10-18 17:36 ` Uladzislau Rezki
[not found] ` <20231017103342.1879-1-hdanton@sina.com>
2023-10-18 11:20 ` Uladzislau Rezki
[not found] ` <20231019114432.1995-1-hdanton@sina.com>
2023-10-19 15:44 ` Uladzislau Rezki [this message]
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=ZTFO17eNKvDNokpe@pc636 \
--to=urezki@gmail.com \
--cc=Neeraj.Upadhyay@amd.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=hdanton@sina.com \
--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 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.