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

From: Paul E. McKenney
Date: Thu Oct 10 2013 - 13:45:22 EST


On Thu, Oct 10, 2013 at 06:52:29PM +0200, Ingo Molnar wrote:
>
> * Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > On Thu, 10 Oct 2013 17:26:12 +0200 Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> >
> > > On 10/10, Ingo Molnar wrote:
> > > >
> > > > * Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > > >
> > > > > But the thing is; our sense of NR_CPUS has shifted, where it used to be
> > > > > ok to do something like:
> > > > >
> > > > > for_each_cpu()
> > > > >
> > > > > With preemption disabled; it gets to be less and less sane to do
> > > > > so, simply because 'common' hardware has 256+ CPUs these days. If
> > > > > we cannot rely on preempt disable to exclude hotplug, we must use
> > > > > get_online_cpus(), but get_online_cpus() is global state and thus
> > > > > cannot be used at any sort of frequency.
> > > >
> > > > So ... why not make it _really_ cheap, i.e. the read lock costing
> > > > nothing, and tie CPU hotplug to freezing all tasks in the system?
> > > >
> > > > Actual CPU hot unplugging and repluggin is _ridiculously_ rare in a
> > > > system, I don't understand how we tolerate _any_ overhead from this
> > > > utter slowpath.
> > >
> > > Well, iirc Srivatsa (cc'ed) pointed out that some systems do
> > > cpu_down/up quite often to save the power.
> >
> > cpu hotremove already uses stop_machine, so such an approach shouldn't
> > actually worsen things (a lot) for them?
>
> Also, using CPU hotremove to save power, instead of implementing proper
> power aware scheduling, is very broken to begin with.

In many cases, agreed. Particularly on devices where there is an easy
way to send out regular updates and bug fixes, and especially if they
are connected to AC power.

But if I was in charge of creating a battery-powered multicore embedded
device that was to ship in million-unit quantities, especially in the
not-uncommon case where more than one CPU is needed only for specific
actions, I would offline the extra CPUs except when I was sure they were
needed. This would of course still rely on power-aware scheduling when
more than one CPU was in use. The power-aware scheduling conserves energy
for short-term variations (in which case offlining really is useless),
but longer term "keep this CPU -off-" is provided by offlining.

Yes, the Linux kernel code quality is quite good, but bugs still happen,
and bugs can easily cause CPUs to power up unnecessarily. This doesn't
have to happen very often to kill your battery. If the extra CPUs are
offline, a large class of those bugs are rendered harmless. If you are
going to have a very large number of difficult-to-update battery-powered
devices in the field, defending against such bugs is worthwhile.

Thanx, Paul

--
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/