Re: divide by zero bug in find_busiest_group

From: Peter Zijlstra
Date: Fri Aug 27 2010 - 04:08:53 EST


On Thu, 2010-08-26 at 12:19 -0700, Venkatesh Pallipadi wrote:
> > There's also another place group->cpu_power values gets updated
> > without any synchronization, in
> > the update_cpu_power function. Though the only way this could result
> > in a bad value for cpu_power
> > is by core A reading an in-transit value for a non-atomically-updated
> > 64 bit value from core B :-). Unlikely ?
> > Very !!. Should we make that update explicity atomic ? Would be prudent.

struct sched_group {
...
unsigned int cpu_power, cpu_power_orig;
...
}

we assume that things are naturally aligned and reads/writes to word
sized entities are 'atomic' -- lots of kernel code makes this
assumption.

So the worst thing that can happen with the unsynchronized update of
cpu_power is that a reader sees the old value, no problem, we don't care
its all statistics anyway. Racing writers (could happen between regular
and nohz load-balance) we don't care about either, since the result is
either one or the other, not a mixture of both.


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