Commit 68c3411f authored by Mateusz Guzik's avatar Mateusz Guzik Committed by Linus Torvalds

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.comSigned-off-by: default avatarMateusz Guzik <mguzik@redhat.com>
Reviewed-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8cfa67b4
...@@ -141,25 +141,12 @@ static inline const char *get_task_state(struct task_struct *tsk) ...@@ -141,25 +141,12 @@ static inline const char *get_task_state(struct task_struct *tsk)
return task_state_array[task_state_index(tsk)]; return task_state_array[task_state_index(tsk)];
} }
static inline int get_task_umask(struct task_struct *tsk)
{
struct fs_struct *fs;
int umask = -ENOENT;
task_lock(tsk);
fs = tsk->fs;
if (fs)
umask = fs->umask;
task_unlock(tsk);
return umask;
}
static inline void task_state(struct seq_file *m, struct pid_namespace *ns, static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *p) struct pid *pid, struct task_struct *p)
{ {
struct user_namespace *user_ns = seq_user_ns(m); struct user_namespace *user_ns = seq_user_ns(m);
struct group_info *group_info; struct group_info *group_info;
int g, umask; int g, umask = -1;
struct task_struct *tracer; struct task_struct *tracer;
const struct cred *cred; const struct cred *cred;
pid_t ppid, tpid = 0, tgid, ngid; 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,16 +164,16 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
ngid = task_numa_group_id(p); ngid = task_numa_group_id(p);
cred = get_task_cred(p); cred = get_task_cred(p);
umask = get_task_umask(p);
if (umask >= 0)
seq_printf(m, "Umask:\t%#04o\n", umask);
task_lock(p); task_lock(p);
if (p->fs)
umask = p->fs->umask;
if (p->files) if (p->files)
max_fds = files_fdtable(p->files)->max_fds; max_fds = files_fdtable(p->files)->max_fds;
task_unlock(p); task_unlock(p);
rcu_read_unlock(); rcu_read_unlock();
if (umask >= 0)
seq_printf(m, "Umask:\t%#04o\n", umask);
seq_printf(m, "State:\t%s", get_task_state(p)); seq_printf(m, "State:\t%s", get_task_state(p));
seq_put_decimal_ull(m, "\nTgid:\t", tgid); seq_put_decimal_ull(m, "\nTgid:\t", tgid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment