Proc: move proc fs hooks from cpuset.c to proc/fs/base.c
Subsystems (2)
PATCH 1/1 Proc: move proc fs hooks from cpuset.c to proc/fs/base.c
From: Paul Jackson <[email protected]>
Move the generic proc file operations support for /proc/<pid>/cpuset from kernel/cpuset.c to fs/proc/base.c.
Leave behind in kernel/cpuset.c, now as an exported function, the cpuset specific support for this /proc/<pid>/cpuset file, which writes the cpuset pathname of a tasks cpuset into a seq_file.
The motivation for this move is to put proc stuff in fs/proc, while keeping cpuset stuff in kernel/cpuset.c.
---
fs/proc/base.c | 16 ++++++++++++++++ include/linux/cpuset.h | 3 ++- kernel/cpuset.c | 17 ++--------------- 3 files changed, 20 insertions(+), 16 deletions(-)
kernel/cpuset.c +2 -15
@@ -2368,7 +2368,7 @@ void __cpuset_memory_pressure_bump(void) }/* -* proc_cpuset_show() +* cpuset_proc_show_path() * - Print tasks cpuset path into seq_file. * - Used for /proc/<pid>/cpuset. * - No need to task_lock(tsk) on this tsk->cpuset reference, as it
@@ -2377,7 +2377,7 @@ void __cpuset_memory_pressure_bump(void)* anyway. */ -static int proc_cpuset_show (struct seq_file *m,void *v) +int cpuset_proc_show_path (struct seq_file *m,void *v) {struct cpuset *cs;struct task_ref *tref;
@@ -2416,19 +2416,6 @@ out:return retval; } -static int cpuset_open (struct inode *inode,struct file *file) -{ -struct task_ref *tref =PROC_I (inode)->tref; -return single_open (file, proc_cpuset_show, tref); -} - -struct file_operations proc_cpuset_operations = { - .open = cpuset_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -/* Display task cpus_allowed, mems_allowed in /proc/<pid>/status file. */ char *cpuset_task_status_allowed (struct task_struct *task,char *buffer) {
fs/proc/base.c +16 -0
@@ -695,6 +695,22 @@ static struct file_operations proc_info_ .read = proc_info_read, }; +#ifdef CONFIG_CPUSETS +static int cpuset_open (struct inode *inode,struct file *file) +{ +struct task_ref *tref =PROC_I (inode)->tref; + +return single_open (file, cpuset_proc_show_path, tref); +} + +static struct file_operations proc_cpuset_operations = { + .open = cpuset_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +#endif +static int mem_open (struct inode * inode,struct file * file) { file->private_data = (void *)((long )current->self_exec_id);
include/linux/cpuset.h +2 -1
@@ -11,6 +11,7 @@#include <linux/sched.h> #include <linux/cpumask.h> #include <linux/nodemask.h> +#include <linux/seq_file.h> #ifdef CONFIG_CPUSETS
@@ -45,7 +46,7 @@ extern int cpuset_excl_nodes_overlap(conextern int cpuset_memory_pressure_enabled;extern void __cpuset_memory_pressure_bump (void ); -extern struct file_operations proc_cpuset_operations; +int cpuset_proc_show_path (struct seq_file *m,void *v);extern char *cpuset_task_status_allowed (struct task_struct *task,char *buffer);extern void cpuset_lock (void );
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373Quoted 11 lines · Paul Jackson
From: Paul Jackson <[email protected]>
Move the generic proc file operations support for /proc/<pid>/cpuset from
kernel/cpuset.ctofs/proc/base.c.Leave behind in
kernel/cpuset.c, now as an exported function, the cpuset specific support for this /proc/<pid>/cpuset file, which writes the cpuset pathname of a tasks cpuset into aseq_file.The motivation for this move is to put proc stuff in fs/proc, while keeping cpuset stuff in
kernel/cpuset.c.
Seems pointless. This just increases #ifdef churn for no gain.
Quoted 1 line
Seems pointless. This just increases #ifdef churn for no gain.
Take a look at fs/proc/base.c. That's how pretty much all the other proc hooks are done, with ifdef's around their proc hooks.
ifdef minimization is a good goal, yes.
But uniformity of practice is another good goal.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.925.600.0401Quoted 8 lines · Paul Jackson
Quoted 1 line
Seems pointless. This just increases #ifdef churn for no gain.
Take a look at
fs/proc/base.c. That's how pretty much all the other proc hooks are done, with ifdef's around their proc hooks.ifdef minimization is a good goal, yes.
But uniformity of practice is another good goal.
Agreed. However the direction I am gradually moving fs/proc/base.c is the opposite. Moving things out of it as much as is reasonably possible.
I already moved out all of the /proc/<pid>/?maps code into fs/proc/task_mmu.c
I think the more important piece of uniform practice is to put all of the operations structures and methods together in one file so that it is easier to look between them, when making modifications especially since cpuset_open and proc_cpuset_show are interdependent.
Eric
Quoted 2 lines
Agreed. However the direction I am gradually moving
fs/proc/base.cis the opposite.
Oh - ok fine.
I had seen something from Andrew a couple of days ago that led me to a different understanding in this particular case.
Andrew - kill this patch (unless you know better.)
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.925.600.0401Quoted 8 lines · Paul Jackson
Quoted 2 lines
Agreed. However the direction I am gradually moving
fs/proc/base.cis the opposite.Oh - ok fine.
I had seen something from Andrew a couple of days ago that led me to a different understanding in this particular case.
As we increase the number of namespaces that we allow multiple instances of in linux. More of the files that are in /proc need to become per process, like /proc/mounts did.
I mentioned that to Andrew and I think the message got a little garbled.
Eric