]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pid: change task_state() to use task_ppid_nr_ns()
authorOleg Nesterov <oleg@redhat.com>
Sun, 10 Aug 2025 17:36:20 +0000 (19:36 +0200)
committerChristian Brauner <brauner@kernel.org>
Tue, 19 Aug 2025 11:38:21 +0000 (13:38 +0200)
to simplify the code.

Note that only tpid and max_fds really need rcu_read_lock(), we could move
task_ppid_nr_ns/task_tgid_nr_ns/task_numa_group_id/get_task_cred outside of
rcu read section.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/20250810173620.GA20007@redhat.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/proc/array.c

index d6a0369caa931ebd6baa3fbb01612d04ddf9d3bf..69269745d73b8f5a3e17746313c657f4debcab0f 100644 (file)
@@ -157,13 +157,11 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
        unsigned int max_fds = 0;
 
        rcu_read_lock();
-       ppid = pid_alive(p) ?
-               task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
-
        tracer = ptrace_parent(p);
        if (tracer)
                tpid = task_pid_nr_ns(tracer, ns);
 
+       ppid = task_ppid_nr_ns(p, ns);
        tgid = task_tgid_nr_ns(p, ns);
        ngid = task_numa_group_id(p);
        cred = get_task_cred(p);