Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2085274yba; Fri, 19 Apr 2019 11:50:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqywpQxnK+FaXy02NNak/gvHkmnQm0HiybF2DtoN4kD4a9MKvcAOPplHjX8QpLIMmiZipTl2 X-Received: by 2002:a63:7808:: with SMTP id t8mr5439919pgc.127.1555699836469; Fri, 19 Apr 2019 11:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555699836; cv=none; d=google.com; s=arc-20160816; b=zc/e+OdPJM94nmragmN50Un/ytqYVwnvhntza57P39lueVFCYLlU7wjtLhV6QNnAnT JYY9syrjXmYsW6ketmVRA7XRotjPtcBz3C8TCHLHF2volvbis9zuBOmOIzwpeWke7RrK RYixl+DNdTliZ1NBE/2gX4dJWrg+4q91lYkt47vj+reWCINUUcK9IRUN7GAmGX4XvZsu BDeKSfwL0rCVFkKYac+hGOyNteyPuDTTYkt8THPixWK3XzaOerByI+BeA5qNBaS33R1S UNpmU+T4V9JwRzmiOmH25BnCIDcBIRJOubIznFfp9aj9osxyxqvZ7/ObySUS7qE+h8W/ p+aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ie2DadmZm6hTPRK7wUJZlTnJgtZrSp26ORgnczcU5Qw=; b=kkqLuI5dSFOSZoJfdRlJQ8nHDzXNdEWpgmb+kBixGzGwo4MCfyv/+UizPeQpcmNa4t 6/NoDy6hpspueWNaQy3vD5sKOz2apc0fcjf/40Arn/20W2mq3tNsyrZO4vSk/LWkMy7h wudNoq7Isp29FlT0FMRUuoKeSM9H3Q7sbQdB3LNMDjl2xjPHCtgyUJ41YPwajYm0a49X JNpnwQw5B/oh6vHYWO6GfHGnqndJqfhiZFvnr5pAVMwBrFCiFEWh+0sLxp3snHHFGYPE uu47sX5jfvX9okyrc34QVVEq9laGL41pe60Z09YUcIWFtVRupiDKL+gLysBGAuC73Bxg j8Rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si6237163pfh.177.2019.04.19.11.50.21; Fri, 19 Apr 2019 11:50:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728497AbfDSStW (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.