diff options
author | Tejun Heo <tj@kernel.org> | 2012-04-01 15:09:55 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-04-01 15:09:55 -0400 |
commit | 676f7c8f84d15e94065841529016da5ab92e901b (patch) | |
tree | 29c267a4c5711f9eaca7fa88fd7a78d39c8c4eac /net | |
parent | 6e6ff25bd548a0c5bf5163e4f63e2793dcefbdcb (diff) |
cgroup: relocate cftype and cgroup_subsys definitions in controllers
blk-cgroup, netprio_cgroup, cls_cgroup and tcp_memcontrol
unnecessarily define cftype array and cgroup_subsys structures at the
top of the file, which is unconventional and necessiates forward
declaration of methods.
This patch relocates those below the definitions of the methods and
removes the forward declarations. Note that forward declaration of
tcp_files[] is added in tcp_memcontrol.c for tcp_init_cgroup(). This
will be removed soon by another patch.
This patch doesn't introduce any functional change.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/netprio_cgroup.c | 26 | ||||
-rw-r--r-- | net/ipv4/tcp_memcontrol.c | 57 | ||||
-rw-r--r-- | net/sched/cls_cgroup.c | 27 |
3 files changed, 49 insertions, 61 deletions
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c index ba6900f73900..dbfd4e7f8dc4 100644 --- a/net/core/netprio_cgroup.c +++ b/net/core/netprio_cgroup.c | |||
@@ -23,21 +23,6 @@ | |||
23 | #include <net/sock.h> | 23 | #include <net/sock.h> |
24 | #include <net/netprio_cgroup.h> | 24 | #include <net/netprio_cgroup.h> |
25 | 25 | ||
26 | static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp); | ||
27 | static void cgrp_destroy(struct cgroup *cgrp); | ||
28 | static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp); | ||
29 | |||
30 | struct cgroup_subsys net_prio_subsys = { | ||
31 | .name = "net_prio", | ||
32 | .create = cgrp_create, | ||
33 | .destroy = cgrp_destroy, | ||
34 | .populate = cgrp_populate, | ||
35 | #ifdef CONFIG_NETPRIO_CGROUP | ||
36 | .subsys_id = net_prio_subsys_id, | ||
37 | #endif | ||
38 | .module = THIS_MODULE | ||
39 | }; | ||
40 | |||
41 | #define PRIOIDX_SZ 128 | 26 | #define PRIOIDX_SZ 128 |
42 | 27 | ||
43 | static unsigned long prioidx_map[PRIOIDX_SZ]; | 28 | static unsigned long prioidx_map[PRIOIDX_SZ]; |
@@ -264,6 +249,17 @@ static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) | |||
264 | return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); | 249 | return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); |
265 | } | 250 | } |
266 | 251 | ||
252 | struct cgroup_subsys net_prio_subsys = { | ||
253 | .name = "net_prio", | ||
254 | .create = cgrp_create, | ||
255 | .destroy = cgrp_destroy, | ||
256 | .populate = cgrp_populate, | ||
257 | #ifdef CONFIG_NETPRIO_CGROUP | ||
258 | .subsys_id = net_prio_subsys_id, | ||
259 | #endif | ||
260 | .module = THIS_MODULE | ||
261 | }; | ||
262 | |||
267 | static int netprio_device_event(struct notifier_block *unused, | 263 | static int netprio_device_event(struct notifier_block *unused, |
268 | unsigned long event, void *ptr) | 264 | unsigned long event, void *ptr) |
269 | { | 265 | { |
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c index e795272fbe9e..4d3ee407d2d8 100644 --- a/net/ipv4/tcp_memcontrol.c +++ b/net/ipv4/tcp_memcontrol.c | |||
@@ -6,36 +6,7 @@ | |||
6 | #include <linux/memcontrol.h> | 6 | #include <linux/memcontrol.h> |
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | 8 | ||
9 | static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft); | 9 | static struct cftype tcp_files[4]; /* XXX: will be removed soon */ |
10 | static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft, | ||
11 | const char *buffer); | ||
12 | static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event); | ||
13 | |||
14 | static struct cftype tcp_files[] = { | ||
15 | { | ||
16 | .name = "kmem.tcp.limit_in_bytes", | ||
17 | .write_string = tcp_cgroup_write, | ||
18 | .read_u64 = tcp_cgroup_read, | ||
19 | .private = RES_LIMIT, | ||
20 | }, | ||
21 | { | ||
22 | .name = "kmem.tcp.usage_in_bytes", | ||
23 | .read_u64 = tcp_cgroup_read, | ||
24 | .private = RES_USAGE, | ||
25 | }, | ||
26 | { | ||
27 | .name = "kmem.tcp.failcnt", | ||
28 | .private = RES_FAILCNT, | ||
29 | .trigger = tcp_cgroup_reset, | ||
30 | .read_u64 = tcp_cgroup_read, | ||
31 | }, | ||
32 | { | ||
33 | .name = "kmem.tcp.max_usage_in_bytes", | ||
34 | .private = RES_MAX_USAGE, | ||
35 | .trigger = tcp_cgroup_reset, | ||
36 | .read_u64 = tcp_cgroup_read, | ||
37 | }, | ||
38 | }; | ||
39 | 10 | ||
40 | static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) | 11 | static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) |
41 | { | 12 | { |
@@ -270,3 +241,29 @@ void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx) | |||
270 | 241 | ||
271 | tcp->tcp_prot_mem[idx] = val; | 242 | tcp->tcp_prot_mem[idx] = val; |
272 | } | 243 | } |
244 | |||
245 | static struct cftype tcp_files[] = { | ||
246 | { | ||
247 | .name = "kmem.tcp.limit_in_bytes", | ||
248 | .write_string = tcp_cgroup_write, | ||
249 | .read_u64 = tcp_cgroup_read, | ||
250 | .private = RES_LIMIT, | ||
251 | }, | ||
252 | { | ||
253 | .name = "kmem.tcp.usage_in_bytes", | ||
254 | .read_u64 = tcp_cgroup_read, | ||
255 | .private = RES_USAGE, | ||
256 | }, | ||
257 | { | ||
258 | .name = "kmem.tcp.failcnt", | ||
259 | .private = RES_FAILCNT, | ||
260 | .trigger = tcp_cgroup_reset, | ||
261 | .read_u64 = tcp_cgroup_read, | ||
262 | }, | ||
263 | { | ||
264 | .name = "kmem.tcp.max_usage_in_bytes", | ||
265 | .private = RES_MAX_USAGE, | ||
266 | .trigger = tcp_cgroup_reset, | ||
267 | .read_u64 = tcp_cgroup_read, | ||
268 | }, | ||
269 | }; | ||
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index 1afaa284fcd7..024df8a32275 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c | |||
@@ -22,22 +22,6 @@ | |||
22 | #include <net/sock.h> | 22 | #include <net/sock.h> |
23 | #include <net/cls_cgroup.h> | 23 | #include <net/cls_cgroup.h> |
24 | 24 | ||
25 | static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp); | ||
26 | static void cgrp_destroy(struct cgroup *cgrp); | ||
27 | static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp); | ||
28 | |||
29 | struct cgroup_subsys net_cls_subsys = { | ||
30 | .name = "net_cls", | ||
31 | .create = cgrp_create, | ||
32 | .destroy = cgrp_destroy, | ||
33 | .populate = cgrp_populate, | ||
34 | #ifdef CONFIG_NET_CLS_CGROUP | ||
35 | .subsys_id = net_cls_subsys_id, | ||
36 | #endif | ||
37 | .module = THIS_MODULE, | ||
38 | }; | ||
39 | |||
40 | |||
41 | static inline struct cgroup_cls_state *cgrp_cls_state(struct cgroup *cgrp) | 25 | static inline struct cgroup_cls_state *cgrp_cls_state(struct cgroup *cgrp) |
42 | { | 26 | { |
43 | return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id), | 27 | return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id), |
@@ -93,6 +77,17 @@ static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) | |||
93 | return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); | 77 | return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); |
94 | } | 78 | } |
95 | 79 | ||
80 | struct cgroup_subsys net_cls_subsys = { | ||
81 | .name = "net_cls", | ||
82 | .create = cgrp_create, | ||
83 | .destroy = cgrp_destroy, | ||
84 | .populate = cgrp_populate, | ||
85 | #ifdef CONFIG_NET_CLS_CGROUP | ||
86 | .subsys_id = net_cls_subsys_id, | ||
87 | #endif | ||
88 | .module = THIS_MODULE, | ||
89 | }; | ||
90 | |||
96 | struct cls_cgroup_head { | 91 | struct cls_cgroup_head { |
97 | u32 handle; | 92 | u32 handle; |
98 | struct tcf_exts exts; | 93 | struct tcf_exts exts; |