All of lore.kernel.org
 help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com>
To: Joel Fernandes <joel@joelfernandes.org>
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: Wed, 18 Oct 2023 19:36:07 +0200	[thread overview]
Message-ID: <ZTAXh1ifgAAF0GsW@pc636> (raw)
In-Reply-To: <CAEXW_YT5+ginWcAM-Bxk7tDcGxOgn-6cuTamBJOzr8ta6_jf+g@mail.gmail.com>

On Wed, Oct 18, 2023 at 10:32:22AM -0400, Joel Fernandes wrote:
> On Tue, Oct 17, 2023 at 10:06 AM Uladzislau Rezki <urezki@gmail.com> wrote:
> [...]
> > > > +
> > > > +       /* Finally. */
> > > > +       complete(&rs->completion);
> > > > +}
> > > > +
> > > > +static void rcu_sr_normal_gp_cleanup_work(struct work_struct *work)
> > > > +{
> > > > +       struct llist_node *done, *rcu, *next;
> > > > +
> > > > +       done = llist_del_all(&sr.done);
> > > > +       if (!done)
> > > > +               return;
> > > > +
> > > > +       llist_for_each_safe(rcu, next, done)
> > > > +               rcu_sr_normal_complete(rcu);
> > > > +}
> > > [...]
> > > > +static void rcu_sr_normal_add_req(struct rcu_synchronize *rs)
> > > > +{
> > > > +       atomic_inc(&sr.active);
> > > > +       if (llist_add((struct llist_node *) &rs->head, &sr.curr))
> > > > +               /* Set the tail. Only first and one user can do that. */
> > > > +               WRITE_ONCE(sr.curr_tail, (struct llist_node *) &rs->head);
> > > > +       atomic_dec(&sr.active);
> > >
> > > Here there is no memory ordering provided by the atomic ops. Is that really Ok?
> > >
> > This needs to be reworked since there is no ordering guaranteed. I think
> > there is a version of "atomic_inc_something" that guarantees it?
> 
> Yeah there is atomic_fetch_{inc,dec}{_acquire,_release}()
> 
> Or:
>   atomic_inc(&sr.active);
>   smp_mb__after_atomic();
> 
>   smp_mb__before_atomic();
>   atomic_dec(&sr.active);
> 
> ?
>
> That's probably better because we don't need ordering before the inc
> or after the dec, AFAICS.
> 
There are two variants, atomic_inc_return() and atomic_dec_return()
which are fully ordered. Any thoughts about them? One line instead of
two as in your case.

Your concern is about, that atomic_inc() can be reodered? There is a
llist_add() that has inside the try_cmpxchg() that should have barrier.

Any thoughts?

Thank you for the review and help, Joel!

--
Uladzislau Rezki

  reply	other threads:[~2023-10-18 17:37 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 [this message]
     [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

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=ZTAXh1ifgAAF0GsW@pc636 \
    --to=urezki@gmail.com \
    --cc=Neeraj.Upadhyay@amd.com \
    --cc=boqun.feng@gmail.com \
    --cc=frederic@kernel.org \
    --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 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.