summaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-12-10 18:45:12 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 20:41:09 -0500
commit0f4a0d53f20c76a70cb5b69b6aa237de2107e171 (patch)
tree6c1e5e4a323bd542fc07d117acf61824293b5262 /fs/proc
parent4af1036df4dd4f0d59fad9d82ed456bfa2e73fa6 (diff)
proc: task_state: deuglify the max_fds calculation
1. The usage of fdt looks very ugly, it can't be NULL if ->files is not NULL. We can use "unsigned int max_fds" instead. 2. This also allows to move seq_printf(max_fds) outside of task_lock() and join it with the previous seq_printf(). See also the next patch. 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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/array.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index b5810c228c10..7c8d9aecb070 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -157,9 +157,9 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
157 struct user_namespace *user_ns = seq_user_ns(m); 157 struct user_namespace *user_ns = seq_user_ns(m);
158 struct group_info *group_info; 158 struct group_info *group_info;
159 int g; 159 int g;
160 struct fdtable *fdt = NULL;
161 const struct cred *cred; 160 const struct cred *cred;
162 pid_t ppid, tpid; 161 pid_t ppid, tpid;
162 unsigned int max_fds = 0;
163 163
164 rcu_read_lock(); 164 rcu_read_lock();
165 ppid = pid_alive(p) ? 165 ppid = pid_alive(p) ?
@@ -171,6 +171,12 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
171 tpid = task_pid_nr_ns(tracer, ns); 171 tpid = task_pid_nr_ns(tracer, ns);
172 } 172 }
173 cred = get_task_cred(p); 173 cred = get_task_cred(p);
174
175 task_lock(p);
176 if (p->files)
177 max_fds = files_fdtable(p->files)->max_fds;
178 task_unlock(p);
179
174 seq_printf(m, 180 seq_printf(m,
175 "State:\t%s\n" 181 "State:\t%s\n"
176 "Tgid:\t%d\n" 182 "Tgid:\t%d\n"
@@ -179,7 +185,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
179 "PPid:\t%d\n" 185 "PPid:\t%d\n"
180 "TracerPid:\t%d\n" 186 "TracerPid:\t%d\n"
181 "Uid:\t%d\t%d\t%d\t%d\n" 187 "Uid:\t%d\t%d\t%d\t%d\n"
182 "Gid:\t%d\t%d\t%d\t%d\n", 188 "Gid:\t%d\t%d\t%d\t%d\n"
189 "FDSize:\t%d\nGroups:\t",
183 get_task_state(p), 190 get_task_state(p),
184 task_tgid_nr_ns(p, ns), 191 task_tgid_nr_ns(p, ns),
185 task_numa_group_id(p), 192 task_numa_group_id(p),
@@ -192,16 +199,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
192 from_kgid_munged(user_ns, cred->gid), 199 from_kgid_munged(user_ns, cred->gid),
193 from_kgid_munged(user_ns, cred->egid), 200 from_kgid_munged(user_ns, cred->egid),
194 from_kgid_munged(user_ns, cred->sgid), 201 from_kgid_munged(user_ns, cred->sgid),
195 from_kgid_munged(user_ns, cred->fsgid)); 202 from_kgid_munged(user_ns, cred->fsgid),
196 203 max_fds);
197 task_lock(p);
198 if (p->files)
199 fdt = files_fdtable(p->files);
200 seq_printf(m,
201 "FDSize:\t%d\n"
202 "Groups:\t",
203 fdt ? fdt->max_fds : 0);
204 task_unlock(p);
205 rcu_read_unlock(); 204 rcu_read_unlock();
206 205
207 group_info = cred->group_info; 206 group_info = cred->group_info;