Re: [PATCH RFC 3/9] RCU: Preemptible RCU

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Paul E. McKenney <paulmck@...>
Cc: <linux-kernel@...>, <linux-rt-users@...>, <mingo@...>, <akpm@...>, <dipankar@...>, <josht@...>, <tytso@...>, <dvhltc@...>, <tglx@...>, <a.p.zijlstra@...>, <bunk@...>, <ego@...>, <srostedt@...>
Date: Sunday, September 23, 2007 - 1:38 pm

On 09/10, Paul E. McKenney wrote:

Impressive work! a couple of random newbie's questions...


Also superfluously declared in rcuclassic.h and in rcupreempt.h


unused?


Just curious, any reason why rcu_flipctr can't live in rcu_data ? Similarly,
rcu_try_flip_state can be a member of rcu_ctrlblk, it is even protected by
rcu_ctrlblk.fliplock

Isn't DEFINE_PER_CPU_SHARED_ALIGNED better for rcu_flip_flag and rcu_mb_flag?


Could you please tell more, why do we need this cli?

It can't "protect" rcu_ctrlblk.completed, and the only change which affects
the state machine is rcu_flipctr[idx]++, so I can't understand the "half-done"
above. (of course, we must disable preemption while changing rcu_flipctr).

Hmm... this was already discussed... from another message:

	> Critical portions of the GP protection happen in the scheduler-clock
	> interrupt, which is a hardirq.  For example, the .completed counter
	> is always incremented in hardirq context, and we cannot tolerate a
	> .completed increment in this code.  Allowing such an increment would
	> defeat the counter-acknowledge state in the state machine.

Still can't understand, please help! .completed could be incremented by
another CPU, why rcu_check_callbacks() running on _this_ CPU is so special?


Isn't it "obvious" that this barrier is not needed? rcu_flipctr could be
change only by this CPU, regardless of the actual value of idx, we can't
read the "wrong" value of rcu_flipctr[idx], no?

OTOH, I can't understand how it works. With ot without local_irq_save(),
another CPU can do rcu_try_flip_idle() and increment rcu_ctrlblk.completed
at any time, we can see the old value... rcu_try_flip_waitzero() can miss us?

OK, GP_STAGES > 1, so rcu_try_flip_waitzero() will actually check both
0 and 1 lastidx's before synchronize_rcu() succeeds... I doubt very much
my understanding is correct. Apart from this why GP_STAGES > 1 ???

Well, I think this code is just too tricky for me! Will try to read again
after sleep ;)


Why? Any code sequence which relies on that?

For example, rcu_check_callbacks does

	if (rcu_ctrlblk.completed == rdp->completed)
		rcu_try_flip();

it is possible that the timer interrupt calls rcu_check_callbacks()
exactly because rcu_pending() sees rcu_flipped, but without rmb() in
between we can see the old value of rcu_ctrlblk.completed.

This is not a problem because rcu_try_flip() needs rcu_ctrlblk.fliplock,
so rcu_try_flip() will see the new state != rcu_try_flip_idle_state, but
I can't understand any mb() in rcu_try_flip_xxx().


Do we really need this fastpath? It is not needed for the correctness,
and this case is very unlikely (in fact I think it is not possible:
rcu_check_callbacks() (triggers RCU_SOFTIRQ) is called with irqs disabled).


This looks a bit strange. Is this optimization? Why not

	spin_lock_irqsave(&rdp->lock, flags);
	rdp = RCU_DATA_ME();
	...

? RCU_DATA_ME() is cheap, but spin_lock() under local_irq_save() spins
without preemption.

Actually, why do we need rcu_data->lock ? Looks like local_irq_save()
should be enough, no? perhaps some -rt reasons ?


Any reason this func can't do rcu_check_mb() as well?

If this is possible, can't we move the code doing "s/rcu_flipped/rcu_flip_seen/"
from __rcu_advance_callbacks() to rcu_check_mb() to unify the "acks" ?


This "schedule()" is not needed, any time sched_setaffinity() returns on another
CPU we already forced preemption of the previously active task on that CPU.


Well, this is not correct... but doesn't matter because of the next patch.

But could you explain how it can deadlock (according to the changelog of
the next patch) ?

Thanks!

Oleg.

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH RFC 0/9] RCU: Preemptible RCU, Paul E. McKenney, (Mon Sep 10, 2:30 pm)
Re: [PATCH RFC 0/9] RCU: Preemptible RCU, Ingo Molnar, (Mon Sep 10, 2:44 pm)
[PATCH RFC 6/9] RCU priority boosting for preemptible RCU, Paul E. McKenney, (Mon Sep 10, 2:39 pm)
Re: [PATCH RFC 6/9] RCU priority boosting for preemptible RCU, Paul E. McKenney, (Fri Oct 5, 10:07 am)
Re: [PATCH RFC 6/9] RCU priority boosting for preemptible RCU, Gautham R Shenoy, (Fri Sep 28, 6:56 pm)
Re: [PATCH RFC 6/9] RCU priority boosting for preemptible RCU, Paul E. McKenney, (Sat Sep 29, 11:11 pm)
[PATCH RFC 5/9] RCU: CPU hotplug support for preemptible RCU, Paul E. McKenney, (Mon Sep 10, 2:36 pm)
[PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Mon Sep 10, 2:34 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Oleg Nesterov, (Sun Sep 23, 1:38 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Sun Sep 23, 8:15 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Oleg Nesterov, (Wed Sep 26, 11:13 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Thu Sep 27, 11:46 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Oleg Nesterov, (Fri Sep 28, 10:47 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 28, 2:57 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Oleg Nesterov, (Sun Sep 30, 12:31 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Sun Sep 30, 9:20 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Davide Libenzi, (Sun Sep 30, 7:02 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Sun Sep 30, 9:37 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Oleg Nesterov, (Tue Oct 2, 2:02 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Davide Libenzi, (Mon Oct 1, 2:44 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Mon Oct 1, 3:21 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Davide Libenzi, (Mon Oct 1, 6:09 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Mon Oct 1, 6:24 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 11:20 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 7:03 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 8:32 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 9:19 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 9:43 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 10:56 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Sat Sep 22, 12:10 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 10:40 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 8:26 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 9:15 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 9:53 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 11:15 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Sat Sep 22, 12:07 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Peter Zijlstra, (Fri Sep 21, 11:46 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 6:31 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 6:44 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 7:23 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 7:44 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 6:06 pm)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Steven Rostedt, (Fri Sep 21, 12:17 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Dipankar Sarma, (Fri Sep 21, 1:56 am)
Re: [PATCH RFC 3/9] RCU: Preemptible RCU, Paul E. McKenney, (Fri Sep 21, 1:50 am)
[PATCH RFC 2/9] RCU: Fix barriers, Paul E. McKenney, (Mon Sep 10, 2:33 pm)