Hello, Hillf!

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

> On Mon, Oct 16, 2023 at 1:30 PM Uladzislau Rezki (Sony) <[email protected]> 
> 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

Reply via email to