Re: [PATCH 0/6] Optimize the cpu hotplug locking -v2

From: Steven Rostedt
Date: Thu Oct 10 2013 - 15:04:52 EST


On Thu, 10 Oct 2013 11:49:15 -0700
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> Oh, and I'm sure there are several users that currently depend on
> being able to sleep over get_online_cpu's. But I'm pretty sure it's
> "several", not "hundreds", and I think we could fix them up.

I'm wondering if we can have a for_each_cpu() that only disables
preemption in the loop. That is, each iteration will enable preemption,
but the loop itself will guarantee that the current cpu to process
still exists.

rcu_read_lock();
for_each_cpu(cpu, mask) {
rcu_read_unlock();
rcu_read_lock();
if (!cpu_online(cpu))
continue;
[...]
}
rcu_read_unlock();

That way expensive loops wont stop the current CPU to process all
online CPUs.

Of course, it will miss a CPU that comes online. But it would still
need to handle the case of a CPU coming online after the final
put_online_cpus(), so I'm not sure that's a problem.

-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/