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=-1.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,URIBL_BLOCKED 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 5A6F1C282E0 for ; Fri, 19 Apr 2019 23:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 239192171F for ; Fri, 19 Apr 2019 23:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555715907; bh=ePj/BWoLV3AAsvH/rEPZCke8uzzjZYdlFd4lptMDRy8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=K0/YxM9sqIJIccIoQKDGZWKavw06Dh2RPOZ8IbKPUvtbR3S1CW8fDD5NcOmj7wlZj 5KrOyKwibJ5Wl59/YW6eSDNJEfPrv763ud/heQJ34WX5COfplQTztmBuHLkw1RDfPV hAytFfbhU+JrBniC4R72gMvDcwSzR2td46d0z/QA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725911AbfDSXS0 (ORCPT ); Fri, 19 Apr 2019 19:18:26 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44721 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbfDSXS0 (ORCPT ); Fri, 19 Apr 2019 19:18:26 -0400 Received: by mail-lf1-f65.google.com with SMTP id h18so4942420lfj.11 for ; Fri, 19 Apr 2019 16:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zdUf3lFbFQiNVBd828vl0zLRp6GM+2VM7En0qhuWigE=; b=W1H/EhobO3jdaaFICBrL4EdvmrKM5H/rZe9k3wwV4Xjsn8IG1+N3EncfkPMpszyU5h jWaiv1a7My9tKLMI/AOpM8zIfr0rydXlPidRIVM5StgDb0YtknNIn3Pjwm86NQXgnQvj H7avsLNDEC3dUuePD1+ekBG08hJ2FbNbiQQV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zdUf3lFbFQiNVBd828vl0zLRp6GM+2VM7En0qhuWigE=; b=U+4m+PqrMisbjOwPHl68OQLORwxIZyrt3x/DkQtNL1xG4R7kgV5JlptDAbPEEvZIqi C7PxbFYSt3OsfYTt9JHzQ2Nb+fVg98ILq1BSFFmedhl+OAY+A22E8CuPoDGrvo5QgVGW ELXTbb5vn9IFhptiVUdqZXq+JLCfZeATr8KNa3birKkxZ/t59SGef2GhH3jS8OkPW+bT W+ZxESCS4qtv/M69elsQzfqPTta0JSF4QJdw6MKqKx9RaI1c9uEl3qeos3WsAx2qz2NU RTuv926t8qFTEV88/eTVer0VI1SKS7763KkCltL8s5xqMIIQzWCrQd91lmi2GYic+SoJ nNFA== X-Gm-Message-State: APjAAAX5MgT4wY+SLlofKHCr6+uTz42d6y95pcAyEAS9SMYNEhGWLp49 FeRaVyY16eEI8r3SsS9sc3nHujQkmv0= X-Google-Smtp-Source: APXvYqycHMHu+NwJDmj9zOUwyJuSRh3b2oBduHmOjBiZg4DwDdNxqvt32v/iCMDhGgWM7N/oRaz4CA== X-Received: by 2002:a19:5e56:: with SMTP id z22mr3709097lfi.81.1555715903790; Fri, 19 Apr 2019 16:18:23 -0700 (PDT) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com. [209.85.167.54]) by smtp.gmail.com with ESMTPSA id y7sm1299407ljy.65.2019.04.19.16.18.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 16:18:23 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id j11so4975689lfm.0 for ; Fri, 19 Apr 2019 16:18:23 -0700 (PDT) X-Received: by 2002:ac2:547a:: with SMTP id e26mr3548958lfn.148.1555715513747; Fri, 19 Apr 2019 16:11:53 -0700 (PDT) MIME-Version: 1.0 References: <20190416120430.GA15437@redhat.com> <20190416192051.GA184889@google.com> <20190417130940.GC32622@redhat.com> <20190419190247.GB251571@google.com> <20190419191858.iwcvqm6fihbkaata@brauner.io> <20190419194902.GE251571@google.com> <20190419212002.GB44851@google.com> In-Reply-To: <20190419212002.GB44851@google.com> From: Linus Torvalds Date: Fri, 19 Apr 2019 16:11:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC 1/2] Add polling support to pidfd To: Joel Fernandes 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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. Linus