Skip to content

Commit 52de477

Browse files
lizf-oshtejun
authored andcommitted
cpuset: simplify proc_cpuset_show()
Use the ONE macro instead of REG, and we can simplify proc_cpuset_show(). Signed-off-by: Zefan Li <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 006f4ac commit 52de477

3 files changed

Lines changed: 7 additions & 31 deletions

File tree

‎fs/proc/base.c‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -376,22 +376,6 @@ static const struct file_operations proc_lstats_operations = {
376376

377377
#endif
378378

379-
#ifdef CONFIG_PROC_PID_CPUSET
380-
381-
static int cpuset_open(struct inode *inode, struct file *file)
382-
{
383-
struct pid *pid = PROC_I(inode)->pid;
384-
return single_open(file, proc_cpuset_show, pid);
385-
}
386-
387-
static const struct file_operations proc_cpuset_operations = {
388-
.open = cpuset_open,
389-
.read = seq_read,
390-
.llseek = seq_lseek,
391-
.release = single_release,
392-
};
393-
#endif
394-
395379
static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
396380
struct pid *pid, struct task_struct *task)
397381
{
@@ -2558,7 +2542,7 @@ static const struct pid_entry tgid_base_stuff[] = {
25582542
REG("latency", S_IRUGO, proc_lstats_operations),
25592543
#endif
25602544
#ifdef CONFIG_PROC_PID_CPUSET
2561-
REG("cpuset", S_IRUGO, proc_cpuset_operations),
2545+
ONE("cpuset", S_IRUGO, proc_cpuset_show),
25622546
#endif
25632547
#ifdef CONFIG_CGROUPS
25642548
ONE("cgroup", S_IRUGO, proc_cgroup_show),
@@ -2904,7 +2888,7 @@ static const struct pid_entry tid_base_stuff[] = {
29042888
REG("latency", S_IRUGO, proc_lstats_operations),
29052889
#endif
29062890
#ifdef CONFIG_PROC_PID_CPUSET
2907-
REG("cpuset", S_IRUGO, proc_cpuset_operations),
2891+
ONE("cpuset", S_IRUGO, proc_cpuset_show),
29082892
#endif
29092893
#ifdef CONFIG_CGROUPS
29102894
ONE("cgroup", S_IRUGO, proc_cgroup_show),

‎include/linux/cpuset.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ extern void __cpuset_memory_pressure_bump(void);
8686

8787
extern void cpuset_task_status_allowed(struct seq_file *m,
8888
struct task_struct *task);
89-
extern int proc_cpuset_show(struct seq_file *, void *);
89+
extern int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
90+
struct pid *pid, struct task_struct *tsk);
9091

9192
extern int cpuset_mem_spread_node(void);
9293
extern int cpuset_slab_spread_node(void);

‎kernel/cpuset.c‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,10 +2729,9 @@ void __cpuset_memory_pressure_bump(void)
27292729
* and we take cpuset_mutex, keeping cpuset_attach() from changing it
27302730
* anyway.
27312731
*/
2732-
int proc_cpuset_show(struct seq_file *m, void *unused_v)
2732+
int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
2733+
struct pid *pid, struct task_struct *tsk)
27332734
{
2734-
struct pid *pid;
2735-
struct task_struct *tsk;
27362735
char *buf, *p;
27372736
struct cgroup_subsys_state *css;
27382737
int retval;
@@ -2742,24 +2741,16 @@ int proc_cpuset_show(struct seq_file *m, void *unused_v)
27422741
if (!buf)
27432742
goto out;
27442743

2745-
retval = -ESRCH;
2746-
pid = m->private;
2747-
tsk = get_pid_task(pid, PIDTYPE_PID);
2748-
if (!tsk)
2749-
goto out_free;
2750-
27512744
retval = -ENAMETOOLONG;
27522745
rcu_read_lock();
27532746
css = task_css(tsk, cpuset_cgrp_id);
27542747
p = cgroup_path(css->cgroup, buf, PATH_MAX);
27552748
rcu_read_unlock();
27562749
if (!p)
2757-
goto out_put_task;
2750+
goto out_free;
27582751
seq_puts(m, p);
27592752
seq_putc(m, '\n');
27602753
retval = 0;
2761-
out_put_task:
2762-
put_task_struct(tsk);
27632754
out_free:
27642755
kfree(buf);
27652756
out:

0 commit comments

Comments
 (0)