Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2084879yba; Mon, 15 Apr 2019 04:44:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSueKwMIRgsL4W6RDqKvT08Qgn4HQzQiTah51xF1mjQvoQGW58Me/ny2thwCNM/ESMGwK7 X-Received: by 2002:a65:554e:: with SMTP id t14mr59190274pgr.107.1555328699078; Mon, 15 Apr 2019 04:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555328699; cv=none; d=google.com; s=arc-20160816; b=v1iaYjTMs1fnU78qkp9p9Qa8wUE4Vfvzjh4+yNzKgEYzuQnEe2uPHBhqiypmc1UX2r t4C4R7ARw/8dUFJidK+Wg3MKgrKmXj6Nm0mVA7WA03ilsyWMum0LNnrEcQW10K0vZIfc 4sAN4EpIGNld12NcfHCi4k/iKw1OIKnwZmQU/ja15t/RjZ2cB80bQ4lcZTIqBZ14h/75 JdxNkLG+tFqXqeqFXyjpazJeoGMnSgny/9taDNFZBsyCLyRMhJVctSSJjlDueveS6gp9 ZFhCzwaZhgiL1jZEqInrF6dO7cgvyoLbMK73PgzagYHZvDRv9dLNnU9JqqKnBhWO9rTq ZSMw== 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=cVSPkvt9BqtnPlPL39TJHMRVFb8x0A01KTK+jYGWGsg=; b=s4G46MoaI5vl/jl390YNIwxcF3evGP7RWIj+0gVGMgddqv5IDV+WTNyTM/gnlLSFwn YrHiCTZsUyM56d1Mp3lvXYUiWG8RnVDzcwize/qT+XwXBIex2/X7rPo2iYcXq8l6UofE ea7nWMjbpze0xJYIhpoHIJ/lnib47LDn6S8TDuE5eJVAUcghzPpecCEjUWYh9crEd+Fk R7mdR0y9z0goC3nbicLzs4tUa5E6RNSaKmRH0fM/R3bpRquj50RL5EN4BfK14WMNqBl8 BnA2s1dFPyU1UewWqngnd+3siEc3HQheeIh/FS97yUrwoBvwBJa4cfDewmnawu8XA3i8 LYjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=dhB9HCr6; 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 t6si43267634pgt.476.2019.04.15.04.44.42; Mon, 15 Apr 2019 04:44:59 -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=@brauner.io header.s=google header.b=dhB9HCr6; 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 S1727417AbfDOLmT (ORCPT + 99 others); Mon, 15 Apr 2019 07:42:19 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:37351 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727409AbfDOLmQ (ORCPT ); Mon, 15 Apr 2019 07:42:16 -0400 Received: by mail-it1-f194.google.com with SMTP id u65so26053383itc.2 for ; Mon, 15 Apr 2019 04:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cVSPkvt9BqtnPlPL39TJHMRVFb8x0A01KTK+jYGWGsg=; b=dhB9HCr6Qpn52S4osyplpy49jFsOV4SLfupn7LDbKBuaQ22jERlQ1O1ZRAbY4JUEgV rmnpgaXda4P4j/PHZKlo/Cn6JR7TUX8cFmvx4exoufyeQCnaHDo0OS4BwF6tsX1spHoJ Rpn7+7adfs+Gdw0j/2voVJcYDptVGNyUTyb55sGG2V31WbvssxxndzFYLRK/7pHvQr13 cfhQH+P7gXFgmXy6ylU+VCIDLfJt9qO/U/rjCiYhQ8R16MNHQbw2igtCIS3rCG/rjMzm fL7LzQ4U/D4fmkfClgLSXPI890y0T8iheaytBdYl40djQXGX7wNEMq9jfGxMuJBwPSg0 bGSQ== 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=cVSPkvt9BqtnPlPL39TJHMRVFb8x0A01KTK+jYGWGsg=; b=ar2goth7mwIIZ87S2zj3j3qvFsynAbNKCpXyMUgIO+JBe5LRwhifXK6ixLXRfVgkBk 4u5fJHmmDcPl83IVzEtTxjc1JEpJ+aZYOKmx4DcDZ0vuQpwZLcgmzSQ1KRp9TgBH9lcU lOLdbxU90ukJDtWGbL1dAYLTFdgUw7oKK/yPCBZ8C9U2ewlzZKF7dMSmCZxaEYdFYM5S Ivke3MuFLeAuhgXM2K64ula36aM/KPo826j034XeDe/6KIeS50MccO7glQ0C3w2HdMxp re5xEB5niopdedQG/SOP95u6SW4maUPf8ScPfFzSs21qNlfBQQEuXajaAQDFYCnosgtp b3eQ== X-Gm-Message-State: APjAAAUawj018ndC3YkAiVxGjGYium5/xiv73+7j0/Ffo3mjFeEAwEQ2 ytpITKrKhF6NBe6RFqNdKQg7Ww== X-Received: by 2002:a24:2e0a:: with SMTP id i10mr21474472ita.162.1555328535032; Mon, 15 Apr 2019 04:42:15 -0700 (PDT) Received: from brauner.io ([208.54.80.237]) by smtp.gmail.com with ESMTPSA id v19sm18858196iol.27.2019.04.15.04.42.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Apr 2019 04:42:14 -0700 (PDT) Date: Mon, 15 Apr 2019 13:42:06 +0200 From: Christian Brauner To: Oleg Nesterov Cc: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, jannh@google.com, dhowells@redhat.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, serge@hallyn.com, luto@kernel.org, arnd@arndb.de, ebiederm@xmission.com, keescook@chromium.org, tglx@linutronix.de, mtk.manpages@gmail.com, akpm@linux-foundation.org, cyphar@cyphar.com, joel@joelfernandes.org, dancol@google.com Subject: Re: [PATCH 2/4] clone: add CLONE_PIDFD Message-ID: <20190415114204.ydczeuwmi74wfsuv@brauner.io> References: <20190414201436.19502-1-christian@brauner.io> <20190414201436.19502-3-christian@brauner.io> <20190415105209.GA22204@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190415105209.GA22204@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 15, 2019 at 12:52:09PM +0200, Oleg Nesterov wrote: > On 04/14, Christian Brauner wrote: > > > > @@ -2260,6 +2363,10 @@ long _do_fork(unsigned long clone_flags, > > } > > > > put_pid(pid); > > + > > + if (clone_flags & CLONE_PIDFD) > > + nr = pidfd; > > + > > Well, this doesn't look nice ... > > CLONE_PARENT_SETTID doesn't look very usefule, so what if we add > > if ((clone_flags & (CLONE_PIDFD|CLONE_PARENT_SETTID)) == > (CLONE_PIDFD|CLONE_PARENT_SETTID)) > return ERR_PTR(-EINVAL); > > at the start of copy_process() ? > > Then it can do > > if (clone_flags & CLONE_PIDFD) { > retval = pidfd_create(pid, &pidfdf); > if (retval < 0) > goto bad_fork_free_pid; > retval = put_user(retval, parent_tidptr) > if (retval < 0) > goto bad_fork_free_pid; > } Uhhh Oleg, that is nifty. I have to say I like that a lot. This would let us return the pid and the pidfd in one go and we can also start pidfd numbering at 0.