diff options
| -rw-r--r-- | kernel/cgroup/cgroup.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index d6ed725f36d9..eed92ed624e5 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
| @@ -5832,3 +5832,64 @@ int cgroup_bpf_update(struct cgroup *cgrp, struct bpf_prog *prog, | |||
| 5832 | return ret; | 5832 | return ret; |
| 5833 | } | 5833 | } |
| 5834 | #endif /* CONFIG_CGROUP_BPF */ | 5834 | #endif /* CONFIG_CGROUP_BPF */ |
| 5835 | |||
| 5836 | #ifdef CONFIG_SYSFS | ||
| 5837 | static ssize_t show_delegatable_files(struct cftype *files, char *buf, | ||
| 5838 | ssize_t size, const char *prefix) | ||
| 5839 | { | ||
| 5840 | struct cftype *cft; | ||
| 5841 | ssize_t ret = 0; | ||
| 5842 | |||
| 5843 | for (cft = files; cft && cft->name[0] != '\0'; cft++) { | ||
| 5844 | if (!(cft->flags & CFTYPE_NS_DELEGATABLE)) | ||
| 5845 | continue; | ||
| 5846 | |||
| 5847 | if (prefix) | ||
| 5848 | ret += snprintf(buf + ret, size - ret, "%s.", prefix); | ||
| 5849 | |||
| 5850 | ret += snprintf(buf + ret, size - ret, "%s\n", cft->name); | ||
| 5851 | |||
| 5852 | if (unlikely(ret >= size)) { | ||
| 5853 | WARN_ON(1); | ||
| 5854 | break; | ||
| 5855 | } | ||
| 5856 | } | ||
| 5857 | |||
| 5858 | return ret; | ||
| 5859 | } | ||
| 5860 | |||
| 5861 | static ssize_t delegate_show(struct kobject *kobj, struct kobj_attribute *attr, | ||
| 5862 | char *buf) | ||
| 5863 | { | ||
| 5864 | struct cgroup_subsys *ss; | ||
| 5865 | int ssid; | ||
| 5866 | ssize_t ret = 0; | ||
| 5867 | |||
| 5868 | ret = show_delegatable_files(cgroup_base_files, buf, PAGE_SIZE - ret, | ||
| 5869 | NULL); | ||
| 5870 | |||
| 5871 | for_each_subsys(ss, ssid) | ||
| 5872 | ret += show_delegatable_files(ss->dfl_cftypes, buf + ret, | ||
| 5873 | PAGE_SIZE - ret, | ||
| 5874 | cgroup_subsys_name[ssid]); | ||
| 5875 | |||
| 5876 | return ret; | ||
| 5877 | } | ||
| 5878 | static struct kobj_attribute cgroup_delegate_attr = __ATTR_RO(delegate); | ||
| 5879 | |||
| 5880 | static struct attribute *cgroup_sysfs_attrs[] = { | ||
| 5881 | &cgroup_delegate_attr.attr, | ||
| 5882 | NULL, | ||
| 5883 | }; | ||
| 5884 | |||
| 5885 | static const struct attribute_group cgroup_sysfs_attr_group = { | ||
| 5886 | .attrs = cgroup_sysfs_attrs, | ||
| 5887 | .name = "cgroup", | ||
| 5888 | }; | ||
| 5889 | |||
| 5890 | static int __init cgroup_sysfs_init(void) | ||
| 5891 | { | ||
| 5892 | return sysfs_create_group(kernel_kobj, &cgroup_sysfs_attr_group); | ||
| 5893 | } | ||
| 5894 | subsys_initcall(cgroup_sysfs_init); | ||
| 5895 | #endif /* CONFIG_SYSFS */ | ||
