Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2298942yba; Fri, 19 Apr 2019 16:41:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUWYO/ubOpfOmnsD21EkOMgZOP9MbyXLxCcvVTtRNAjIVRmguERZqQR9t4gioRUdz59SMP X-Received: by 2002:a63:fa54:: with SMTP id g20mr6524836pgk.242.1555717316997; Fri, 19 Apr 2019 16:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555717316; cv=none; d=google.com; s=arc-20160816; b=opa9SKAIN17UuZaoXZ4zsnxyss6V1GwsPnGLwQKrAd3T58vgv/XmBbj97HJi0oHK85 J71vVDJvjuPFmbEtY9331ZLRlYxqnMrJJdPvw4k4WCwo/9841yOxX6wxG029XP791nVH woSC/pi1ibTnRJid4IGFQWA4TFA1n/oQW8G+AjZUPgNN7NgTIGuyy2kDnCCp03dEBKoq BfraMLDBlbthcFeeKzVj0uwgWq5v/dByDaLccIgu23dxNI2UG9ROSUhnGF+3mGJjD3lt YzvnwSHuYKMYNLwClrqo1SdUy/NX+LIthmnUX/vc6ocTGXesYY0IMwH3f8XcyRcrrT5i PqEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=dpJdQEss2Hf2fCZ1JCBrqDkW/3xv13oIKhlDU7E2du4=; b=GNmZ/xKleLH8ovNUav3bEKOdmOp5O0TsLcHBGin7svm8e+o2YJ1xw3vSPRZ3N17kiQ VmASF/AOApKcCJihJlTwXKsKoLOUAdyp97WPFiSvSz1lf3Y9bPgneZXHu76Pi5eNEKsn F46LCACB4Gq3pLwMHPDlVIas52RpjUgeTL1hQK0AmUoYdzdk0TLf+WwSQLSu+cMUEwrS fuGpLmOR4mZmzVv8zuC8abWC15eTL+F+n1kCc4HzHasqa1l8M9+nsUSGVnplVuUq8mYz ZRGpJXuEA4CY/Q/QRmdeh0Z1N2Hj0XWtUAv9YLQZGz40r7XbiL98NBSpMr8D4gMvjsrN aGMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="CaOcR/pq"; 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 p5si6159212plo.273.2019.04.19.16.41.38; Fri, 19 Apr 2019 16:41:56 -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=@linux-foundation.org header.s=google header.b="CaOcR/pq"; 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 S1727294AbfDSXiQ (ORCPT + 99 others); Fri, 19 Apr 2019 19:38:16 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46929 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbfDSXiP (ORCPT ); Fri, 19 Apr 2019 19:38:15 -0400 Received: by mail-lj1-f194.google.com with SMTP id h21so5740832ljk.13 for ; Fri, 19 Apr 2019 16:38:14 -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=dpJdQEss2Hf2fCZ1JCBrqDkW/3xv13oIKhlDU7E2du4=; b=CaOcR/pqmdOo7x7iaoApuISj/gPfGJ1QkMjs+AMskAF1vinGAZ74i09Pgh3y1pDKhB 79mOsOg744xJsQSz2RfFZzV+ThidOBRe5rh4e6uKUGF9ToOb+0Ag16watR+YN//OjFU/ ZjapE5ucktlB/FOc/NeRcsKgdo0hIXyeNa3Qg= 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=dpJdQEss2Hf2fCZ1JCBrqDkW/3xv13oIKhlDU7E2du4=; b=PZYrriCPYvl6i17Kc+tKiNBveH3c3j1T3b7mrTr4W4HlCaBMBD7vlohZcGs1yqgIHC IHvz/NSPOKq24erxlKbrLmYzXfIH5DuA7QOa+I7XXLic3clTwyVciTvuvP1soLpEAtNE kpoYWgyDYiigicna1mpbgSumxUxJJEiI5jMfuidjG5kJ5BkZFJi71SZ7kYS3oQFQZzV1 u6qfG/9pKlOsHHm+52poUeupulPUL86f+Ub/40ktpiXmm5bwq3PORJ/dX4g+Op2UT0QS jp4zZMktTEazSwkq7AaznysILVIDhnHrLRLor0IzYTMpiAk98urvJF69YXk/RUA+IPGg 1PYg== X-Gm-Message-State: APjAAAWVpKB0hbAacVwwHupaG+YLALjil/+e/YtejyhaULSEG33aZKsK SNA4M1TWAyMrS2BWpnxUPdPx7w+VB40= X-Received: by 2002:a05:651c:14b:: with SMTP id c11mr3599317ljd.185.1555717093028; Fri, 19 Apr 2019 16:38:13 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id r19sm1338811lja.83.2019.04.19.16.38.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 16:38:12 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id r24so5778406ljg.3 for ; Fri, 19 Apr 2019 16:38:12 -0700 (PDT) X-Received: by 2002:a2e:22c4:: with SMTP id i187mr3561786lji.94.1555716778880; Fri, 19 Apr 2019 16:32:58 -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: From: Linus Torvalds Date: Fri, 19 Apr 2019 16:32:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC 1/2] Add polling support to pidfd To: Christian Brauner Cc: Joel Fernandes , 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 19, 2019 at 4:20 PM Christian Brauner wrote: > > On Sat, Apr 20, 2019 at 1:11 AM Linus Torvalds > wrote: > > > > 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. > > Which kind of makes sense for process exit. So the historical behavior > here is in our favor and having POLLIN | POLLHUP rather fitting. > It just seems right that POLLHUP indicates "there can be > no more state transitions". Note that that is *not* true of process exit. The final state transition isn't "exit", it is actually "process has been reaped". That's the point where data no longer exists. Arguably "exit()" just means "pidfd is now readable - you can read the status". That sounds very much like a normal POLLIN condition to me, since the whole *point* of read() on pidfd is presumably to read the status. Now, if you want to have other state transitions (ie read execve/fork/whatever state details), then you could say that _those_ state transitions are just POLLIN, but that the exit state transition is POLLIN | POLLHUP. But logically to me it still smells like the process being reaped should be POLLHUP. You could also say that the execve/fork/whatever state is out of band data, and use EPOLLRDBAND for it. But in fact EPOLLPRI might be better for that, because that works well with select() (ei if you want to select for execve/fork, you use the "ex" bitmask). That said, if FreeBSD already has something like this, and people actually have code that uses it, there's also simply a strong argument for "don't be needlessly different". Linus