summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-05-15 09:57:23 -0400
committerChristoph Hellwig <hch@lst.de>2018-05-16 01:23:35 -0400
commit3f3942aca6da351a12543aa776467791b63b3a78 (patch)
tree31030e086ea36920e07078ea2289b9b72c0b2939 /kernel/cgroup
parent44414d82cfe0f68cb59d0a42f599ccd893ae0032 (diff)
proc: introduce proc_create_single{,_data}
Variants of proc_create{,_data} that directly take a seq_file show callback and drastically reduces the boilerplate code in the callers. All trivial callers converted over. Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'kernel/cgroup')
-rw-r--r--kernel/cgroup/cgroup-internal.h2
-rw-r--r--kernel/cgroup/cgroup-v1.c14
-rw-r--r--kernel/cgroup/cgroup.c2
3 files changed, 3 insertions, 15 deletions
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index b928b27050c6..0808a33d16d3 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -218,9 +218,9 @@ extern const struct proc_ns_operations cgroupns_operations;
218 * cgroup-v1.c 218 * cgroup-v1.c
219 */ 219 */
220extern struct cftype cgroup1_base_files[]; 220extern struct cftype cgroup1_base_files[];
221extern const struct file_operations proc_cgroupstats_operations;
222extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops; 221extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops;
223 222
223int proc_cgroupstats_show(struct seq_file *m, void *v);
224bool cgroup1_ssid_disabled(int ssid); 224bool cgroup1_ssid_disabled(int ssid);
225void cgroup1_pidlist_destroy_all(struct cgroup *cgrp); 225void cgroup1_pidlist_destroy_all(struct cgroup *cgrp);
226void cgroup1_release_agent(struct work_struct *work); 226void cgroup1_release_agent(struct work_struct *work);
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index a2c05d2476ac..e06c97f3ed1a 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -682,7 +682,7 @@ struct cftype cgroup1_base_files[] = {
682}; 682};
683 683
684/* Display information about each subsystem and each hierarchy */ 684/* Display information about each subsystem and each hierarchy */
685static int proc_cgroupstats_show(struct seq_file *m, void *v) 685int proc_cgroupstats_show(struct seq_file *m, void *v)
686{ 686{
687 struct cgroup_subsys *ss; 687 struct cgroup_subsys *ss;
688 int i; 688 int i;
@@ -705,18 +705,6 @@ static int proc_cgroupstats_show(struct seq_file *m, void *v)
705 return 0; 705 return 0;
706} 706}
707 707
708static int cgroupstats_open(struct inode *inode, struct file *file)
709{
710 return single_open(file, proc_cgroupstats_show, NULL);
711}
712
713const struct file_operations proc_cgroupstats_operations = {
714 .open = cgroupstats_open,
715 .read = seq_read,
716 .llseek = seq_lseek,
717 .release = single_release,
718};
719
720/** 708/**
721 * cgroupstats_build - build and fill cgroupstats 709 * cgroupstats_build - build and fill cgroupstats
722 * @stats: cgroupstats to fill information into 710 * @stats: cgroupstats to fill information into
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index a662bfcbea0e..12883656e63e 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -5335,7 +5335,7 @@ int __init cgroup_init(void)
5335 WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup")); 5335 WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup"));
5336 WARN_ON(register_filesystem(&cgroup_fs_type)); 5336 WARN_ON(register_filesystem(&cgroup_fs_type));
5337 WARN_ON(register_filesystem(&cgroup2_fs_type)); 5337 WARN_ON(register_filesystem(&cgroup2_fs_type));
5338 WARN_ON(!proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations)); 5338 WARN_ON(!proc_create_single("cgroups", 0, NULL, proc_cgroupstats_show));
5339 5339
5340 return 0; 5340 return 0;
5341} 5341}