aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
authorMateusz Guzik <mguzik@redhat.com>2018-04-10 19:30:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-11 13:28:33 -0400
commit68c3411ff4a4cee53cc854c11ed191eaaf1956ba (patch)
tree30b9c8ebe459df3573b2fcef6ee15cf2a7f837f1 /fs/proc/array.c
parent8cfa67b4d9a9d9a6061f3cfd0e0ed16e66e45984 (diff)
proc: get rid of task lock/unlock pair to read umask for the "status" file
get_task_umask locks/unlocks the task on its own. The only caller does the same thing immediately after. Utilize the fact the task has to be locked anyway and just do it once. Since there are no other users and the code is short, fold it in. Link: http://lkml.kernel.org/r/1517995608-23683-1-git-send-email-mguzik@redhat.com Signed-off-by: Mateusz Guzik <mguzik@redhat.com> Reviewed-by: Alexey Dobriyan <adobriyan@gmail.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Jerome Marchand <jmarchan@redhat.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.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 598803576e4c..851ec0915e4c 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -141,25 +141,12 @@ static inline const char *get_task_state(struct task_struct *tsk)
141 return task_state_array[task_state_index(tsk)]; 141 return task_state_array[task_state_index(tsk)];
142} 142}
143 143
144static inline int get_task_umask(struct task_struct *tsk)
145{
146 struct fs_struct *fs;
147 int umask = -ENOENT;
148
149 task_lock(tsk);
150 fs = tsk->fs;
151 if (fs)
152 umask = fs->umask;
153 task_unlock(tsk);
154 return umask;
155}
156
157static inline void task_state(struct seq_file *m, struct pid_namespace *ns, 144static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
158 struct pid *pid, struct task_struct *p) 145 struct pid *pid, struct task_struct *p)
159{ 146{
160 struct user_namespace *user_ns = seq_user_ns(m); 147 struct user_namespace *user_ns = seq_user_ns(m);
161 struct group_info *group_info; 148 struct group_info *group_info;
162 int g, umask; 149 int g, umask = -1;
163 struct task_struct *tracer; 150 struct task_struct *tracer;
164 const struct cred *cred; 151 const struct cred *cred;
165 pid_t ppid, tpid = 0, tgid, ngid; 152 pid_t ppid, tpid = 0, tgid, ngid;
@@ -177,16 +164,16 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
177 ngid = task_numa_group_id(p); 164 ngid = task_numa_group_id(p);
178 cred = get_task_cred(p); 165 cred = get_task_cred(p);
179 166
180 umask = get_task_umask(p);
181 if (umask >= 0)
182 seq_printf(m, "Umask:\t%#04o\n", umask);
183
184 task_lock(p); 167 task_lock(p);
168 if (p->fs)
169 umask = p->fs->umask;
185 if (p->files) 170 if (p->files)
186 max_fds = files_fdtable(p->files)->max_fds; 171 max_fds = files_fdtable(p->files)->max_fds;
187 task_unlock(p); 172 task_unlock(p);
188 rcu_read_unlock(); 173 rcu_read_unlock();
189 174
175 if (umask >= 0)
176 seq_printf(m, "Umask:\t%#04o\n", umask);
190 seq_printf(m, "State:\t%s", get_task_state(p)); 177 seq_printf(m, "State:\t%s", get_task_state(p));
191 178
192 seq_put_decimal_ull(m, "\nTgid:\t", tgid); 179 seq_put_decimal_ull(m, "\nTgid:\t", tgid);