Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 006f4ac4 authored by Zefan Li's avatar Zefan Li Committed by Tejun Heo
Browse files

cgroup: simplify proc_cgroup_show()



Use the ONE macro instead of REG, and we can simplify proc_cgroup_show().

Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 971ff493
Loading
Loading
Loading
Loading
+2 −17
Original line number Original line Diff line number Diff line
@@ -376,21 +376,6 @@ static const struct file_operations proc_lstats_operations = {


#endif
#endif


#ifdef CONFIG_CGROUPS
static int cgroup_open(struct inode *inode, struct file *file)
{
	struct pid *pid = PROC_I(inode)->pid;
	return single_open(file, proc_cgroup_show, pid);
}

static const struct file_operations proc_cgroup_operations = {
	.open		= cgroup_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};
#endif

#ifdef CONFIG_PROC_PID_CPUSET
#ifdef CONFIG_PROC_PID_CPUSET


static int cpuset_open(struct inode *inode, struct file *file)
static int cpuset_open(struct inode *inode, struct file *file)
@@ -2576,7 +2561,7 @@ static const struct pid_entry tgid_base_stuff[] = {
	REG("cpuset",     S_IRUGO, proc_cpuset_operations),
	REG("cpuset",     S_IRUGO, proc_cpuset_operations),
#endif
#endif
#ifdef CONFIG_CGROUPS
#ifdef CONFIG_CGROUPS
	REG("cgroup",  S_IRUGO, proc_cgroup_operations),
	ONE("cgroup",  S_IRUGO, proc_cgroup_show),
#endif
#endif
	ONE("oom_score",  S_IRUGO, proc_oom_score),
	ONE("oom_score",  S_IRUGO, proc_oom_score),
	REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adj_operations),
	REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adj_operations),
@@ -2922,7 +2907,7 @@ static const struct pid_entry tid_base_stuff[] = {
	REG("cpuset",    S_IRUGO, proc_cpuset_operations),
	REG("cpuset",    S_IRUGO, proc_cpuset_operations),
#endif
#endif
#ifdef CONFIG_CGROUPS
#ifdef CONFIG_CGROUPS
	REG("cgroup",  S_IRUGO, proc_cgroup_operations),
	ONE("cgroup",  S_IRUGO, proc_cgroup_show),
#endif
#endif
	ONE("oom_score", S_IRUGO, proc_oom_score),
	ONE("oom_score", S_IRUGO, proc_oom_score),
	REG("oom_adj",   S_IRUGO|S_IWUSR, proc_oom_adj_operations),
	REG("oom_adj",   S_IRUGO|S_IWUSR, proc_oom_adj_operations),
+2 −1
Original line number Original line Diff line number Diff line
@@ -37,7 +37,8 @@ extern void cgroup_exit(struct task_struct *p);
extern int cgroupstats_build(struct cgroupstats *stats,
extern int cgroupstats_build(struct cgroupstats *stats,
				struct dentry *dentry);
				struct dentry *dentry);


extern int proc_cgroup_show(struct seq_file *, void *);
extern int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
			    struct pid *pid, struct task_struct *tsk);


/* define the enumeration of all cgroup subsystems */
/* define the enumeration of all cgroup subsystems */
#define SUBSYS(_x) _x ## _cgrp_id,
#define SUBSYS(_x) _x ## _cgrp_id,
+3 −15
Original line number Original line Diff line number Diff line
@@ -5030,12 +5030,9 @@ core_initcall(cgroup_wq_init);
 *  - Print task's cgroup paths into seq_file, one line for each hierarchy
 *  - Print task's cgroup paths into seq_file, one line for each hierarchy
 *  - Used for /proc/<pid>/cgroup.
 *  - Used for /proc/<pid>/cgroup.
 */
 */

int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
/* TODO: Use a proper seq_file iterator */
		     struct pid *pid, struct task_struct *tsk)
int proc_cgroup_show(struct seq_file *m, void *v)
{
{
	struct pid *pid;
	struct task_struct *tsk;
	char *buf, *path;
	char *buf, *path;
	int retval;
	int retval;
	struct cgroup_root *root;
	struct cgroup_root *root;
@@ -5045,14 +5042,6 @@ int proc_cgroup_show(struct seq_file *m, void *v)
	if (!buf)
	if (!buf)
		goto out;
		goto out;


	retval = -ESRCH;
	pid = m->private;
	tsk = get_pid_task(pid, PIDTYPE_PID);
	if (!tsk)
		goto out_free;

	retval = 0;

	mutex_lock(&cgroup_mutex);
	mutex_lock(&cgroup_mutex);
	down_read(&css_set_rwsem);
	down_read(&css_set_rwsem);


@@ -5082,11 +5071,10 @@ int proc_cgroup_show(struct seq_file *m, void *v)
		seq_putc(m, '\n');
		seq_putc(m, '\n');
	}
	}


	retval = 0;
out_unlock:
out_unlock:
	up_read(&css_set_rwsem);
	up_read(&css_set_rwsem);
	mutex_unlock(&cgroup_mutex);
	mutex_unlock(&cgroup_mutex);
	put_task_struct(tsk);
out_free:
	kfree(buf);
	kfree(buf);
out:
out:
	return retval;
	return retval;