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

From: Li Zefan
Date: Tue Jan 28 2014 - 23:17:34 EST


> /**
> - * 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/