User: Password:
Subscribe / Log in / New account

cgroup: Assign subsystem IDs during compile time

From:  Daniel Wagner <>
Subject:  [PATCH v2 00/10] cgroup: Assign subsystem IDs during compile time
Date:  Fri, 24 Aug 2012 16:01:34 +0200
Message-ID:  <>
Cc:  Daniel Wagner <>, "David S. Miller" <davem-fT/PcQaiUtIeIZ0/>, Andrew Morton <akpm-de/>, Eric Dumazet <>, Gao feng <>, Glauber Costa <>, Jamal Hadi Salim <jhs-jkUAjuhPggJWk0Htik3J/>, John Fastabend <>, Kamezawa Hiroyuki <>, Li Zefan <>, Neil Horman <>, Tejun Heo <>
Archive-link:  Article

From: Daniel Wagner <>


Most notable changes are, that enabling/disabling of the jump labels
are not inside the cgroup_lock anymore (create/destroy cb). Instead
the corresponding functions will be called on module load or unload.

CGROUP_BUILTIN_SUBSYS_COUNT is also gone in this version.  This time I
trade space for speed. Some extra cycles are spend to identify the
modules in the for loops, e.g.

for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
	struct cgroup_subsys_state *ss = cgrp->subsys[i];

	/* at bootup time, we don't worry about modular subsystems */
	if (!ss || (ss && ss->module))


CGROUP_SUBSYS_COUNT is currently 12 if all controllers are built.  I
haven't found any other way to get rid of CGROUP_BUILTIN_SUBSYS_COUNT
without real dirty preprocessor tricks.

Finally, the two versions of task_cls_classid() and task_netprioidx()
are merged together.


Original cover letter:

The patch #1 and #2 are there to be able to introduce (#3, #4) the 
jump labels in task_cls_classid() and task_netprioidx(). The jump
labels are needed to know when it is safe to access the controller. 
For example not safe means the module is not yet loaded.

All those patches are just preparation for the center piece (#5) 
of these series. This one will remove the dynamic subsystem ID
generation and falls back to compile time generated IDs. 

This is the first result from the discussion around on the
"cgroup cls & netprio 'cleanups'" patches.

This patches are against net-next

v2: - do not use dirty precompiler tricks:
      use ss->module to identify modules in the loops.
    - enable/disable jump labels in module load/unload functions
    - merge builtin/module versions of task_cls_classid() and task_netprioidx
v1: - only use jump labels when built as module (#3, #4)
    - get rid of the additional 'pointer' (#5)
v0: - initial version

Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/>
Cc: Andrew Morton <akpm-de/>
Cc: Eric Dumazet <>
Cc: Gao feng <>
Cc: Glauber Costa <>
Cc: Jamal Hadi Salim <jhs-jkUAjuhPggJWk0Htik3J/>
Cc: John Fastabend <>
Cc: Kamezawa Hiroyuki <>
Cc: Li Zefan <>
Cc: Neil Horman <>
Cc: Tejun Heo <>

Daniel Wagner (10):
  cgroup: net_cls: Use empty task_cls_classid() when
  cgroup: net_cls: Move sock_update_classid() decleration to
  cgroup: net_cls: Protect access to task_cls_classid() when built as
  cgroup: net_prio: Protect access to task_netprioidx() when built as
  cgroup: Assign subsystem IDs during compile time
  cgroup: net_cls: Simplify ifdef logic
  cgroup: net_cls: Merge builtin and module version of
  cgroup: net_prio: Simplify ifdef logic
  cgroup: net_prio: Merge builtin and module version of

 include/linux/cgroup.h        | 30 ++++++++-----
 include/linux/cgroup_subsys.h | 24 +++++------
 include/net/cls_cgroup.h      | 51 +++++++++++-----------
 include/net/netprio_cgroup.h  | 48 ++++++++-------------
 include/net/sock.h            |  8 ----
 kernel/cgroup.c               | 98 +++++++++++++++++++++++--------------------
 net/core/netprio_cgroup.c     | 14 +++----
 net/core/sock.c               | 16 ++++---
 net/sched/cls_cgroup.c        | 20 ++++-----
 9 files changed, 151 insertions(+), 158 deletions(-)


Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds