[PATCHSET cgroup/for-3.12] cgroup: use cgroup_subsys_state as the primary subsystem interface handle

From: Tejun Heo
Date: Thu Aug 01 2013 - 17:50:15 EST


Currently, struct cgroup * is used as the main interface handle
between cgroup core and its subsystems, which works but is a bit
clunky because subsystems usually care much more about css's
(cgroup_subsys_state) a lot more than cgroups, which is natural as a
css is the intersection between a cgroup and a subsystem.

In addition to being a bit clunky, dealing with cgroups directly pose
a bit of trouble for the planned unified hierarchy support on two
fronts. First, most iterations become subsystem dependent as task
membership is affected by which subtree has the specific subsystem
enabled and thus require specifying which subsystem the iteration is
for, which is automatically achieved if the interfaces deal with css's
instead of cgroups.

Second, as css's may be created, attached, detached and destroyed
dynamically multiple times across the lifetime of a given cgroup as
they're enabled and disabled, which makes cgroup -> css mapping much
more difficult to synchronize. Giving out cgroup to subsystems and
then requiring them to take the extra steps to deal with their css's
coming and going dynamically is a lot more fragile than cgroup core
proper handling it internally and giving out the resulting css's to

So, this patchset converts all cgroup subsystem APIs to deal with
css's instead of cgroups. The patchset is fairly large but most of
the conversions, while being tedious, aren't complex. At the end of
series, subsystems no longer make cgroup -> css mapping themselves and
cgroup_css() - formerly cgroup_subsys_state() - is made internal to
cgroup core proper.

This is a rather large update to the interface and likely to play as a
barrier when porting commits, which is inconvenient but also provides
an opportunity to clean up the API where we can as doing so won't
significantly raise the level of inconvenience. As such, this
patchset contains some API cleanups and I'll probably follow up with
further API updates that I've been meaning to do and, if you have some
good idea to clean up cgroup internal API, this probably is a good
time to submit it.

This patchset contains the following 23 patches.


0001-0007 prepare for css-based interface. Individual subsystems are
updated so that they're easier to convert and css_parent() is added so
that upward travelsal can be done without going through cgroup.

0008 updates all subsystem methods.

0009-0012 update file operations.

0013-0015 update hierarchy iterators.

0016-0020 update task iterators.

0021 updates events.

0022 updates task_set handling.

0023 unexports cgroup_css().

This patchset is available in the following git branch.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git review-cssfy

diffstat follows.

block/blk-cgroup.c | 41 +-
block/blk-cgroup.h | 34 -
block/blk-throttle.c | 40 +-
block/cfq-iosched.c | 90 ++--
fs/bio.c | 2
include/linux/cgroup.h | 268 +++++++-------
include/linux/memcontrol.h | 2
include/linux/vmpressure.h | 6
include/net/cls_cgroup.h | 4
include/net/netprio_cgroup.h | 8
kernel/cgroup.c | 798 ++++++++++++++++++++++++-------------------
kernel/cgroup_freezer.c | 128 +++---
kernel/cpuset.c | 265 ++++++--------
kernel/events/core.c | 22 -
kernel/sched/core.c | 113 +++---
kernel/sched/cpuacct.c | 51 +-
kernel/sched/sched.h | 6
mm/hugetlb_cgroup.c | 69 +--
mm/memcontrol.c | 216 +++++------
mm/vmpressure.c | 25 -
net/core/netprio_cgroup.c | 72 +--
net/ipv4/tcp_memcontrol.c | 12
net/sched/cls_cgroup.c | 39 +-
security/device_cgroup.c | 63 +--
24 files changed, 1210 insertions(+), 1164 deletions(-)


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/