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=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 CB45AC433E7 for ; Tue, 1 Sep 2020 16:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B076F20767 for ; Tue, 1 Sep 2020 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732007AbgIAQSp (ORCPT ); Tue, 1 Sep 2020 12:18:45 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:54113 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731974AbgIAQSo (ORCPT ); Tue, 1 Sep 2020 12:18:44 -0400 Received: from ip5f5af70b.dynamic.kabel-deutschland.de ([95.90.247.11] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kD8zZ-00015R-Fs; Tue, 01 Sep 2020 16:18:41 +0000 Date: Tue, 1 Sep 2020 18:18:40 +0200 From: Christian Brauner To: Oleg Nesterov Cc: 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, Josh Triplett , Jens Axboe , linux-api@vger.kernel.org, Jann Horn Subject: Re: [PATCH 2/4] exit: support non-blocking pidfds Message-ID: <20200901161840.e5eo33ctmq7zavak@wittgenstein> References: <20200831134551.1599689-1-christian.brauner@ubuntu.com> <20200831134551.1599689-3-christian.brauner@ubuntu.com> <20200901161154.GA4386@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200901161154.GA4386@redhat.com> Sender: linux-api-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Tue, Sep 01, 2020 at 06:11:54PM +0200, Oleg Nesterov wrote: > On 08/31, Christian Brauner wrote: > > > > --- a/kernel/exit.c > > +++ b/kernel/exit.c > > @@ -934,6 +934,7 @@ struct wait_opts { > > > > wait_queue_entry_t child_wait; > > int notask_error; > > + int eagain_error; > > }; > > > > static int eligible_pid(struct wait_opts *wo, struct task_struct *p) > > @@ -1461,6 +1462,8 @@ static long do_wait(struct wait_opts *wo) > > > > notask: > > retval = wo->notask_error; > > + if (!retval) > > + retval = wo->eagain_error; > > if (!retval && !(wo->wo_flags & WNOHANG)) { > > retval = -ERESTARTSYS; > > I must have missed something but I don't understand why do we need > the new ->eagain_error and the change in do_wait(). > > > @@ -1544,6 +1551,11 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop, > > wo.wo_flags = options; > > wo.wo_info = infop; > > wo.wo_rusage = ru; > > + wo.eagain_error = 0; > > + if (f_flags & O_NONBLOCK) { > > + wo.wo_flags |= WNOHANG; > > + wo.eagain_error = -EAGAIN; > > + } > > ret = do_wait(&wo); > > Can't kernel_waitid() simply do > > if (f_flags & O_NONBLOCK) > wo.wo_flags |= WNOHANG; > ret = do_wait(); > if (!ret & (f_flags & O_NONBLOCK)) > ret = -EAGAIN; > > ? Heh, indeed, that's even a smaller patch. Will change to that! Thanks for the review, Oleg! Christia