From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH 1/2] pidfd: verify task is alive when printing fdinfo Date: Tue, 15 Oct 2019 16:43:57 +0200 Message-ID: <20191015144356.GA16978@redhat.com> References: <20191015141332.4055-1-christian.brauner@ubuntu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20191015141332.4055-1-christian.brauner@ubuntu.com> Sender: linux-kernel-owner@vger.kernel.org To: Christian Brauner Cc: linux-kernel@vger.kernel.org, Shuah Khan , Andrew Morton , "Peter Zijlstra (Intel)" , Ingo Molnar , Michal Hocko , Thomas Gleixner , Elena Reshetova , Christian Kellner , Roman Gushchin , Andrea Arcangeli , Al Viro , Aleksa Sarai , "Dmitry V. Levin" , linux-kselftest@vger.kernel.org, Jann Horn , linux-api@vger.kernel.org List-Id: linux-api@vger.kernel.org On 10/15, Christian Brauner wrote: > > +static inline bool task_alive(struct pid *pid) > +{ > + bool alive = true; > + > + rcu_read_lock(); > + if (!pid_task(pid, PIDTYPE_PID)) > + alive = false; > + rcu_read_unlock(); > + > + return alive; > +} Well, the usage of rcu_read_lock/unlock looks confusing to me... I mean, this helper does not need rcu lock at all. Except rcu_dereference_check() will complain. static inline bool task_alive(struct pid *pid) { bool alive; /* shut up rcu_dereference_check() */ rcu_lock_acquire(&rcu_lock_map); alive = !!pid_task(pid, PIDTYPE_PID)); rcu_lock_release(&rcu_lock_map); return alive; } looks more clear imo. But in fact I'd suggest to simply use !hlist_empty(&pid->tasks[PIDTYPE_PID]) in pidfd_show_fdinfo() and do not add a new helper. Oleg.