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.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 8D4F2C282DA for ; Fri, 19 Apr 2019 19:03:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FC0C2064A for ; Fri, 19 Apr 2019 19:03:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="vFtkEwj0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728801AbfDSTCv (ORCPT ); Fri, 19 Apr 2019 15:02:51 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36969 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbfDSTCu (ORCPT ); Fri, 19 Apr 2019 15:02:50 -0400 Received: by mail-pl1-f196.google.com with SMTP id w23so2976828ply.4 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=l5ASnD2SFq0LUziTiRIHO5utxr1x3bHmEiPHBMMFta+w0RsoiqvPaKZxAprg6xf/gS 7EUpetZ8M0+XZ69/uKifvnzbB7m1pVmbflGbrK6Hc/yzbWmWbMgmfLzs8GLCfQUnURnZ +ClZO+R1hkiTRf7WFc1y1XrABgx/qRYH999240VgMz82q0rZ7bjPoS32mTHs1pnulwAO +wO5zIIwJMaWbM2VAahnt+U8mtfU7tho6w9N6j4ZjbBBBmiglbq2bqk4y4tJoNe30N0c VGDSI0aBY/QCwnyM8ZyHKz3NIfOumidKIkd6Gl1JmU03f8M8GIpZtVbHOG/QL6YToSah AAHw== X-Gm-Message-State: APjAAAUFzRdeec0q9vu34p43pE7u4Vnl7lHfMvxt8bGXAM+eHsWcjc9a owok/nwMU/1LJnniO8DT0a+z0g== X-Google-Smtp-Source: APXvYqxsaWDdMXJAhn/z/WdbNMp1NyDUuHVxHZBUgyUycIQ+4HZPM1Nx2CEEyiMjCCtZoDlQM+bZCg== 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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