Re: current linux-2.6.git: cpusets completely broken

From: Linus Torvalds
Date: Sat Jul 12 2008 - 15:15:56 EST




On Sat, 12 Jul 2008, Miao Xie wrote:
>
> I think Vegard Nossum's patch is not so good because it is not necessary to detach
> all the sched domains when making a cpu offline.

Well, short-term, I'd like to have a minimal fix.

Long-term, I really think that whole CPU notifier thing needs to be
*fixed*.

It's totally broken to have single callback functions with "flags"
parameters telling people what to do. I don't understand why people keep
doing it. It's *always* broken, and the fix is *always* to a structure
with multiple function pointers - separate functions for separate events.

In the case of those CPU hotplug notifiers, the "freeze" thing could
probably have been a flag, but CPU_DOWN_PREPARE/DEAD/DYING/UP/xyz should
likely just be different function callbacks. That way, when we add a
callback type, it doesn't require changing all existing callbacks that
don't want to care about the new case. And we wouldn't have these stupid
and fragile and ugly "switch()" statements with tons of cases all over.

Sadly, people have latched onto a model (that piece-of-sh*t "notifier"
infrastructure) that encourages - and almost requires - this kind of pure
crap.

But the CPU hotplug stuff _could_ just use separate notifier chains for
the different kinds of events. It wouldn't be perfect, but it would be
better than the mess we have now. Instead of doing

register_cpu_notifier(..);

and having a single thing that has to handle all cases, we could have

/* current "ONLINE/ONLINE_FROZEN" cases */
online = register_cpu_notifier(CPU_ONLINE, online_fn);
dead = register_cpu_nofitier(CPU_DEAD, dead_fn);

which would allocate the "struct notifier_block" an fill it in, and have
_separate_ queues for all those cases. That way, *if* you want to share
the code for multiple cases, you just register the same function. And if
you only cared about one case, you'd only be called for that one case!

I dunno. Maybe the conversion would be painful. And maybe the end result
isn't wonderful either. But the current setup for CPU notifiers is just a
damn disgrace.

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