From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4641AC282DA for ; Fri, 19 Apr 2019 18:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C4DB20643 for ; Fri, 19 Apr 2019 18:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728477AbfDSStW (ORCPT ); Fri, 19 Apr 2019 14:49:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37832 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727658AbfDSStV (ORCPT ); Fri, 19 Apr 2019 14:49:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 151093086272; Fri, 19 Apr 2019 15:44:01 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.38]) by smtp.corp.redhat.com (Postfix) with SMTP id 9F7081001E81; Fri, 19 Apr 2019 15:43:55 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 19 Apr 2019 17:44:00 +0200 (CEST) Date: Fri, 19 Apr 2019 17:43:54 +0200 From: Oleg Nesterov To: Jann Horn Cc: Joel Fernandes , Christian Brauner , Florian Weimer , kernel list , Andy Lutomirski , Steven Rostedt , Daniel Colascione , Suren Baghdasaryan , Linus Torvalds , Alexey Dobriyan , Al Viro , Andrei Vagin , Andrew Morton , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , linux-fsdevel , linux-kselftest@vger.kernel.org, Michal Hocko , Nadav Amit , Serge Hallyn , Shuah Khan , Stephen Rothwell , Taehee Yoo , Tejun Heo , Thomas Gleixner , kernel-team , Tycho Andersen Subject: Re: [PATCH RFC 1/2] Add polling support to pidfd Message-ID: <20190419154354.GB12228@redhat.com> References: <20190411175043.31207-1-joel@joelfernandes.org> <20190416120430.GA15437@redhat.com> <20190416192051.GA184889@google.com> <20190417130940.GC32622@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 19 Apr 2019 15:44:01 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On 04/18, Jann Horn wrote: > > On Wed, Apr 17, 2019 at 3:09 PM Oleg Nesterov wrote: > > On 04/16, Joel Fernandes wrote: > > > On Tue, Apr 16, 2019 at 02:04:31PM +0200, Oleg Nesterov wrote: > > > > > > > > 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. > > > > IOW, when the whole thread group exits, so it can't be used to monitor sub-threads. > > > > just in case... speaking of this patch it doesn't modify proc_tid_base_operations, > > so you can't poll("/proc/sub-thread-tid") anyway, but iiuc you are going to use > > the anonymous file returned by CLONE_PIDFD ? > > I don't think procfs works that way. /proc/sub-thread-tid has > proc_tgid_base_operations despite not being a thread group leader. Yes, sorry, I meant /proc/pid/task/sub-thread-tid. But poll("/proc/sub-thread-tid") won't work too, we can't rely on do_notify_parent() if the task is not a group leader. > (Yes, that's kinda weird.) AFAICS the WARN_ON_ONCE() in this code can > be hit trivially, and then the code will misbehave. Heh, I didn't even notice that WARN_ON_ONCE(task && !thread_group_leader(task)) ;) > @Joel: I think you'll have to either rewrite this to explicitly bail > out if you're dealing with a thread group leader, or make the code > work for threads, too. The last version of CLONE_PIDFD doesn't allow CLONE_THREAD, so we can forget about this problem for now. Oleg.