Commit b0fafc11115938a3215723f37e8e9cc6a94b05b0
Committed by
Linus Torvalds
1 parent
0f4a0d53f2
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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>
Showing 1 changed file with 6 additions and 6 deletions Side-by-side Diff
fs/proc/array.c
... | ... | @@ -158,7 +158,7 @@ |
158 | 158 | struct group_info *group_info; |
159 | 159 | int g; |
160 | 160 | const struct cred *cred; |
161 | - pid_t ppid, tpid; | |
161 | + pid_t ppid, tpid, tgid, ngid; | |
162 | 162 | unsigned int max_fds = 0; |
163 | 163 | |
164 | 164 | rcu_read_lock(); |
165 | 165 | |
... | ... | @@ -170,12 +170,16 @@ |
170 | 170 | if (tracer) |
171 | 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 | 176 | cred = get_task_cred(p); |
174 | 177 | |
175 | 178 | task_lock(p); |
176 | 179 | if (p->files) |
177 | 180 | max_fds = files_fdtable(p->files)->max_fds; |
178 | 181 | task_unlock(p); |
182 | + rcu_read_unlock(); | |
179 | 183 | |
180 | 184 | seq_printf(m, |
181 | 185 | "State:\t%s\n" |
... | ... | @@ -188,10 +192,7 @@ |
188 | 192 | "Gid:\t%d\t%d\t%d\t%d\n" |
189 | 193 | "FDSize:\t%d\nGroups:\t", |
190 | 194 | get_task_state(p), |
191 | - task_tgid_nr_ns(p, ns), | |
192 | - task_numa_group_id(p), | |
193 | - pid_nr_ns(pid, ns), | |
194 | - ppid, tpid, | |
195 | + tgid, ngid, pid_nr_ns(pid, ns), ppid, tpid, | |
195 | 196 | from_kuid_munged(user_ns, cred->uid), |
196 | 197 | from_kuid_munged(user_ns, cred->euid), |
197 | 198 | from_kuid_munged(user_ns, cred->suid), |
... | ... | @@ -201,7 +202,6 @@ |
201 | 202 | from_kgid_munged(user_ns, cred->sgid), |
202 | 203 | from_kgid_munged(user_ns, cred->fsgid), |
203 | 204 | max_fds); |
204 | - rcu_read_unlock(); | |
205 | 205 | |
206 | 206 | group_info = cred->group_info; |
207 | 207 | for (g = 0; g < group_info->ngroups; g++) |