Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2097515yba; Fri, 19 Apr 2019 12:04:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzL/PwuA2LCDBJRGBl/5SnmWuBPP0XwVaIqWdeIHp5+bflkEqsSb7EMp0ert6VTZVc2tDKA X-Received: by 2002:a63:f012:: with SMTP id k18mr5487379pgh.433.1555700681210; Fri, 19 Apr 2019 12:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555700681; cv=none; d=google.com; s=arc-20160816; b=rsbxD0Q6VG7ls2oPSSepRgQ810Rc1hQQGDDTFZK/S7cGBTp5ch6Qj6A4UZtleC9+Um LCFLHCDd83li/H8aycW5h16yKhxuQFcdzPzUPaI45Iy/+1G39I61Y3VtOiouumv66Wd1 Retlhi7oQ84EvywxKFLFxmXTp0UjPzkLXw4rlPjElvWKBmlWuxjC1Q+ruv+mH3WPQcUt Lo7szl1wAYGr83g+TUj4xOFN+MFu/td23dtBuUs0+yf3ntuHtsClatYD/AEv++I7MXL2 6EaSHRZ48RXCP8kmmauhmSBwNaMPDbu9NDCSFGzLbzf9ecv03jfJXmGfuh9RXNGX08Uv jaGg== 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:dkim-signature; bh=p9ek9Lo1t5TDwh6GoEDfO3CWDi0O8EcB/kULAdUF/OU=; b=lGG3xyM01iNUaq3Acg+0KQoibRg58IK8IHnXT8/L7A99Nixg3H9S9n+ufygN5GhZAt f6Fyz4LKIIy8AG/0xrHJlxUoYMy7VrNpWDREtNyaEVHG5tNlBhuj66ct5JsukUx4qa3/ xae/jFf97TTgBehuawTS06pABWuDuFsIvOFMbjkl7TVXZbvF1IOMRvfLF6TO9EckTUcL 0oBKyCIUu3Yg/8m1Cvz5sDghcEcPGwVa28n5MvjXgcj1+9tmfuz1ITMs4t8uW364UOw9 HSexuN57XBVytWqR6ji4OX8eLiw7yfpf0h8oHQ+vF8gqQVgahIufAwPB17RGiWamebEL Ivag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=vFtkEwj0; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si5377069pgb.292.2019.04.19.12.04.25; Fri, 19 Apr 2019 12:04:41 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=vFtkEwj0; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728974AbfDSTCw (ORCPT + 99 others); Fri, 19 Apr 2019 15:02:52 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38349 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728607AbfDSTCu (ORCPT ); Fri, 19 Apr 2019 15:02:50 -0400 Received: by mail-pl1-f196.google.com with SMTP id f36so2976566plb.5 for ; Fri, 19 Apr 2019 12:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=p9ek9Lo1t5TDwh6GoEDfO3CWDi0O8EcB/kULAdUF/OU=; b=vFtkEwj0yv9OP3j0uE/8mvF2oBbaEbnga9y0/sXtRCBUScAMbt5NbTRw9cKstPvPtp FG33T7XnDBQnO2UeZGyqTGavpSTMU0mx83wbpIqF/UKm9SlMNGM3hc0ZLXsEMCRt3JoW s9Wmh0Xi1JY4d0EDv4nUp4wWSeeRaYl6u3s6U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=p9ek9Lo1t5TDwh6GoEDfO3CWDi0O8EcB/kULAdUF/OU=; b=rqgy5K+5vTR+aYwnbkb82if8TAyx86SpBg/bL2XQtHQIclQ74ICd3iLTo3qDwUKaqC SD8yuOdGmltQFUQqsnk7NG7zJ9xos3n3AAeNQdx7gNtPTCMj+FJLwDkKLgto9c/oHCYE ANcyMw2iWnS8Zi2GiMa4Lz79A+5ukSKr5sdcjNFw13i5+peDNsfc3J0oRUSrU0VILRii AlzY8r46m+Z2B9yW6WaKBoF2ETVbCo09AhOxf5+F5qS0S1nIRM9K2jryI6tnqH2rVDZO s6MghVrci+Tzz70Ro9U7QqK9foywg8Ub/hExBiFPNTpua2iHqoALW1Yb6JgCflfxtuXn 8K+w== X-Gm-Message-State: APjAAAW/92HypZM0vSDdIQWUoI6JtIhHap4TWmUuCsAUDi70iIztLbZl A/8DhyrdGSyP3DFSpbBHLBkQTg== X-Received: by 2002:a17:902:442:: with SMTP id 60mr5506960ple.107.1555700569184; Fri, 19 Apr 2019 12:02:49 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id o89sm9909856pfi.178.2019.04.19.12.02.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Apr 2019 12:02:48 -0700 (PDT) Date: Fri, 19 Apr 2019 15:02:47 -0400 From: Joel Fernandes To: Christian Brauner Cc: Jann Horn , Oleg Nesterov , 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: <20190419190247.GB251571@google.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.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 18, 2019 at 07:26:44PM +0200, Christian Brauner wrote: > On April 18, 2019 7:23:38 PM GMT+02:00, 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, that's kinda weird.) AFAICS the WARN_ON_ONCE() in this code can > >be hit trivially, and then the code will misbehave. > > > >@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 latter case probably being preferred if this API is supposed to be > useable for thread management in userspace. At the moment, we are not planning to use this for sub-thread management. I am reworking this patch to only work on clone(2) pidfds which makes the above discussion about /proc a bit unnecessary I think. Per the latest CLONE_PIDFD patches, CLONE_THREAD with pidfd is not supported. Also we wanted to make the polling of pidfd quite close to the wait(2) family semantics which, as I understand correctly, is not something that works for sub-threads. In the future, we could bail in poll(2) or return an error, if clone(2) starts supporting thread pidfds, but at the moment I will like to keep the WARN_ON just in case. Please let me know if I missed something. thanks! - Joel