Re: [PATCH 2/6] cgroup: drop module support

2014-01-29 Thread Tejun Heo
Hello, Li.

On Wed, Jan 29, 2014 at 12:16:38PM +0800, Li Zefan wrote:
> > -#define for_each_builtin_subsys(ss, i) 
> > \
> > -   for ((i) = 0; (i) < CGROUP_BUILTIN_SUBSYS_COUNT &&  \
> > -(((ss) = cgroup_subsys[i]) || true); (i)++)
> > +   for ((ssid) = 0; (ssid) < CGROUP_SUBSYS_COUNT &&\
> > +(((ss) = cgroup_subsys[ssid]) || true); (ssid)++)
> 
> Now cgroup_subsys[i] won't be NULL, so we can drop "|| true".

Hmmm... because the macro is kinda complex, I'd like to avoid changing
its implementation in this patch.  Also, the "|| true" tells the
compiler that it doesn't have to generate conditional branch on the
preceding condition.

Now that the array is always consecutive, I'm planning to further
simplify the iterators to not require ssid, so that it just becomes
for_each_subsys(ss).  Let's leave it alone for now.

> > +   if (need_forkexit_callback)
> > +   for_each_subsys(ss, i)
> > if (ss->fork)
> > ss->fork(child);
> > -   }
> 
> This looks a bit ugly. How about leaving the parentheses for the
> outmost if statement?
> 
> if (need_forkexit_callback) {
>   for_each_subsys(ss, i)
>   if (ss->fork)
>   ss->fork(child);
> }

Maybe, I don't know.  I tend to aim for the minimum necessary as that
usually is the easiest way to achieve consistency.  That said certain
things are a lot easier on the eye with a bit of extra notations -
e.g. "(a & b) && c".  Alright, will add the parentheses.

Thanks!

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/6] cgroup: drop module support

2014-01-29 Thread Tejun Heo
Hello, Li.

On Wed, Jan 29, 2014 at 12:16:38PM +0800, Li Zefan wrote:
  -#define for_each_builtin_subsys(ss, i) 
  \
  -   for ((i) = 0; (i)  CGROUP_BUILTIN_SUBSYS_COUNT   \
  -(((ss) = cgroup_subsys[i]) || true); (i)++)
  +   for ((ssid) = 0; (ssid)  CGROUP_SUBSYS_COUNT \
  +(((ss) = cgroup_subsys[ssid]) || true); (ssid)++)
 
 Now cgroup_subsys[i] won't be NULL, so we can drop || true.

Hmmm... because the macro is kinda complex, I'd like to avoid changing
its implementation in this patch.  Also, the || true tells the
compiler that it doesn't have to generate conditional branch on the
preceding condition.

Now that the array is always consecutive, I'm planning to further
simplify the iterators to not require ssid, so that it just becomes
for_each_subsys(ss).  Let's leave it alone for now.

  +   if (need_forkexit_callback)
  +   for_each_subsys(ss, i)
  if (ss-fork)
  ss-fork(child);
  -   }
 
 This looks a bit ugly. How about leaving the parentheses for the
 outmost if statement?
 
 if (need_forkexit_callback) {
   for_each_subsys(ss, i)
   if (ss-fork)
   ss-fork(child);
 }

Maybe, I don't know.  I tend to aim for the minimum necessary as that
usually is the easiest way to achieve consistency.  That said certain
things are a lot easier on the eye with a bit of extra notations -
e.g. (a  b)  c.  Alright, will add the parentheses.

Thanks!

-- 
tejun
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/6] cgroup: drop module support

2014-01-28 Thread Li Zefan
>  /**
> - * for_each_subsys - iterate all loaded cgroup subsystems
> + * for_each_subsys - iterate all enabled cgroup subsystems
>   * @ss: the iteration cursor
>   * @ssid: the index of @ss, CGROUP_SUBSYS_COUNT after reaching the end
> - *
> - * Iterates through all loaded subsystems.  Should be called under
> - * cgroup_mutex or cgroup_root_mutex.
>   */
>  #define for_each_subsys(ss, ssid)\
> - for (({ cgroup_assert_mutex_or_root_locked(); (ssid) = 0; });   \
> -  (ssid) < CGROUP_SUBSYS_COUNT; (ssid)++)\
> - if (!((ss) = cgroup_subsys[(ssid)])) { }\
> - else
> -
> -/**
> - * for_each_builtin_subsys - iterate all built-in cgroup subsystems
> - * @ss: the iteration cursor
> - * @i: the index of @ss, CGROUP_BUILTIN_SUBSYS_COUNT after reaching the end
> - *
> - * Bulit-in subsystems are always present and iteration itself doesn't
> - * require any synchronization.
> - */
> -#define for_each_builtin_subsys(ss, i)   
> \
> - for ((i) = 0; (i) < CGROUP_BUILTIN_SUBSYS_COUNT &&  \
> -  (((ss) = cgroup_subsys[i]) || true); (i)++)
> + for ((ssid) = 0; (ssid) < CGROUP_SUBSYS_COUNT &&\
> +  (((ss) = cgroup_subsys[ssid]) || true); (ssid)++)

Now cgroup_subsys[i] won't be NULL, so we can drop "|| true".

>  
>  /* iterate across the active hierarchies */
>  #define for_each_active_root(root)   \
> @@ -975,50 +951,24 @@ static void cgroup_d_remove_dir(struct dentry *dentry)
>   remove_dir(dentry);
>  }
>  

...

> - if (need_forkexit_callback) {
> - /*
> -  * fork/exit callbacks are supported only for builtin
> -  * subsystems, and the builtin section of the subsys
> -  * array is immutable, so we don't need to lock the
> -  * subsys array here. On the other hand, modular section
> -  * of the array can be freed at module unload, so we
> -  * can't touch that.
> -  */
> - for_each_builtin_subsys(ss, i)
> + if (need_forkexit_callback)
> + for_each_subsys(ss, i)
>   if (ss->fork)
>   ss->fork(child);
> - }

This looks a bit ugly. How about leaving the parentheses for the
outmost if statement?

if (need_forkexit_callback) {
for_each_subsys(ss, i)
if (ss->fork)
ss->fork(child);
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] cgroup: drop module support

2014-01-28 Thread Tejun Heo
With module supported dropped from net_prio, no controller is using
cgroup module support.  None of actual resource controllers can be
built as a module and we aren't gonna add new controllers which don't
control resources.  This patch drops module support from cgroup.

* cgroup_[un]load_subsys() and cgroup_subsys->module removed.

* As there's no point in distinguishing IS_BUILTIN() and IS_MODULE(),
  cgroup_subsys.h now uses IS_ENABLED() directly.

* enum cgroup_subsys_id now exactly matches the list of enabled
  controllers as ordered in cgroup_subsys.h.

* cgroup_subsys[] is now a contiguously occupied array.  Size
  specification is no longer necessary and dropped.

* for_each_builtin_subsys() is removed and for_each_subsys() is
  updated to not require any locking.

* module ref handling is removed from rebind_subsystems().

* Module related comments dropped.

v2: Rebased on top of fe1217c4f3f7 ("net: net_cls: move cgroupfs
classid handling into core").

Signed-off-by: Tejun Heo 
---
 block/blk-cgroup.c|   1 -
 include/linux/cgroup.h|  29 +
 include/linux/cgroup_subsys.h |  24 ++--
 kernel/cgroup.c   | 287 +++---
 net/core/netclassid_cgroup.c  |   1 -
 net/core/netprio_cgroup.c |   1 -
 6 files changed, 33 insertions(+), 310 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4e491d9..660d419 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -914,7 +914,6 @@ struct cgroup_subsys blkio_subsys = {
.can_attach = blkcg_can_attach,
.subsys_id = blkio_subsys_id,
.base_cftypes = blkcg_files,
-   .module = THIS_MODULE,
 };
 EXPORT_SYMBOL_GPL(blkio_subsys);
 
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5c09759..d842a73 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -37,28 +37,13 @@ extern void cgroup_post_fork(struct task_struct *p);
 extern void cgroup_exit(struct task_struct *p, int run_callbacks);
 extern int cgroupstats_build(struct cgroupstats *stats,
struct dentry *dentry);
-extern int cgroup_load_subsys(struct cgroup_subsys *ss);
-extern void cgroup_unload_subsys(struct cgroup_subsys *ss);
 
 extern int proc_cgroup_show(struct seq_file *, void *);
 
-/*
- * Define the enumeration of all cgroup subsystems.
- *
- * We define ids for builtin subsystems and then modular ones.
- */
+/* define the enumeration of all cgroup subsystems */
 #define SUBSYS(_x) _x ## _subsys_id,
 enum cgroup_subsys_id {
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include 
-#undef IS_SUBSYS_ENABLED
-   CGROUP_BUILTIN_SUBSYS_COUNT,
-
-   __CGROUP_SUBSYS_TEMP_PLACEHOLDER = CGROUP_BUILTIN_SUBSYS_COUNT - 1,
-
-#define IS_SUBSYS_ENABLED(option) IS_MODULE(option)
-#include 
-#undef IS_SUBSYS_ENABLED
CGROUP_SUBSYS_COUNT,
 };
 #undef SUBSYS
@@ -370,10 +355,9 @@ struct css_set {
struct list_head cgrp_links;
 
/*
-* Set of subsystem states, one for each subsystem. This array
-* is immutable after creation apart from the init_css_set
-* during subsystem registration (at boot time) and modular subsystem
-* loading/unloading.
+* Set of subsystem states, one for each subsystem. This array is
+* immutable after creation apart from the init_css_set during
+* subsystem registration (at boot time).
 */
struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
 
@@ -620,15 +604,10 @@ struct cgroup_subsys {
/* base cftypes, automatically [de]registered with subsys itself */
struct cftype *base_cftypes;
struct cftype_set base_cftset;
-
-   /* should be defined only by modular subsystems */
-   struct module *module;
 };
 
 #define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys;
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include 
-#undef IS_SUBSYS_ENABLED
 #undef SUBSYS
 
 /**
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 7b99d71..11c42f6 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -3,51 +3,51 @@
  *
  * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
  */
-#if IS_SUBSYS_ENABLED(CONFIG_CPUSETS)
+#if IS_ENABLED(CONFIG_CPUSETS)
 SUBSYS(cpuset)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG)
+#if IS_ENABLED(CONFIG_CGROUP_DEBUG)
 SUBSYS(debug)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED)
+#if IS_ENABLED(CONFIG_CGROUP_SCHED)
 SUBSYS(cpu_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT)
+#if IS_ENABLED(CONFIG_CGROUP_CPUACCT)
 SUBSYS(cpuacct)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_MEMCG)
+#if IS_ENABLED(CONFIG_MEMCG)
 SUBSYS(mem_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE)
+#if IS_ENABLED(CONFIG_CGROUP_DEVICE)
 SUBSYS(devices)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER)
+#if IS_ENABLED(CONFIG_CGROUP_FREEZER)
 SUBSYS(freezer)
 

[PATCH 2/6] cgroup: drop module support

2014-01-28 Thread Tejun Heo
With module supported dropped from net_prio, no controller is using
cgroup module support.  None of actual resource controllers can be
built as a module and we aren't gonna add new controllers which don't
control resources.  This patch drops module support from cgroup.

* cgroup_[un]load_subsys() and cgroup_subsys-module removed.

* As there's no point in distinguishing IS_BUILTIN() and IS_MODULE(),
  cgroup_subsys.h now uses IS_ENABLED() directly.

* enum cgroup_subsys_id now exactly matches the list of enabled
  controllers as ordered in cgroup_subsys.h.

* cgroup_subsys[] is now a contiguously occupied array.  Size
  specification is no longer necessary and dropped.

* for_each_builtin_subsys() is removed and for_each_subsys() is
  updated to not require any locking.

* module ref handling is removed from rebind_subsystems().

* Module related comments dropped.

v2: Rebased on top of fe1217c4f3f7 (net: net_cls: move cgroupfs
classid handling into core).

Signed-off-by: Tejun Heo t...@kernel.org
---
 block/blk-cgroup.c|   1 -
 include/linux/cgroup.h|  29 +
 include/linux/cgroup_subsys.h |  24 ++--
 kernel/cgroup.c   | 287 +++---
 net/core/netclassid_cgroup.c  |   1 -
 net/core/netprio_cgroup.c |   1 -
 6 files changed, 33 insertions(+), 310 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4e491d9..660d419 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -914,7 +914,6 @@ struct cgroup_subsys blkio_subsys = {
.can_attach = blkcg_can_attach,
.subsys_id = blkio_subsys_id,
.base_cftypes = blkcg_files,
-   .module = THIS_MODULE,
 };
 EXPORT_SYMBOL_GPL(blkio_subsys);
 
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5c09759..d842a73 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -37,28 +37,13 @@ extern void cgroup_post_fork(struct task_struct *p);
 extern void cgroup_exit(struct task_struct *p, int run_callbacks);
 extern int cgroupstats_build(struct cgroupstats *stats,
struct dentry *dentry);
-extern int cgroup_load_subsys(struct cgroup_subsys *ss);
-extern void cgroup_unload_subsys(struct cgroup_subsys *ss);
 
 extern int proc_cgroup_show(struct seq_file *, void *);
 
-/*
- * Define the enumeration of all cgroup subsystems.
- *
- * We define ids for builtin subsystems and then modular ones.
- */
+/* define the enumeration of all cgroup subsystems */
 #define SUBSYS(_x) _x ## _subsys_id,
 enum cgroup_subsys_id {
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include linux/cgroup_subsys.h
-#undef IS_SUBSYS_ENABLED
-   CGROUP_BUILTIN_SUBSYS_COUNT,
-
-   __CGROUP_SUBSYS_TEMP_PLACEHOLDER = CGROUP_BUILTIN_SUBSYS_COUNT - 1,
-
-#define IS_SUBSYS_ENABLED(option) IS_MODULE(option)
-#include linux/cgroup_subsys.h
-#undef IS_SUBSYS_ENABLED
CGROUP_SUBSYS_COUNT,
 };
 #undef SUBSYS
@@ -370,10 +355,9 @@ struct css_set {
struct list_head cgrp_links;
 
/*
-* Set of subsystem states, one for each subsystem. This array
-* is immutable after creation apart from the init_css_set
-* during subsystem registration (at boot time) and modular subsystem
-* loading/unloading.
+* Set of subsystem states, one for each subsystem. This array is
+* immutable after creation apart from the init_css_set during
+* subsystem registration (at boot time).
 */
struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
 
@@ -620,15 +604,10 @@ struct cgroup_subsys {
/* base cftypes, automatically [de]registered with subsys itself */
struct cftype *base_cftypes;
struct cftype_set base_cftset;
-
-   /* should be defined only by modular subsystems */
-   struct module *module;
 };
 
 #define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys;
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include linux/cgroup_subsys.h
-#undef IS_SUBSYS_ENABLED
 #undef SUBSYS
 
 /**
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 7b99d71..11c42f6 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -3,51 +3,51 @@
  *
  * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
  */
-#if IS_SUBSYS_ENABLED(CONFIG_CPUSETS)
+#if IS_ENABLED(CONFIG_CPUSETS)
 SUBSYS(cpuset)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG)
+#if IS_ENABLED(CONFIG_CGROUP_DEBUG)
 SUBSYS(debug)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED)
+#if IS_ENABLED(CONFIG_CGROUP_SCHED)
 SUBSYS(cpu_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT)
+#if IS_ENABLED(CONFIG_CGROUP_CPUACCT)
 SUBSYS(cpuacct)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_MEMCG)
+#if IS_ENABLED(CONFIG_MEMCG)
 SUBSYS(mem_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE)
+#if IS_ENABLED(CONFIG_CGROUP_DEVICE)
 SUBSYS(devices)
 #endif
 
-#if 

Re: [PATCH 2/6] cgroup: drop module support

2014-01-28 Thread Li Zefan
  /**
 - * for_each_subsys - iterate all loaded cgroup subsystems
 + * for_each_subsys - iterate all enabled cgroup subsystems
   * @ss: the iteration cursor
   * @ssid: the index of @ss, CGROUP_SUBSYS_COUNT after reaching the end
 - *
 - * Iterates through all loaded subsystems.  Should be called under
 - * cgroup_mutex or cgroup_root_mutex.
   */
  #define for_each_subsys(ss, ssid)\
 - for (({ cgroup_assert_mutex_or_root_locked(); (ssid) = 0; });   \
 -  (ssid)  CGROUP_SUBSYS_COUNT; (ssid)++)\
 - if (!((ss) = cgroup_subsys[(ssid)])) { }\
 - else
 -
 -/**
 - * for_each_builtin_subsys - iterate all built-in cgroup subsystems
 - * @ss: the iteration cursor
 - * @i: the index of @ss, CGROUP_BUILTIN_SUBSYS_COUNT after reaching the end
 - *
 - * Bulit-in subsystems are always present and iteration itself doesn't
 - * require any synchronization.
 - */
 -#define for_each_builtin_subsys(ss, i)   
 \
 - for ((i) = 0; (i)  CGROUP_BUILTIN_SUBSYS_COUNT   \
 -  (((ss) = cgroup_subsys[i]) || true); (i)++)
 + for ((ssid) = 0; (ssid)  CGROUP_SUBSYS_COUNT \
 +  (((ss) = cgroup_subsys[ssid]) || true); (ssid)++)

Now cgroup_subsys[i] won't be NULL, so we can drop || true.

  
  /* iterate across the active hierarchies */
  #define for_each_active_root(root)   \
 @@ -975,50 +951,24 @@ static void cgroup_d_remove_dir(struct dentry *dentry)
   remove_dir(dentry);
  }
  

...

 - if (need_forkexit_callback) {
 - /*
 -  * fork/exit callbacks are supported only for builtin
 -  * subsystems, and the builtin section of the subsys
 -  * array is immutable, so we don't need to lock the
 -  * subsys array here. On the other hand, modular section
 -  * of the array can be freed at module unload, so we
 -  * can't touch that.
 -  */
 - for_each_builtin_subsys(ss, i)
 + if (need_forkexit_callback)
 + for_each_subsys(ss, i)
   if (ss-fork)
   ss-fork(child);
 - }

This looks a bit ugly. How about leaving the parentheses for the
outmost if statement?

if (need_forkexit_callback) {
for_each_subsys(ss, i)
if (ss-fork)
ss-fork(child);
}


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] cgroup: drop module support

2014-01-17 Thread Tejun Heo
With module supported dropped from net_cls and net_prio, no controller
is using cgroup module support.  None of actual resource controllers
can be built as a module and we aren't gonna add new controllers which
don't control resources.  This patch drops module support from cgroup.

* cgroup_[un]load_subsys() and cgroup_subsys->module removed.

* As there's no point in distinguishing IS_BUILTIN() and IS_MODULE(),
  cgroup_subsys.h now uses IS_ENABLED() directly.

* enum cgroup_subsys_id now exactly matches the list of enabled
  controllers as ordered in cgroup_subsys.h.

* cgroup_subsys[] is now a contiguously occupied array.  Size
  specification is no longer necessary and dropped.

* for_each_builtin_subsys() is removed and for_each_subsys() is
  updated to not require any locking.

* module ref handling is removed from rebind_subsystems().

* Module related comments dropped.

Signed-off-by: Tejun Heo 
---
 block/blk-cgroup.c|   1 -
 include/linux/cgroup.h|  29 +
 include/linux/cgroup_subsys.h |  24 ++--
 kernel/cgroup.c   | 287 +++---
 net/core/netprio_cgroup.c |   1 -
 net/sched/cls_cgroup.c|   1 -
 6 files changed, 33 insertions(+), 310 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4e491d9..660d419 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -914,7 +914,6 @@ struct cgroup_subsys blkio_subsys = {
.can_attach = blkcg_can_attach,
.subsys_id = blkio_subsys_id,
.base_cftypes = blkcg_files,
-   .module = THIS_MODULE,
 };
 EXPORT_SYMBOL_GPL(blkio_subsys);
 
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5c09759..d842a73 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -37,28 +37,13 @@ extern void cgroup_post_fork(struct task_struct *p);
 extern void cgroup_exit(struct task_struct *p, int run_callbacks);
 extern int cgroupstats_build(struct cgroupstats *stats,
struct dentry *dentry);
-extern int cgroup_load_subsys(struct cgroup_subsys *ss);
-extern void cgroup_unload_subsys(struct cgroup_subsys *ss);
 
 extern int proc_cgroup_show(struct seq_file *, void *);
 
-/*
- * Define the enumeration of all cgroup subsystems.
- *
- * We define ids for builtin subsystems and then modular ones.
- */
+/* define the enumeration of all cgroup subsystems */
 #define SUBSYS(_x) _x ## _subsys_id,
 enum cgroup_subsys_id {
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include 
-#undef IS_SUBSYS_ENABLED
-   CGROUP_BUILTIN_SUBSYS_COUNT,
-
-   __CGROUP_SUBSYS_TEMP_PLACEHOLDER = CGROUP_BUILTIN_SUBSYS_COUNT - 1,
-
-#define IS_SUBSYS_ENABLED(option) IS_MODULE(option)
-#include 
-#undef IS_SUBSYS_ENABLED
CGROUP_SUBSYS_COUNT,
 };
 #undef SUBSYS
@@ -370,10 +355,9 @@ struct css_set {
struct list_head cgrp_links;
 
/*
-* Set of subsystem states, one for each subsystem. This array
-* is immutable after creation apart from the init_css_set
-* during subsystem registration (at boot time) and modular subsystem
-* loading/unloading.
+* Set of subsystem states, one for each subsystem. This array is
+* immutable after creation apart from the init_css_set during
+* subsystem registration (at boot time).
 */
struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
 
@@ -620,15 +604,10 @@ struct cgroup_subsys {
/* base cftypes, automatically [de]registered with subsys itself */
struct cftype *base_cftypes;
struct cftype_set base_cftset;
-
-   /* should be defined only by modular subsystems */
-   struct module *module;
 };
 
 #define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys;
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include 
-#undef IS_SUBSYS_ENABLED
 #undef SUBSYS
 
 /**
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index b613ffd..cc4cafe 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -3,51 +3,51 @@
  *
  * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
  */
-#if IS_SUBSYS_ENABLED(CONFIG_CPUSETS)
+#if IS_ENABLED(CONFIG_CPUSETS)
 SUBSYS(cpuset)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG)
+#if IS_ENABLED(CONFIG_CGROUP_DEBUG)
 SUBSYS(debug)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED)
+#if IS_ENABLED(CONFIG_CGROUP_SCHED)
 SUBSYS(cpu_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT)
+#if IS_ENABLED(CONFIG_CGROUP_CPUACCT)
 SUBSYS(cpuacct)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_MEMCG)
+#if IS_ENABLED(CONFIG_MEMCG)
 SUBSYS(mem_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE)
+#if IS_ENABLED(CONFIG_CGROUP_DEVICE)
 SUBSYS(devices)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER)
+#if IS_ENABLED(CONFIG_CGROUP_FREEZER)
 SUBSYS(freezer)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_NET_CLS_CGROUP)
+#if 

[PATCH 2/6] cgroup: drop module support

2014-01-17 Thread Tejun Heo
With module supported dropped from net_cls and net_prio, no controller
is using cgroup module support.  None of actual resource controllers
can be built as a module and we aren't gonna add new controllers which
don't control resources.  This patch drops module support from cgroup.

* cgroup_[un]load_subsys() and cgroup_subsys-module removed.

* As there's no point in distinguishing IS_BUILTIN() and IS_MODULE(),
  cgroup_subsys.h now uses IS_ENABLED() directly.

* enum cgroup_subsys_id now exactly matches the list of enabled
  controllers as ordered in cgroup_subsys.h.

* cgroup_subsys[] is now a contiguously occupied array.  Size
  specification is no longer necessary and dropped.

* for_each_builtin_subsys() is removed and for_each_subsys() is
  updated to not require any locking.

* module ref handling is removed from rebind_subsystems().

* Module related comments dropped.

Signed-off-by: Tejun Heo t...@kernel.org
---
 block/blk-cgroup.c|   1 -
 include/linux/cgroup.h|  29 +
 include/linux/cgroup_subsys.h |  24 ++--
 kernel/cgroup.c   | 287 +++---
 net/core/netprio_cgroup.c |   1 -
 net/sched/cls_cgroup.c|   1 -
 6 files changed, 33 insertions(+), 310 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 4e491d9..660d419 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -914,7 +914,6 @@ struct cgroup_subsys blkio_subsys = {
.can_attach = blkcg_can_attach,
.subsys_id = blkio_subsys_id,
.base_cftypes = blkcg_files,
-   .module = THIS_MODULE,
 };
 EXPORT_SYMBOL_GPL(blkio_subsys);
 
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5c09759..d842a73 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -37,28 +37,13 @@ extern void cgroup_post_fork(struct task_struct *p);
 extern void cgroup_exit(struct task_struct *p, int run_callbacks);
 extern int cgroupstats_build(struct cgroupstats *stats,
struct dentry *dentry);
-extern int cgroup_load_subsys(struct cgroup_subsys *ss);
-extern void cgroup_unload_subsys(struct cgroup_subsys *ss);
 
 extern int proc_cgroup_show(struct seq_file *, void *);
 
-/*
- * Define the enumeration of all cgroup subsystems.
- *
- * We define ids for builtin subsystems and then modular ones.
- */
+/* define the enumeration of all cgroup subsystems */
 #define SUBSYS(_x) _x ## _subsys_id,
 enum cgroup_subsys_id {
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include linux/cgroup_subsys.h
-#undef IS_SUBSYS_ENABLED
-   CGROUP_BUILTIN_SUBSYS_COUNT,
-
-   __CGROUP_SUBSYS_TEMP_PLACEHOLDER = CGROUP_BUILTIN_SUBSYS_COUNT - 1,
-
-#define IS_SUBSYS_ENABLED(option) IS_MODULE(option)
-#include linux/cgroup_subsys.h
-#undef IS_SUBSYS_ENABLED
CGROUP_SUBSYS_COUNT,
 };
 #undef SUBSYS
@@ -370,10 +355,9 @@ struct css_set {
struct list_head cgrp_links;
 
/*
-* Set of subsystem states, one for each subsystem. This array
-* is immutable after creation apart from the init_css_set
-* during subsystem registration (at boot time) and modular subsystem
-* loading/unloading.
+* Set of subsystem states, one for each subsystem. This array is
+* immutable after creation apart from the init_css_set during
+* subsystem registration (at boot time).
 */
struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
 
@@ -620,15 +604,10 @@ struct cgroup_subsys {
/* base cftypes, automatically [de]registered with subsys itself */
struct cftype *base_cftypes;
struct cftype_set base_cftset;
-
-   /* should be defined only by modular subsystems */
-   struct module *module;
 };
 
 #define SUBSYS(_x) extern struct cgroup_subsys _x ## _subsys;
-#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include linux/cgroup_subsys.h
-#undef IS_SUBSYS_ENABLED
 #undef SUBSYS
 
 /**
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index b613ffd..cc4cafe 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -3,51 +3,51 @@
  *
  * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
  */
-#if IS_SUBSYS_ENABLED(CONFIG_CPUSETS)
+#if IS_ENABLED(CONFIG_CPUSETS)
 SUBSYS(cpuset)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG)
+#if IS_ENABLED(CONFIG_CGROUP_DEBUG)
 SUBSYS(debug)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED)
+#if IS_ENABLED(CONFIG_CGROUP_SCHED)
 SUBSYS(cpu_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT)
+#if IS_ENABLED(CONFIG_CGROUP_CPUACCT)
 SUBSYS(cpuacct)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_MEMCG)
+#if IS_ENABLED(CONFIG_MEMCG)
 SUBSYS(mem_cgroup)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE)
+#if IS_ENABLED(CONFIG_CGROUP_DEVICE)
 SUBSYS(devices)
 #endif
 
-#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER)
+#if IS_ENABLED(CONFIG_CGROUP_FREEZER)
 SUBSYS(freezer)
 #endif
 
-#if