aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-12-10 18:45:15 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 20:41:09 -0500
commitb0fafc11115938a3215723f37e8e9cc6a94b05b0 (patch)
treed2bf204d75d4bbde98e9a3b83b812c3c8bceda20 /fs/proc/array.c
parent0f4a0d53f20c76a70cb5b69b6aa237de2107e171 (diff)
proc: task_state: move the main seq_printf() outside of rcu_read_lock()
task_state() does seq_printf() under rcu_read_lock(), but this is only needed for task_tgid_nr_ns() and task_numa_group_id(). We can calculate tgid/ngid and drop rcu lock. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Aaron Tomlin <atomlin@redhat.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com>, Cc: Sterling Alexander <stalexan@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Roland McGrath <roland@hack.frob.com> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/array.c')
-rw-r--r--fs/proc/array.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 7c8d9aecb070..800e30f8f284 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -158,7 +158,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
158 struct group_info *group_info; 158 struct group_info *group_info;
159 int g; 159 int g;
160 const struct cred *cred; 160 const struct cred *cred;
161 pid_t ppid, tpid; 161 pid_t ppid, tpid, tgid, ngid;
162 unsigned int max_fds = 0; 162 unsigned int max_fds = 0;
163 163
164 rcu_read_lock(); 164 rcu_read_lock();
@@ -170,12 +170,16 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
170 if (tracer) 170 if (tracer)
171 tpid = task_pid_nr_ns(tracer, ns); 171 tpid = task_pid_nr_ns(tracer, ns);
172 } 172 }
173
174 tgid = task_tgid_nr_ns(p, ns);
175 ngid = task_numa_group_id(p);
173 cred = get_task_cred(p); 176 cred = get_task_cred(p);
174 177
175 task_lock(p); 178 task_lock(p);
176 if (p->files) 179 if (p->files)
177 max_fds = files_fdtable(p->files)->max_fds; 180 max_fds = files_fdtable(p->files)->max_fds;
178 task_unlock(p); 181 task_unlock(p);
182 rcu_read_unlock();
179 183
180 seq_printf(m, 184 seq_printf(m,
181 "State:\t%s\n" 185 "State:\t%s\n"
@@ -188,10 +192,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
188 "Gid:\t%d\t%d\t%d\t%d\n" 192 "Gid:\t%d\t%d\t%d\t%d\n"
189 "FDSize:\t%d\nGroups:\t", 193 "FDSize:\t%d\nGroups:\t",
190 get_task_state(p), 194 get_task_state(p),
191 task_tgid_nr_ns(p, ns), 195 tgid, ngid, pid_nr_ns(pid, ns), ppid, tpid,
192 task_numa_group_id(p),
193 pid_nr_ns(pid, ns),
194 ppid, tpid,
195 from_kuid_munged(user_ns, cred->uid), 196 from_kuid_munged(user_ns, cred->uid),
196 from_kuid_munged(user_ns, cred->euid), 197 from_kuid_munged(user_ns, cred->euid),
197 from_kuid_munged(user_ns, cred->suid), 198 from_kuid_munged(user_ns, cred->suid),
@@ -201,7 +202,6 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
201 from_kgid_munged(user_ns, cred->sgid), 202 from_kgid_munged(user_ns, cred->sgid),
202 from_kgid_munged(user_ns, cred->fsgid), 203 from_kgid_munged(user_ns, cred->fsgid),
203 max_fds); 204 max_fds);
204 rcu_read_unlock();
205 205
206 group_info = cred->group_info; 206 group_info = cred->group_info;
207 for (g = 0; g < group_info->ngroups; g++) 207 for (g = 0; g < group_info->ngroups; g++)