[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKOZueu=5aNf+oDFBM56TbqZwKpB6q1y81V1cbL+k4DTyV53+A@mail.gmail.com>
Date: Thu, 18 Apr 2019 11:57:54 -0700
From: Daniel Colascione <dancol@...gle.com>
To: Jonathan Kowalski <bl0pbl33p@...il.com>
Cc: Joel Fernandes <joel@...lfernandes.org>,
Oleg Nesterov <oleg@...hat.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Andy Lutomirski <luto@...capital.net>,
Steven Rostedt <rostedt@...dmis.org>,
Christian Brauner <christian@...uner.io>,
Jann Horn <jannh@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Alexey Dobriyan <adobriyan@...il.com>,
Al Viro <viro@...iv.linux.org.uk>,
Andrei Vagin <avagin@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Arnd Bergmann <arnd@...db.de>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Kees Cook <keescook@...omium.org>,
Linux FS Devel <linux-fsdevel@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>, Michal Hocko <mhocko@...e.com>,
Nadav Amit <namit@...are.com>, Serge Hallyn <serge@...lyn.com>,
Shuah Khan <shuah@...nel.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Taehee Yoo <ap420073@...il.com>, Tejun Heo <tj@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Android Kernel Team <kernel-team@...roid.com>,
Tycho Andersen <tycho@...ho.ws>
Subject: Re: [PATCH RFC 1/2] Add polling support to pidfd
On Thu, Apr 18, 2019 at 11:44 AM Jonathan Kowalski <bl0pbl33p@...il.com> wrote:
>
> On Tue, Apr 16, 2019 at 8:21 PM Joel Fernandes <joel@...lfernandes.org> wrote:
> >
> > On Tue, Apr 16, 2019 at 02:04:31PM +0200, Oleg Nesterov wrote:
> > > On 04/11, Joel Fernandes (Google) wrote:
> > > >
> > > > +static unsigned int proc_tgid_base_poll(struct file *file, struct poll_table_struct *pts)
> > > > +{
> > > > + int poll_flags = 0;
> > > > + struct task_struct *task;
> > > > + struct pid *pid;
> > > > +
> > > > + task = get_proc_task(file->f_path.dentry->d_inode);
> > > > +
> > > > + WARN_ON_ONCE(task && !thread_group_leader(task));
> > > > +
> > > > + /*
> > > > + * tasklist_lock must be held because to avoid racing with
> > > > + * changes in exit_state and wake up. Basically to avoid:
> > > > + *
> > > > + * P0: read exit_state = 0
> > > > + * P1: write exit_state = EXIT_DEAD
> > > > + * P1: Do a wake up - wq is empty, so do nothing
> > > > + * P0: Queue for polling - wait forever.
> > > > + */
> > > > + read_lock(&tasklist_lock);
> > > > + if (!task)
> > > > + poll_flags = POLLIN | POLLRDNORM | POLLERR;
> > > > + else if (task->exit_state == EXIT_DEAD)
> > > > + poll_flags = POLLIN | POLLRDNORM;
> > > > + else if (task->exit_state == EXIT_ZOMBIE && thread_group_empty(task))
> > > > + poll_flags = POLLIN | POLLRDNORM;
> > > > +
> > > > + if (!poll_flags) {
> > > > + pid = proc_pid(file->f_path.dentry->d_inode);
> > > > + poll_wait(file, &pid->wait_pidfd, pts);
> > > > + }
> > >
> > > can't understand...
> > >
> > > Could you explain when it should return POLLIN? When the whole process exits?
> >
> > It returns POLLIN when the task is dead or doesn't exist anymore, or when it
> > is in a zombie state and there's no other thread in the thread group.
> >
>
> Would using something other than POLLIN be an option (maybe POLLPRI)?
> The convention is to use it to indicate readability on the descriptor,
> and also possibly POLLHUP instead of POLLERR (the latter is less of a
> problem, but FreeBSD also does the same, so it'd help with some
> consistency for libraries wanting to use this, which aren't interested
> in other sub states).
Existing event loop libraries generally support checking only for
readability and writability. Not setting POLLIN would make these FDs
more difficult to use with existing event loop libraries. What
advantage would compensate for this difficulty?
Powered by blists - more mailing lists