Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp927185pxk; Thu, 3 Sep 2020 16:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhxQ2fLwoFTj0/f3jr7Z3ESmn8ldFTc3r5rfuFAdjm1HuKqlNZRRrbYgBbZ3pPuFGyKfdQ X-Received: by 2002:a17:906:5f96:: with SMTP id a22mr4936228eju.335.1599177502367; Thu, 03 Sep 2020 16:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599177502; cv=none; d=google.com; s=arc-20160816; b=j3SRRBORAQLQKnGIngK2/M7rpsPmqujATIU5bW7cE6gk3pQNymv9coaWeKU6eZQu0u swXnNHVmHpjCSM9XUmh9aH8jmqZD90MLzP0Qvh+H+LjWk6v2cBzv4M8VBy/xW+7zJ3rB 34dmHR8w/XWKwgi9lNP2DyCSltsXhtHW5bxSonbXB6oqzeldMTv22fqHQmbW3aNdnwnc mE/V8QBq2/uTIJPPXuRwcejvFfJAVjkSZDdfSWb9euvhlMG3pXqZ+LsRYQCGg8EftwK6 pMqWN/pY4AMJxo6Lkbz0BbpOAIzdI7YtmIlYSEyFYyosLFTR84KnbWkjOTBliRnIDF8i WTIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=FAJEzFycAzrcPbeP+J0XiWcizQT6WcyqOmMUlzaZ4HY=; b=dtum/HkjgTVd+SeGV0xiKpE85fDBsTTPUX9fZAQ6yddAchFF1JYiznP88R00N95Rax XY5t5vzkk4BE8F9AuBYQ/YmxCl4Vz9kO+6W/e5ZRHdSzNkZ9ucvWZgSkwtvwLuxB+TJ0 FwJeepqb28ikCFYK3aAetL6yJujqbjLflYopeze8h1qGXcgY3WiKF1jMnejGirF9l6eK Dr19xqe1VIXRqDxV6URN3UmBdXqUXOLAiHG9PaawWOkfkjIri6yNWm3t9RAxjkMd/TQV 37qpf3lRMh4J8ruEOQCKNxVz1qbeheGyZLBO2V53tKcI6EHUiWwsN5Zf928L6CaGNcmI 4qKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb15si2925993ejb.366.2020.09.03.16.57.59; Thu, 03 Sep 2020 16:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729581AbgICXzA (ORCPT + 99 others); Thu, 3 Sep 2020 19:55:00 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:39655 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgICXy7 (ORCPT ); Thu, 3 Sep 2020 19:54:59 -0400 X-Originating-IP: 50.39.163.217 Received: from localhost (50-39-163-217.bvtn.or.frontiernet.net [50.39.163.217]) (Authenticated sender: josh@joshtriplett.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 6C0091C0002; Thu, 3 Sep 2020 23:54:48 +0000 (UTC) Date: Thu, 3 Sep 2020 16:54:45 -0700 From: Josh Triplett To: Christian Brauner Cc: Oleg Nesterov , linux-kernel@vger.kernel.org, Christian Brauner , "Peter Zijlstra (Intel)" , Ingo Molnar , Thomas Gleixner , "Eric W. Biederman" , Kees Cook , Sargun Dhillon , Aleksa Sarai , linux-kselftest@vger.kernel.org, Jens Axboe , linux-api@vger.kernel.org, Jann Horn Subject: Re: [PATCH v2 2/4] exit: support non-blocking pidfds Message-ID: <20200903235445.GB210207@localhost> References: <20200902102130.147672-1-christian.brauner@ubuntu.com> <20200902102130.147672-3-christian.brauner@ubuntu.com> <20200903142241.GI4386@redhat.com> <20200903153847.zvi5dzwj6v4eap6i@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903153847.zvi5dzwj6v4eap6i@wittgenstein> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 03, 2020 at 05:38:47PM +0200, Christian Brauner wrote: > On Thu, Sep 03, 2020 at 04:22:42PM +0200, Oleg Nesterov wrote: > > On 09/02, Christian Brauner wrote: > > > > > > It also makes the API more consistent and uniform. In essence, waitid() is > > > treated like a read on a non-blocking pidfd or a recvmsg() on a non-blocking > > > socket. > > > With the addition of support for non-blocking pidfds we support the same > > > functionality that sockets do. For sockets() recvmsg() supports MSG_DONTWAIT > > > for pidfds waitid() supports WNOHANG. > > > > What I personally do not like is that waitid(WNOHANG) returns zero or EAGAIN > > depending on f_flags & O_NONBLOCK... This doesn't match recvmsg(MSG_DONTWAIT) > > and doesn't look consistent to me. > > It's not my favorite thing either but async event loops are usually > modeled around EAGAIN so I think this has benefits. Josh can speak more > to that. I wouldn't expect the same application to use both WNOHANG and O_NONBLOCK, since the latter makes the former unnecessary. I'd have no objection if WNOHANG continued to have the same "return 0 and you have to check the structure to figure out what that means" behavior regardless of the fd flags, for compatibility with an application or library that expects that behavior with WNOHANG and didn't expect the return value to change with a non-blocking fd. waitid could just return EAGAIN on a non-blocking fd if *not* passed WNOHANG, which would make pidfd Just Work in non-blocking event loops.