Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2343107yba; Fri, 19 Apr 2019 17:48:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPam/SJ5qJFacdJRNJXsMIdc22XWQgd3H12OBDMkJzje74DRHX2tcjxFOCn4FfpfUO1vFX X-Received: by 2002:a62:f20e:: with SMTP id m14mr7296258pfh.228.1555721293369; Fri, 19 Apr 2019 17:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555721293; cv=none; d=google.com; s=arc-20160816; b=JXKEHDQLB44namZuGpPYHBjQH6JFxY6mKxVMofetKbz0q1hL0T61l2c31w7KGx6Nt8 +sfU6doP58y/OH0mu+5MUPAc2Und2fD/16LtSpmAhkLCQtUxiLXhPnCxR/Qy9ubP0vib zHMnWMpT0xTy3uVjZh7F+/zxAx+eNyR3s8e4F3GyyIrWT0TKWQS7yU5ZBxqMYBHdu7cg XcQVdSUjF3FZIe/WF0gHbCZODQA7XrchiSAEAqrfe3KZupJgSZICDkMgvWOSSCAvqIVL BHte6/3nTHMP9Gpfd9hOXh6rh1ozDaxqkacV/WAnG+9YPXJvurVKdW6VOu+sPoIQ2qi/ p3jw== 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=lJeJCEsvjqX5rGVJW/HifUv3RwhSjNdHLvuBe2kGGfU=; b=VArrq61mNHwuHQU+n8zjplMGq5nTfkqr8/d24iOim3guAqFpbdnMr3lYCh6dNzvX8s JGW6vqlPC18NgXOYDCrOGprbVXu+7RkcRY2s9he+bsTUW7f3vf3wNL7VLn+bYkNpr4pa 6byKrR04M7STbK2GZmjGTTQajWenNVJuXuHI/o5mFm/cJ6kfzc4UsrVuk9dlU1TQRHnY EWH0UeBAWKaoXmuVl2UKQGZIITY5ReGFMbilTX2nyE010EU7I8rkSw9xUbmKvWLSKw5L MzM6I7shjGsGWJVMIR5FJvw5A5GcuvOGVtVWhNFT5FhrU7TbG3bm/aKwhUMSfQT06y2G C9Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=wSdZMzhK; 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 z73si6254887pgd.345.2019.04.19.17.47.55; Fri, 19 Apr 2019 17:48:13 -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=wSdZMzhK; 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 S1726150AbfDTArB (ORCPT + 99 others); Fri, 19 Apr 2019 20:47:01 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33073 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfDTArB (ORCPT ); Fri, 19 Apr 2019 20:47:01 -0400 Received: by mail-pl1-f193.google.com with SMTP id t16so3253280plo.0 for ; Fri, 19 Apr 2019 17:47:01 -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=lJeJCEsvjqX5rGVJW/HifUv3RwhSjNdHLvuBe2kGGfU=; b=wSdZMzhKAmXWG+c9nxI1Ty9OEoHWhIECkuhxH3mr4CfZGPhKu+43CIdbUmWjaHFNPN a4iDaM9ERZujhMePnXrwwGOTOIn+Iel8E4QAXJfWq2VqhCHHcQVA2EWiYAdUcfJugZxt iUzsd2EFp378t7EixJw76/OIwIrt3puPV7NuE= 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=lJeJCEsvjqX5rGVJW/HifUv3RwhSjNdHLvuBe2kGGfU=; b=eGSZSymao2raCC8eXzIHOdakwXBcJt461J84Lddw6We7XT6BJWedYnO53h1T8AYc19 hrv8gKDpYNtbSOJ8mC3xPiD7eTYgx/fH2eLOHRWRapSNY1mlSUwa1ACqtxTuoAa9T4TA xLGkiK13LLz0wBnWNZoPRe0Eg0KfK4ZHS41i08SH/tW6CTmMlelMmU9gId3RXMxg26m0 o0NSZjDe4HV0v5N/8Ut1vjog2+ah5gdoJOaJXuZiiSMuS4ZBSY4OmkVzilAsiVrV5Uk+ TXI8tfUAOoUU1JfYQuQ3ZqvaND9pyA3hKXbYWIULDRELgKb1YFrAyVTHu/ZAlGwaznOi 9eVQ== X-Gm-Message-State: APjAAAVjIvH6+5vPAIwsWwFLJ2V6dArh5fMlOBqUArSRdM7zaCq08Pul JA4fp+fbMhagJnYHGC5UuXiPNA== X-Received: by 2002:a17:902:3064:: with SMTP id u91mr6507760plb.181.1555721220670; Fri, 19 Apr 2019 17:47:00 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id u4sm433524pgr.89.2019.04.19.17.46.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Apr 2019 17:46:59 -0700 (PDT) Date: Fri, 19 Apr 2019 20:46:58 -0400 From: Joel Fernandes To: Linus Torvalds Cc: Christian Brauner , Daniel Colascione , Jann Horn , Oleg Nesterov , Florian Weimer , kernel list , Andy Lutomirski , Steven Rostedt , Suren Baghdasaryan , Alexey Dobriyan , Al Viro , Andrei Vagin , Andrew Morton , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , linux-fsdevel , "open list:KERNEL SELFTEST FRAMEWORK" , 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: <20190420004658.GG251571@google.com> References: <20190417130940.GC32622@redhat.com> <20190419190247.GB251571@google.com> <20190419191858.iwcvqm6fihbkaata@brauner.io> <20190419194902.GE251571@google.com> <20190419212002.GB44851@google.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 Fri, Apr 19, 2019 at 04:11:37PM -0700, Linus Torvalds wrote: > On Fri, Apr 19, 2019 at 2:20 PM Joel Fernandes wrote: > > > > According to Linus, POLLHUP usually indicates that something is readable: > > Note that if you use the legacy interfaces (ie "select()"), then even > just a plain POLLHUP will always just show as "readable". > > So for a lot of applications, it won't even matter. Returning POLLHUP > will mean it's readable whether POLLIN is set or not (and EPOLLERR > will automatically mean that it's marked both readable and writable). > > In fact, I'd argue that not a lot of people care about the more > esoteric bits at all. If your poll function does POLLIN and POLLOUT, > it's fine. Anything else is specialized enough that most people simply > won't care. Don't overdesign things too much. You need to have a major > reason to care about the other POLL bits. > > It's also worth noting that POLLERR/POLLHUP/POLLNVAL cannot be masked > for "poll()". Even if you only ask for POLLIN/POLLOUT, you will always > get POLLERR/POLLHUP notification. That is again historical behavior, > and it's kind of a "you can't poll a hung up fd". But it once again > means that you should consider POLLHUP to be something *exceptional* > and final, where no further or other state changes can happen or are > relevant. > > That may well work fine for pidfd when the task is gone, but it's > really worth noting that any *normal* state should be about > POLLIN/POLLOUT. People should not think that "POLLHUP sounds like the > appropriate name", they should realize that POLLHUP is basically a > terminal error condition, not a "input is available". > > So just keep that in mind. Got it, thanks a lot for the detailed explanation of the flags. So then I feel I should not return POLLHUP or POLLERR because the task_struct getting reaped is not an error condition. I will simplify the patch and repost it. It seems that would be the best thing to do to serve the usecase. We just want to know when the task exited and a reaped task also counts as one that exited. thanks, - Joel