Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3837992img; Mon, 25 Mar 2019 20:04:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPxmauNicYX9EjG0dE66lbfDEobQ+i/aWV6h7TZeoMJ5HzYwjsymi6EZGZxSMNl7Nj5eWI X-Received: by 2002:a17:902:b48d:: with SMTP id y13mr28794481plr.310.1553569445395; Mon, 25 Mar 2019 20:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553569445; cv=none; d=google.com; s=arc-20160816; b=MPlvsop6kBH+r1d8ODFibSk5X3y/EleZvXStbb4CQ1T+yqCPkaL3XY1vv0Vm2CtGTb jyr+kkTIJcYT3GYvljs41xFDXXGY4V9MjQ86/ZGPo1x2l1LEhNgKDOzVGvd7SV7RpiSn fIRXl0UxexOeofdL4ulqfI/egNctTZzPqJf/ytNF2lrPyY8tR3ZtBexlbTGH4+9tEHNZ L1R9einAYc4LvM5HoowjDxSOTkiHjBkn9y3s3d+pvKR9r9WxtRbOOWPTkCHcJUYzToS0 axD835fl5fUhzby3vJMT2tzZVbldj3fv9wJeH1aJqoYYTbSRVSB8HcCCtCCNbr/53REV JauQ== 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=wJSCE91nRq7dxmP8eW+epFcXHvqxYHPonMa2hKnFAtQ=; b=ai/oaHHORh95NDK5HLo4UrEUBXRv/LM/fLZGMYZV3/g6F2kL981uWtgdVOJHKe3mMY ah89gG6rmF62xZlk6s+AZsJoiPRP78F+g9LHc7iIGoFk9U18RHvDB6RW+/JalkTcK8nV /XIp76Eq759qbOCExkB+ealxJO7Jm/zh2lJLjtRn1g5VbrbfWwyO68snSIM4toceUBUZ My/2YoThiCNt7iWuEJx4JAJWFHw939GY/Q2XORE7ZGN1abJo/HpK5/QJSCTTfOXFrWk1 +3NYSCSGXf0Jhp0xSC1fd0VUqzg5Xrk0cYbF1uOJt6xpUtOKR00I9IS3rKLN0cwX9dOK SBDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=yq8dP6tB; 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 y5si7881534plp.192.2019.03.25.20.03.47; Mon, 25 Mar 2019 20:04:05 -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=yq8dP6tB; 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 S1730273AbfCZDDL (ORCPT + 99 others); Mon, 25 Mar 2019 23:03:11 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40166 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbfCZDDL (ORCPT ); Mon, 25 Mar 2019 23:03:11 -0400 Received: by mail-pl1-f195.google.com with SMTP id b11so917639plr.7 for ; Mon, 25 Mar 2019 20:03:11 -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=wJSCE91nRq7dxmP8eW+epFcXHvqxYHPonMa2hKnFAtQ=; b=yq8dP6tBcCJ8vtGQy8q04TNHt7N8uSPuRg3f1Nd5rlzJVuPzCeu7LS0OwxbE03FCtf Izf+CdjKGS5rTmiav6Z1GwSydOd3/6SlgMYZKkr8RGH+6A6MR/fAQN8iWlPWIi9OjWXo eFMHL0bk8ZILwCY93M1ItFmh43pqHXus9jyH8= 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=wJSCE91nRq7dxmP8eW+epFcXHvqxYHPonMa2hKnFAtQ=; b=L57sAX/HbWMu0Kp9Q9DGNkFxpfxm0ROZbSob5q7yfWMD+cU9S/7O5122uxuNmufHVm jBK9fWWlHdxkhJq9yRnScLxYxDPuzIAHjOrjfhqCGTQSHeSNUAC6qpEkTPiYaFE+LYLv QcqlTEvYBJQkYVK2PWQ9+VlS2cI+Pr50akG7kl1lTul0MSkJXIeJdnVw3+T9/fLUrsHe byTVvKDYfgYF+fO2QVPqIn4wvFMhU0Sbn4TjIRI/lNhuBPh99IGeZdIV3smS59WzLuni dUymqfbYmOwZwwSUwW/jdfhwcmxTBJ5mKgsEPIfLfgc2csyBqazA/UtNDVB6fkjFZkeQ DEbg== X-Gm-Message-State: APjAAAUz0tYmNU6YUH/DY/1is/yCTH3gbwmqWL0DCLN7kEJTrC3a/i4G M7ls+FuVe6+WVzDge8/O2NlWog== X-Received: by 2002:a17:902:aa5:: with SMTP id 34mr27609815plp.302.1553569390274; Mon, 25 Mar 2019 20:03:10 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id 140sm22599378pfb.55.2019.03.25.20.03.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2019 20:03:08 -0700 (PDT) Date: Mon, 25 Mar 2019 23:03:07 -0400 From: Joel Fernandes To: Jonathan Kowalski Cc: Jann Horn , Christian Brauner , Daniel Colascione , Konstantin Khlebnikov , Andy Lutomirski , David Howells , "Serge E. Hallyn" , "Eric W. Biederman" , Linux API , linux-kernel , Arnd Bergmann , Kees Cook , Alexey Dobriyan , Thomas Gleixner , Michael Kerrisk-manpages , "Dmitry V. Levin" , Andrew Morton , Oleg Nesterov , Nagarathnam Muthusamy , Aleksa Sarai , Al Viro Subject: Re: [PATCH 0/4] pid: add pidctl() Message-ID: <20190326030307.GA213200@google.com> References: <20190325162052.28987-1-christian@brauner.io> <20190325173614.GB25975@google.com> <20190325201544.7o2kwuie3infcblp@brauner.io> <20190325211132.GA6494@google.com> <20190325214338.GA16969@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 Mon, Mar 25, 2019 at 09:54:58PM +0000, Jonathan Kowalski wrote: > On Mon, Mar 25, 2019 at 9:43 PM Joel Fernandes wrote: > > > > On Mon, Mar 25, 2019 at 10:19:26PM +0100, Jann Horn wrote: > > > On Mon, Mar 25, 2019 at 10:11 PM Joel Fernandes wrote: > > > > > > But often you don't just want to wait for a single thing to happen; > > > you want to wait for many things at once, and react as soon as any one > > > of them happens. This is why the kernel has epoll and all the other > > > "wait for event on FD" APIs. If waiting for a process isn't possible > > > with fd-based APIs like epoll, users of this API have to spin up > > > useless helper threads. > > > > This is true. I almost forgot about the polling requirement, sorry. So then a > > new syscall it is.. About what to wait for, that can be a separate parameter > > to pidfd_wait then. > > > > This introduces a time window where the process changes state between > "get pidfd" and "setup waitfd", it would be simpler if the pidfd > itself supported .poll and on termination the exit status was made > readable from the file descriptor. It is much cleaner to add a new pidfd_wait syscall for this as discussed in the other thread. Adding .poll directly to the pidfd would seem to complicate the blocking configuration. Do we block until the task is a zombie or until it is dead? That is not possible to specify easily. Also if we need to return other types of information from the pidfd, not just exit state, then it is not clear whether blocking on a pidfd just purely on exit status makes sense. It is much cleaner to add a new pidfd_wait syscall giving it a pidfd, specify what to block on (EXIT_DEAD or EXIT_ZOMBIE or both) and then return a wait fd that can be read/blocked and returning all the needed information on unblock. > Further, in the clone4 patchset, there was a mechanism to autoreap > such a process so that it does not interfere with waiting a process > does normally. How do you intend to handle this case if anyone except > the parent is wanting to *wait* on the process (a second process, > without reaping, so as to not disrupt any waiting in the parent), and > for things like libraries that finally can manage their own set of > process when pidfd_clone is added, by excluding this process from the > process's normal wait handling logic. The pidfd_wait logic being discussed does not depend on or affects the autoreap behavior. This wait is not the traditional wait family of calls. It is for just getting notified about reading all the exit state of a task. Once I post the code, it will be clear. And I'll CC you.. thanks, - Joel