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: Wednesday, September 26, 2007 - 11:13 am

On 09/23, Paul E. McKenney wrote:

even if rcu lock/unlock happen on different CPUs, rcu_flipctr is not "shared",
we remember the index, but not the CPU, we always modify the "local" data.


Thanks a lot! Actually, this explains most of my questions. I was greatly
confused even before I started to read the code. Looking at rcu_flipctr[2]
I wrongly assumed that these 2 counters "belong" to different GPs. When
I started to understand the reality, I was confused by GP_STAGES == 4 ;)


Thanks!


yes, this is clear


Yes, yes, I see now. We really need this barriers, except I think
rcu_try_flip_idle() can use wmb. However, I have a bit offtopic question,

	// rcu_try_flip_waitzero()
	if (A == 0) {
		mb();
		B == 0;
	}

Do we really need the mb() in this case? How it is possible that STORE
goes before LOAD? "Obviously", the LOAD should be completed first, no?


Oooh... well... I need to think more about your explanation :)


Hmm. Still can't understand.

Suppose that we are doing call_rcu(), and __rcu_advance_callbacks() sees
rdp->completed == rcu_ctrlblk.completed but rcu_flip_flag = rcu_flipped
(say, another CPU does rcu_try_flip_idle() in between).

We ack the flip, call_rcu() enables irqs, the timer interrupt calls
__rcu_advance_callbacks() again and moves the callbacks.

So, it is still possible that "move callbacks" and "ack the flip" happen
out of order. But why this is bad?

This can't "speedup" the moving of our callbacks from next to done lists.
Yes, RCU state machine can switch to the next state/stage, but this looks
safe to me.

Help!

The last question, rcu_check_callbacks does

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

Could you clarify the check above? Afaics this is just optimization,
technically it is correct to rcu_try_flip() at any time, even if ->completed
are not synchronized. Most probably in that case rcu_try_flip_waitack() will
fail, but nothing bad can happen, yes?


oldmask could be obsolete now. Suppose that the admin moves that task to some
cpuset or just changes its ->cpus_allowed while it does synchronize_sched().

I think there is another problem. It would be nice to eliminate taking the global
sched_hotcpu_mutex in sched_setaffinity() (I think without CONFIG_HOTPLUG_CPU
it is not needed right now). In that case sched_setaffinity(0, cpumask_of_cpu(cpu))
can in fact return on the "wrong" CPU != cpu if another thread changes our affinity
in parallel, and this breaks synchronize_sched().


Can't we do something different? Suppose that we changed migration_thread(),
something like (roughly)

	-	__migrate_task(req->task, cpu, req->dest_cpu);
	+	if (req->task)
	+		__migrate_task(req->task, cpu, req->dest_cpu);
	+	else
	+		schedule(); // unneeded, mb() is enough?
	
		complete(&req->done);

Now,
	void synchronize_sched(void)
	{
		struct migration_req req;

		req->task = NULL;
		init_completion(&req.done);

		for_each_online_cpu(cpu) {
			struct rq *rq = cpu_rq(cpu);
			int online;

			spin_lock_irq(&rq->lock);
			online = cpu_online(cpu); // HOTPLUG_CPU
			if (online) {
				list_add(&req->list, &rq->migration_queue);
				req.done.done = 0;
			}
			spin_unlock_irq(&rq->lock);

			if (online) {
				wake_up_process(rq->migration_thread);
				wait_for_completion(&req.done);
			}
		}
	}

Alternatively, we can use schedule_on_each_cpu(), but it has other disadvantages.

Thoughts?

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)