diff mbox

[net-next,1/2] procfs: split proc_pid_status function

Message ID 1403011478-20206-1-git-send-email-p.wilczek@samsung.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Piotr Wilczek June 17, 2014, 1:24 p.m. UTC
Split proc_pid_status function to get proces status with task locked elswere.
This allows to collect multiple process information with a single task lock.

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
---
 fs/proc/array.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Comments

David Miller June 20, 2014, 4:22 a.m. UTC | #1
From: Piotr Wilczek <p.wilczek@samsung.com>
Date: Tue, 17 Jun 2014 15:24:37 +0200

> +int proc_pid_status_mm(struct seq_file *m, struct pid_namespace *ns,
> +		       struct pid *pid, struct task_struct *task,
> +		       struct mm_struct *mm)
>  {
> -	struct mm_struct *mm = get_task_mm(task);
> -
>  	task_name(m, task);
>  	task_state(m, ns, pid, task);
>  
> -	if (mm) {
> +	if (mm)
>  		task_mem(m, mm);
> -		mmput(mm);

Neither proc_pid_status() nor the invocations in your second patch ever
invoke this function with a NULL mm, therefore you should never try to
explicitly handle the case.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 64db2bc..dcf9a28 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -356,24 +356,36 @@  static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
 	seq_putc(m, '\n');
 }
 
-int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
-			struct pid *pid, struct task_struct *task)
+int proc_pid_status_mm(struct seq_file *m, struct pid_namespace *ns,
+		       struct pid *pid, struct task_struct *task,
+		       struct mm_struct *mm)
 {
-	struct mm_struct *mm = get_task_mm(task);
-
 	task_name(m, task);
 	task_state(m, ns, pid, task);
 
-	if (mm) {
+	if (mm)
 		task_mem(m, mm);
-		mmput(mm);
-	}
+
 	task_sig(m, task);
 	task_cap(m, task);
 	task_seccomp(m, task);
 	task_cpus_allowed(m, task);
 	cpuset_task_status_allowed(m, task);
 	task_context_switch_counts(m, task);
+
+	return 0;
+}
+
+int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
+		    struct pid *pid, struct task_struct *task)
+{
+	struct mm_struct *mm = get_task_mm(task);
+
+	if (mm) {
+		proc_pid_status_mm(m, ns, pid, task, mm);
+		mmput(mm);
+	}
+
 	return 0;
 }