Re: [PATCH] Remove GP_REPLAY state from rcu_sync

From: Oleg Nesterov
Date: Fri Oct 04 2019 - 11:41:16 EST


On 10/04, Joel Fernandes (Google) wrote:
>
> But this is not always true if you consider the following events:

I'm afraid I missed your point, but...

> ---------------------->
> GP num 111111 22222222222222222222222222222222233333333
> GP state i e p x r rx i
> CPU0 : rse rsx
> CPU1 : rse rsx
> CPU2 : rse rsx
>
> Here, we had 3 grace periods that elapsed, 1 for the rcu_sync_enter(),
> and 2 for the rcu_sync_exit(s).

But this is fine?

We only need to ensure that we have a full GP pass between the "last"
rcu_sync_exit() and GP_XXX -> GP_IDLE transition.

> However, we had 3 rcu_sync_exit()s, not 2. In other words, the
> rcu_sync_exit() got batched.
>
> So my point here is, rcu_sync_exit() does not really always cause a new
> GP to happen

See above, it should not.

> Then what is the point of the GP_REPLAY state at all if it does not
> always wait for a new GP?

Again, I don't understand... GP_REPLAY ensures that we will have a full GP
before rcu_sync_func() sets GP_IDLE, note that it does another "recursive"
call_rcu() if it sees GP_REPLAY.

> Taking a step back, why did we intend to have
> to wait for a new GP if another rcu_sync_exit() comes while one is still
> in progress?

To ensure that if another CPU sees rcu_sync_is_idle() (GP_IDLE) after you
do rcu_sync_exit(), then it must also see all memory changes you did before
rcu_sync_exit().

Oleg.