Re: [PATCH 1/5] pid: get pid_t ppid of task in init_pid_ns
From: Oleg Nesterov
Date: Mon Dec 30 2013 - 12:04:17 EST
On 12/23, Richard Guy Briggs wrote:
>
> +static inline pid_t task_ppid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
> +{
> + pid_t pid;
> +
> + rcu_read_lock();
> + pid = pid_alive(tsk) ?
> + task_pid_nr_ns(rcu_dereference(tsk->real_parent), ns) : 0;
> + rcu_read_unlock();
> +
> + return pid;
> +}
I do not really mind, but perhaps
pid_t pid = 0;
rcu_read_lock();
if (pid_alive(task))
pid = task_pid_nr_ns(rcu_dereference(tsk->real_parent);
rcu_read_unlock();
return pid;
looks a bit cleaner.
> +static inline pid_t task_ppid_nr(struct task_struct *tsk)
> +{
> + pid_t pid;
> +
> + rcu_read_lock();
> + pid = pid_alive(tsk) ?
> + task_pid_nr(rcu_dereference(tsk->real_parent)) : 0;
> + rcu_read_unlock();
> +
> + return pid;
> +}
It could simply do
return task_ppid_nr_ns(tsk, init_pid_ns);
but again, I won't argue.
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/