Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cgroup: convert all non-memcg controllers to the new cftype interface

Convert debug, freezer, cpuset, cpu_cgroup, cpuacct, net_prio, blkio,
net_cls and device controllers to use the new cftype based interface.
Termination entry is added to cftype arrays and populate callbacks are
replaced with cgroup_subsys->base_cftypes initializations.

This is functionally identical transformation. There shouldn't be any
visible behavior change.

memcg is rather special and will be converted separately.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <paul@paulmenage.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Vivek Goyal <vgoyal@redhat.com>

Tejun Heo 4baf6e33 676f7c8f

+29 -76
+2 -7
block/blk-cgroup.c
··· 1515 1515 .read_map = blkiocg_file_read_map, 1516 1516 }, 1517 1517 #endif 1518 + { } /* terminate */ 1518 1519 }; 1519 - 1520 - static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup) 1521 - { 1522 - return cgroup_add_files(cgroup, subsys, blkio_files, 1523 - ARRAY_SIZE(blkio_files)); 1524 - } 1525 1520 1526 1521 static void blkiocg_destroy(struct cgroup *cgroup) 1527 1522 { ··· 1637 1642 .can_attach = blkiocg_can_attach, 1638 1643 .attach = blkiocg_attach, 1639 1644 .destroy = blkiocg_destroy, 1640 - .populate = blkiocg_populate, 1641 1645 #ifdef CONFIG_BLK_CGROUP 1642 1646 /* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */ 1643 1647 .subsys_id = blkio_subsys_id, 1644 1648 #endif 1649 + .base_cftypes = blkio_files, 1645 1650 .use_id = 1, 1646 1651 .module = THIS_MODULE, 1647 1652 };
+3 -7
kernel/cgroup.c
··· 5349 5349 .name = "releasable", 5350 5350 .read_u64 = releasable_read, 5351 5351 }, 5352 - }; 5353 5352 5354 - static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont) 5355 - { 5356 - return cgroup_add_files(cont, ss, debug_files, 5357 - ARRAY_SIZE(debug_files)); 5358 - } 5353 + { } /* terminate */ 5354 + }; 5359 5355 5360 5356 struct cgroup_subsys debug_subsys = { 5361 5357 .name = "debug", 5362 5358 .create = debug_create, 5363 5359 .destroy = debug_destroy, 5364 - .populate = debug_populate, 5365 5360 .subsys_id = debug_subsys_id, 5361 + .base_cftypes = debug_files, 5366 5362 }; 5367 5363 #endif /* CONFIG_CGROUP_DEBUG */
+3 -8
kernel/cgroup_freezer.c
··· 358 358 static struct cftype files[] = { 359 359 { 360 360 .name = "state", 361 + .flags = CFTYPE_NOT_ON_ROOT, 361 362 .read_seq_string = freezer_read, 362 363 .write_string = freezer_write, 363 364 }, 365 + { } /* terminate */ 364 366 }; 365 - 366 - static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup) 367 - { 368 - if (!cgroup->parent) 369 - return 0; 370 - return cgroup_add_files(cgroup, ss, files, ARRAY_SIZE(files)); 371 - } 372 367 373 368 struct cgroup_subsys freezer_subsys = { 374 369 .name = "freezer", 375 370 .create = freezer_create, 376 371 .destroy = freezer_destroy, 377 - .populate = freezer_populate, 378 372 .subsys_id = freezer_subsys_id, 379 373 .can_attach = freezer_can_attach, 380 374 .fork = freezer_fork, 375 + .base_cftypes = files, 381 376 };
+11 -22
kernel/cpuset.c
··· 1765 1765 .write_u64 = cpuset_write_u64, 1766 1766 .private = FILE_SPREAD_SLAB, 1767 1767 }, 1768 + 1769 + { 1770 + .name = "memory_pressure_enabled", 1771 + .flags = CFTYPE_ONLY_ON_ROOT, 1772 + .read_u64 = cpuset_read_u64, 1773 + .write_u64 = cpuset_write_u64, 1774 + .private = FILE_MEMORY_PRESSURE_ENABLED, 1775 + }, 1776 + 1777 + { } /* terminate */ 1768 1778 }; 1769 - 1770 - static struct cftype cft_memory_pressure_enabled = { 1771 - .name = "memory_pressure_enabled", 1772 - .read_u64 = cpuset_read_u64, 1773 - .write_u64 = cpuset_write_u64, 1774 - .private = FILE_MEMORY_PRESSURE_ENABLED, 1775 - }; 1776 - 1777 - static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont) 1778 - { 1779 - int err; 1780 - 1781 - err = cgroup_add_files(cont, ss, files, ARRAY_SIZE(files)); 1782 - if (err) 1783 - return err; 1784 - /* memory_pressure_enabled is in root cpuset only */ 1785 - if (!cont->parent) 1786 - err = cgroup_add_file(cont, ss, 1787 - &cft_memory_pressure_enabled); 1788 - return err; 1789 - } 1790 1779 1791 1780 /* 1792 1781 * post_clone() is called during cgroup_create() when the ··· 1876 1887 .destroy = cpuset_destroy, 1877 1888 .can_attach = cpuset_can_attach, 1878 1889 .attach = cpuset_attach, 1879 - .populate = cpuset_populate, 1880 1890 .post_clone = cpuset_post_clone, 1881 1891 .subsys_id = cpuset_subsys_id, 1892 + .base_cftypes = files, 1882 1893 .early_init = 1, 1883 1894 }; 1884 1895
+4 -12
kernel/sched/core.c
··· 7970 7970 .write_u64 = cpu_rt_period_write_uint, 7971 7971 }, 7972 7972 #endif 7973 + { } /* terminate */ 7973 7974 }; 7974 - 7975 - static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont) 7976 - { 7977 - return cgroup_add_files(cont, ss, cpu_files, ARRAY_SIZE(cpu_files)); 7978 - } 7979 7975 7980 7976 struct cgroup_subsys cpu_cgroup_subsys = { 7981 7977 .name = "cpu", ··· 7980 7984 .can_attach = cpu_cgroup_can_attach, 7981 7985 .attach = cpu_cgroup_attach, 7982 7986 .exit = cpu_cgroup_exit, 7983 - .populate = cpu_cgroup_populate, 7984 7987 .subsys_id = cpu_cgroup_subsys_id, 7988 + .base_cftypes = cpu_files, 7985 7989 .early_init = 1, 7986 7990 }; 7987 7991 ··· 8166 8170 .name = "stat", 8167 8171 .read_map = cpuacct_stats_show, 8168 8172 }, 8173 + { } /* terminate */ 8169 8174 }; 8170 - 8171 - static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) 8172 - { 8173 - return cgroup_add_files(cgrp, ss, files, ARRAY_SIZE(files)); 8174 - } 8175 8175 8176 8176 /* 8177 8177 * charge this task's execution time to its accounting group. ··· 8200 8208 .name = "cpuacct", 8201 8209 .create = cpuacct_create, 8202 8210 .destroy = cpuacct_destroy, 8203 - .populate = cpuacct_populate, 8204 8211 .subsys_id = cpuacct_subsys_id, 8212 + .base_cftypes = files, 8205 8213 }; 8206 8214 #endif /* CONFIG_CGROUP_CPUACCT */
+2 -6
net/core/netprio_cgroup.c
··· 242 242 .read_map = read_priomap, 243 243 .write_string = write_priomap, 244 244 }, 245 + { } /* terminate */ 245 246 }; 246 - 247 - static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) 248 - { 249 - return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); 250 - } 251 247 252 248 struct cgroup_subsys net_prio_subsys = { 253 249 .name = "net_prio", 254 250 .create = cgrp_create, 255 251 .destroy = cgrp_destroy, 256 - .populate = cgrp_populate, 257 252 #ifdef CONFIG_NETPRIO_CGROUP 258 253 .subsys_id = net_prio_subsys_id, 259 254 #endif 255 + .base_cftypes = ss_files, 260 256 .module = THIS_MODULE 261 257 }; 262 258
+2 -6
net/sched/cls_cgroup.c
··· 70 70 .read_u64 = read_classid, 71 71 .write_u64 = write_classid, 72 72 }, 73 + { } /* terminate */ 73 74 }; 74 - 75 - static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) 76 - { 77 - return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); 78 - } 79 75 80 76 struct cgroup_subsys net_cls_subsys = { 81 77 .name = "net_cls", 82 78 .create = cgrp_create, 83 79 .destroy = cgrp_destroy, 84 - .populate = cgrp_populate, 85 80 #ifdef CONFIG_NET_CLS_CGROUP 86 81 .subsys_id = net_cls_subsys_id, 87 82 #endif 83 + .base_cftypes = ss_files, 88 84 .module = THIS_MODULE, 89 85 }; 90 86
+2 -8
security/device_cgroup.c
··· 447 447 .read_seq_string = devcgroup_seq_read, 448 448 .private = DEVCG_LIST, 449 449 }, 450 + { } /* terminate */ 450 451 }; 451 - 452 - static int devcgroup_populate(struct cgroup_subsys *ss, 453 - struct cgroup *cgroup) 454 - { 455 - return cgroup_add_files(cgroup, ss, dev_cgroup_files, 456 - ARRAY_SIZE(dev_cgroup_files)); 457 - } 458 452 459 453 struct cgroup_subsys devices_subsys = { 460 454 .name = "devices", 461 455 .can_attach = devcgroup_can_attach, 462 456 .create = devcgroup_create, 463 457 .destroy = devcgroup_destroy, 464 - .populate = devcgroup_populate, 465 458 .subsys_id = devices_subsys_id, 459 + .base_cftypes = dev_cgroup_files, 466 460 }; 467 461 468 462 int __devcgroup_inode_permission(struct inode *inode, int mask)