[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191015145646.72eqrw6j52ehvfn2@wittgenstein>
Date: Tue, 15 Oct 2019 16:56:47 +0200
From: Christian Brauner <christian.brauner@...ntu.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: linux-kernel@...r.kernel.org, Shuah Khan <shuah@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>, Michal Hocko <mhocko@...e.com>,
Thomas Gleixner <tglx@...utronix.de>,
Elena Reshetova <elena.reshetova@...el.com>,
Christian Kellner <christian@...lner.me>,
Roman Gushchin <guro@...com>,
Andrea Arcangeli <aarcange@...hat.com>,
Al Viro <viro@...iv.linux.org.uk>,
Aleksa Sarai <cyphar@...har.com>,
"Dmitry V. Levin" <ldv@...linux.org>,
linux-kselftest@...r.kernel.org, Jann Horn <jannh@...gle.com>,
linux-api@...r.kernel.org
Subject: Re: [PATCH 1/2] pidfd: verify task is alive when printing fdinfo
On Tue, Oct 15, 2019 at 04:43:57PM +0200, Oleg Nesterov wrote:
> 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.
Yep, I think we have another codepath were the rcu locks might be purely
cosmetic so I thought it's not a big deal (see below).
>
> 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.
Sounds good to me. But can't we then just do something similar just with
!hlist_empty(&pid->tasks[PIDTYPE_TGID])
in v5.4-rc3:kernel/pid.c:pidfd_open():514-517 ?
or would this be problematic because of de_thread()?
Thanks!
Christian
Powered by blists - more mailing lists