All of lore.kernel.org
 help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com>
To: Hillf Danton <hdanton@sina.com>
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>,
	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: Wed, 18 Oct 2023 13:20:49 +0200	[thread overview]
Message-ID: <ZS-_kS0vr8G-k0pp@pc636> (raw)
In-Reply-To: <20231017103342.1879-1-hdanton@sina.com>

Hello, Hillf!

> Hi Ulad
> 
> Good work with a nit.
> 
Thank you :)

> 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.

Or i miss your point? If so, i appreciate if you clarify it in more
detail.

> > +
> > +	/*
> > +	 * 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));
> > +
> > +	/*
> > +	 * Obtain a tail of current active users. It is guaranteed
> > +	 * that if we are only one active user and the list is not
> > +	 * empty, the tail has already been updated.
> > +	 */
> > +	ret = atomic_inc_return(&sr.active);
> 
> Replacing atomic_inc_return() with smp_mb() cuts sr.active off.
> 
But here we would like to know that we were only one user + not
empty list gurantees that a tail is ready.

Thank you for your comments!

--
Uladzislau Rezki

  parent reply	other threads:[~2023-10-18 11:20 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 [this message]
     [not found]   ` <20231019114432.1995-1-hdanton@sina.com>
2023-10-19 15:44     ` Uladzislau Rezki

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=ZS-_kS0vr8G-k0pp@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.