diff options
| -rw-r--r-- | block/blk-cgroup.c | 38 | ||||
| -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 |
4 files changed, 65 insertions, 83 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index ea84a23d5e68..60ef16d6d155 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
| @@ -28,34 +28,12 @@ static LIST_HEAD(blkio_list); | |||
| 28 | struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; | 28 | struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; |
| 29 | EXPORT_SYMBOL_GPL(blkio_root_cgroup); | 29 | EXPORT_SYMBOL_GPL(blkio_root_cgroup); |
| 30 | 30 | ||
| 31 | static struct cgroup_subsys_state *blkiocg_create(struct cgroup *); | ||
| 32 | static int blkiocg_can_attach(struct cgroup *, struct cgroup_taskset *); | ||
| 33 | static void blkiocg_attach(struct cgroup *, struct cgroup_taskset *); | ||
| 34 | static void blkiocg_destroy(struct cgroup *); | ||
| 35 | static int blkiocg_populate(struct cgroup_subsys *, struct cgroup *); | ||
| 36 | |||
| 37 | /* for encoding cft->private value on file */ | 31 | /* for encoding cft->private value on file */ |
| 38 | #define BLKIOFILE_PRIVATE(x, val) (((x) << 16) | (val)) | 32 | #define BLKIOFILE_PRIVATE(x, val) (((x) << 16) | (val)) |
| 39 | /* What policy owns the file, proportional or throttle */ | 33 | /* What policy owns the file, proportional or throttle */ |
| 40 | #define BLKIOFILE_POLICY(val) (((val) >> 16) & 0xffff) | 34 | #define BLKIOFILE_POLICY(val) (((val) >> 16) & 0xffff) |
| 41 | #define BLKIOFILE_ATTR(val) ((val) & 0xffff) | 35 | #define BLKIOFILE_ATTR(val) ((val) & 0xffff) |
| 42 | 36 | ||
| 43 | struct cgroup_subsys blkio_subsys = { | ||
| 44 | .name = "blkio", | ||
| 45 | .create = blkiocg_create, | ||
| 46 | .can_attach = blkiocg_can_attach, | ||
| 47 | .attach = blkiocg_attach, | ||
| 48 | .destroy = blkiocg_destroy, | ||
| 49 | .populate = blkiocg_populate, | ||
| 50 | #ifdef CONFIG_BLK_CGROUP | ||
| 51 | /* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */ | ||
| 52 | .subsys_id = blkio_subsys_id, | ||
| 53 | #endif | ||
| 54 | .use_id = 1, | ||
| 55 | .module = THIS_MODULE, | ||
| 56 | }; | ||
| 57 | EXPORT_SYMBOL_GPL(blkio_subsys); | ||
| 58 | |||
| 59 | static inline void blkio_policy_insert_node(struct blkio_cgroup *blkcg, | 37 | static inline void blkio_policy_insert_node(struct blkio_cgroup *blkcg, |
| 60 | struct blkio_policy_node *pn) | 38 | struct blkio_policy_node *pn) |
| 61 | { | 39 | { |
| @@ -1658,6 +1636,22 @@ static void blkiocg_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) | |||
| 1658 | } | 1636 | } |
| 1659 | } | 1637 | } |
| 1660 | 1638 | ||
| 1639 | struct cgroup_subsys blkio_subsys = { | ||
| 1640 | .name = "blkio", | ||
| 1641 | .create = blkiocg_create, | ||
| 1642 | .can_attach = blkiocg_can_attach, | ||
| 1643 | .attach = blkiocg_attach, | ||
| 1644 | .destroy = blkiocg_destroy, | ||
| 1645 | .populate = blkiocg_populate, | ||
| 1646 | #ifdef CONFIG_BLK_CGROUP | ||
| 1647 | /* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */ | ||
| 1648 | .subsys_id = blkio_subsys_id, | ||
| 1649 | #endif | ||
| 1650 | .use_id = 1, | ||
| 1651 | .module = THIS_MODULE, | ||
| 1652 | }; | ||
| 1653 | EXPORT_SYMBOL_GPL(blkio_subsys); | ||
| 1654 | |||
| 1661 | void blkio_policy_register(struct blkio_policy_type *blkiop) | 1655 | void blkio_policy_register(struct blkio_policy_type *blkiop) |
| 1662 | { | 1656 | { |
| 1663 | spin_lock(&blkio_list_lock); | 1657 | spin_lock(&blkio_list_lock); |
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; |
