Re: [PATCH v8 3/4] cgroups: allow a cgroup subsystem to reject a fork

From: Aleksa Sarai
Date: Tue Apr 07 2015 - 09:47:07 EST

Hi Tejun,

>> I tried doing this and the kernel would refuse to boot. I believe it has
>> something to do with the ordering of early_init subsystems, but I'm not
> Hmmm... yeah, failure in early_init can be tricky to debug.

Okay, I took another look and it isn't that there are hard ordering
dependencies, it's because of how I wrote the tagging macro for cgroup_subsys.h
that caused a NULL deref during the early_init. Whoops.

>> entirely sure (this optimisation can be dealt with later [it's non-critical],
>> so IMO this should be done in a separate patchset [if at all]). Also, your
>> later comments would fix the subsys bitmask problem (we can just pass the
>> default %NULL), we don't even need to test the index.
> [...] I don't
> think it's a good idea to send the patches as-are because we can't
> debug and fix them properly, right? [...]

In what way are they hard to debug?

> [...] If there are hard ordering
> dependencies, the range of subsystems which require fork/exit doesn't
> have to be at the beginning.

I just spent a few hours trying to write it and it's just too dodgy to live.
Either you have a solution that won't work with nested tags, and is generally
just kind of bad or you have a solution that requires you to keep two separate
enumerations in sync. And of course you need to offset the index you're looking
stuff up in ss_state so that also looks bad.

But that's all besides the point because, *even if* it I had a clean solution,
it still wouldn't solve the fact that we are
> [...] adding quite a few loops in relatively hot paths.
You kind of _need_ to loop over all the subsystems in either case, the only
difference between having an array of CGROUP_SUBSYS_COUNT pointers or
CGROUP_PREFORK_COUNT is the few bytes of memory you've "saved" (at the expense
of making the callback code essentially unreadable).

Aleksa Sarai (cyphar)
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at