Re: [PATCH v2 08/23] cgroup: pass around cgroup_subsys_state instead of cgroup in subsystem methods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/02/2013 10:24 PM, Tejun Heo wrote:
cgroup is currently in the process of transitioning to using struct
cgroup_subsys_state * as the primary handle instead of struct cgroup *
in subsystem implementations for the following reasons.

* With unified hierarchy, subsystems will be dynamically bound and
   unbound from cgroups and thus css's (cgroup_subsys_state) may be
   created and destroyed dynamically over the lifetime of a cgroup,
   which is different from the current state where all css's are
   allocated and destroyed together with the associated cgroup.  This
   in turn means that cgroup_css() should be synchronized and may
   return NULL, making it more cumbersome to use.

* Differing levels of per-subsystem granularity in the unified
   hierarchy means that the task and descendant iterators should behave
   differently depending on the specific subsystem the iteration is
   being performed for.

* In majority of the cases, subsystems only care about its part in the
   cgroup hierarchy - ie. the hierarchy of css's.  Subsystem methods
   often obtain the matching css pointer from the cgroup and don't
   bother with the cgroup pointer itself.  Passing around css fits
   much better.

This patch converts all cgroup_subsys methods to take @css instead of
@cgroup.  The conversions are mostly straight-forward.  A few
noteworthy changes are

* ->css_alloc() now takes css of the parent cgroup rather than the
   pointer to the new cgroup as the css for the new cgroup doesn't
   exist yet.  Knowing the parent css is enough for all the existing
   subsystems.

* In kernel/cgroup.c::offline_css(), unnecessary open coded css
   dereference is replaced with local variable access.

This patch shouldn't cause any behavior differences.

v2: Unnecessary explicit cgrp->subsys[] deref in css_online() replaced
     with local variable @css as suggested by Li Zefan.

     Rebased on top of new for-3.12 which includes for-3.11-fixes so
     that ->css_free() invocation added by da0a12caff ("cgroup: fix a
     leak when percpu_ref_init() fails") is converted too.  Suggested
     by Li Zefan.

Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
Acked-by: Li Zefan <lizefan@xxxxxxxxxx>
Acked-by: Michal Hocko <mhocko@xxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Balbir Singh <bsingharora@xxxxxxxxx>
Cc: Aristeu Rozanski <aris@xxxxxxxxxx>
Cc: Matt Helsley <matthltc@xxxxxxxxxx>
Cc: Daniel Wagner <daniel.wagner@xxxxxxxxxxxx>
Cc: Vivek Goyal <vgoyal@xxxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>

netprio and cls part:

Acked-By: Daniel Wagner <daniel.wagner@xxxxxxxxxxxx>

cheers,
daniel



_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/containers




[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux