diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-22 20:40:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-22 20:40:19 -0400 |
commit | 88d6ae8dc33af12fe1c7941b1fae2767374046fd (patch) | |
tree | 8f17415c0722b0a4d7511ac170cfb4e3802e1ad2 /net/ipv4 | |
parent | f5c101892fbd3d2f6d2729bc7eb7b3f6c31dbddd (diff) | |
parent | 0d4dde1ac9a5af74ac76c6ab90557d1ae7b8f5d8 (diff) |
Merge branch 'for-3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo:
"cgroup file type addition / removal is updated so that file types are
added and removed instead of individual files so that dynamic file
type addition / removal can be implemented by cgroup and used by
controllers. blkio controller changes which will come through block
tree are dependent on this. Other changes include res_counter cleanup
and disallowing kthread / PF_THREAD_BOUND threads to be attached to
non-root cgroups.
There's a reported bug with the file type addition / removal handling
which can lead to oops on cgroup umount. The issue is being looked
into. It shouldn't cause problems for most setups and isn't a
security concern."
Fix up trivial conflict in Documentation/feature-removal-schedule.txt
* 'for-3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: (21 commits)
res_counter: Account max_usage when calling res_counter_charge_nofail()
res_counter: Merge res_counter_charge and res_counter_charge_nofail
cgroups: disallow attaching kthreadd or PF_THREAD_BOUND threads
cgroup: remove cgroup_subsys->populate()
cgroup: get rid of populate for memcg
cgroup: pass struct mem_cgroup instead of struct cgroup to socket memcg
cgroup: make css->refcnt clearing on cgroup removal optional
cgroup: use negative bias on css->refcnt to block css_tryget()
cgroup: implement cgroup_rm_cftypes()
cgroup: introduce struct cfent
cgroup: relocate __d_cgrp() and __d_cft()
cgroup: remove cgroup_add_file[s]()
cgroup: convert memcg controller to the new cftype interface
memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP
cgroup: convert all non-memcg controllers to the new cftype interface
cgroup: relocate cftype and cgroup_subsys definitions in controllers
cgroup: merge cft_release_agent cftype array into the base files array
cgroup: implement cgroup_add_cftypes() and friends
cgroup: build list of all cgroups under a given cgroupfs_root
cgroup: move cgroup_clear_directory() call out of cgroup_populate_dir()
...
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/tcp_memcontrol.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c index e795272fbe9e..151703791bb0 100644 --- a/net/ipv4/tcp_memcontrol.c +++ b/net/ipv4/tcp_memcontrol.c | |||
@@ -6,37 +6,6 @@ | |||
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); | ||
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 | |||
40 | static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) | 9 | static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) |
41 | { | 10 | { |
42 | return container_of(cg_proto, struct tcp_memcontrol, cg_proto); | 11 | return container_of(cg_proto, struct tcp_memcontrol, cg_proto); |
@@ -49,7 +18,7 @@ static void memcg_tcp_enter_memory_pressure(struct sock *sk) | |||
49 | } | 18 | } |
50 | EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure); | 19 | EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure); |
51 | 20 | ||
52 | int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) | 21 | int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss) |
53 | { | 22 | { |
54 | /* | 23 | /* |
55 | * The root cgroup does not use res_counters, but rather, | 24 | * The root cgroup does not use res_counters, but rather, |
@@ -59,13 +28,12 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
59 | struct res_counter *res_parent = NULL; | 28 | struct res_counter *res_parent = NULL; |
60 | struct cg_proto *cg_proto, *parent_cg; | 29 | struct cg_proto *cg_proto, *parent_cg; |
61 | struct tcp_memcontrol *tcp; | 30 | struct tcp_memcontrol *tcp; |
62 | struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); | ||
63 | struct mem_cgroup *parent = parent_mem_cgroup(memcg); | 31 | struct mem_cgroup *parent = parent_mem_cgroup(memcg); |
64 | struct net *net = current->nsproxy->net_ns; | 32 | struct net *net = current->nsproxy->net_ns; |
65 | 33 | ||
66 | cg_proto = tcp_prot.proto_cgroup(memcg); | 34 | cg_proto = tcp_prot.proto_cgroup(memcg); |
67 | if (!cg_proto) | 35 | if (!cg_proto) |
68 | goto create_files; | 36 | return 0; |
69 | 37 | ||
70 | tcp = tcp_from_cgproto(cg_proto); | 38 | tcp = tcp_from_cgproto(cg_proto); |
71 | 39 | ||
@@ -88,15 +56,12 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
88 | cg_proto->sockets_allocated = &tcp->tcp_sockets_allocated; | 56 | cg_proto->sockets_allocated = &tcp->tcp_sockets_allocated; |
89 | cg_proto->memcg = memcg; | 57 | cg_proto->memcg = memcg; |
90 | 58 | ||
91 | create_files: | 59 | return 0; |
92 | return cgroup_add_files(cgrp, ss, tcp_files, | ||
93 | ARRAY_SIZE(tcp_files)); | ||
94 | } | 60 | } |
95 | EXPORT_SYMBOL(tcp_init_cgroup); | 61 | EXPORT_SYMBOL(tcp_init_cgroup); |
96 | 62 | ||
97 | void tcp_destroy_cgroup(struct cgroup *cgrp) | 63 | void tcp_destroy_cgroup(struct mem_cgroup *memcg) |
98 | { | 64 | { |
99 | struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); | ||
100 | struct cg_proto *cg_proto; | 65 | struct cg_proto *cg_proto; |
101 | struct tcp_memcontrol *tcp; | 66 | struct tcp_memcontrol *tcp; |
102 | u64 val; | 67 | u64 val; |
@@ -270,3 +235,37 @@ void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx) | |||
270 | 235 | ||
271 | tcp->tcp_prot_mem[idx] = val; | 236 | tcp->tcp_prot_mem[idx] = val; |
272 | } | 237 | } |
238 | |||
239 | static struct cftype tcp_files[] = { | ||
240 | { | ||
241 | .name = "kmem.tcp.limit_in_bytes", | ||
242 | .write_string = tcp_cgroup_write, | ||
243 | .read_u64 = tcp_cgroup_read, | ||
244 | .private = RES_LIMIT, | ||
245 | }, | ||
246 | { | ||
247 | .name = "kmem.tcp.usage_in_bytes", | ||
248 | .read_u64 = tcp_cgroup_read, | ||
249 | .private = RES_USAGE, | ||
250 | }, | ||
251 | { | ||
252 | .name = "kmem.tcp.failcnt", | ||
253 | .private = RES_FAILCNT, | ||
254 | .trigger = tcp_cgroup_reset, | ||
255 | .read_u64 = tcp_cgroup_read, | ||
256 | }, | ||
257 | { | ||
258 | .name = "kmem.tcp.max_usage_in_bytes", | ||
259 | .private = RES_MAX_USAGE, | ||
260 | .trigger = tcp_cgroup_reset, | ||
261 | .read_u64 = tcp_cgroup_read, | ||
262 | }, | ||
263 | { } /* terminate */ | ||
264 | }; | ||
265 | |||
266 | static int __init tcp_memcontrol_init(void) | ||
267 | { | ||
268 | WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, tcp_files)); | ||
269 | return 0; | ||
270 | } | ||
271 | __initcall(tcp_memcontrol_init); | ||