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=-3.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_NEOMUTT autolearn=unavailable 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 8E31AC04AAF for ; Thu, 16 May 2019 15:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59ABE20657 for ; Thu, 16 May 2019 15:29:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=brauner.io header.i=@brauner.io header.b="TH4z/rM7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727763AbfEPP3V (ORCPT ); Thu, 16 May 2019 11:29:21 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:37807 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfEPP3V (ORCPT ); Thu, 16 May 2019 11:29:21 -0400 Received: by mail-ed1-f68.google.com with SMTP id w37so5849694edw.4 for ; Thu, 16 May 2019 08:29:20 -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=ZqfBKUXmncS+f99++ptXSxdqupLw9zmhEoHFhOKQ3+w=; b=TH4z/rM7ErguN84LC3AmRg3JM/hVu0pzNCfG54H90jzb63FEyWpgQxI/RMgxJKMw0P YMcyNk31xsPD9o3Q8SwKVFbPkeg8kucRDIsE3yDY3iiXnyBwTwnYxeZvDW5/V+wBXU6a 4Whkmp9tF7azl07xuKt/fN1RfMwR7c1B7epJGJ4YizDr1inzgV4yUswyquIaazuD7NSA +Y7PT7f4mQIjQrv4yQyYO9MGe0DD0FnBStZnFHo1gVuPfCi9qKCZU5pU6DsIxSnGA9Ik 9SEOtQn5L4G4624dzeKPE3TTelvggQSyZJ+x/s6KcHf9L4yAiTiSgxh1JqlUq122MXzB 4CVw== 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=ZqfBKUXmncS+f99++ptXSxdqupLw9zmhEoHFhOKQ3+w=; b=jIZzrrc4PkL4sh3JmqvMjcAGuMQ9xq7V1c9F/FeiPCpSngpHvy6SvxDT6r1lBC8v8J ODzUysKe30Y2oAGMbOwDiE/i0J4wLSZ5iprYTX/34kAgzSQHIWzxzCDTeul4SmrWALry PORHpHHvOAspNjZKupARD8nufbla5XBhnYz/uE5WS/CX9WTba9/iaP6bUwRQpFOtBaCg f0bJg5iGyqxsFCHUunjfht12wKIglvZZJoGv0Gpebrm7r+Lz8i8uJALKKUgVO6WMfVCY hx1+sGQvHePa5Cjsu3Jaq/XXv7NDTwUmkVEKeeuAOz0tWXOjufxvkf6krXkStgZuM/je uzTQ== X-Gm-Message-State: APjAAAXPtQDmJUOe5GaM5XDGE3FVbEbf1X4v5PY5uJvxDzYNAxduJy5Q uMXtFsMB28P/eD+Egu0zgIiFdQ== X-Google-Smtp-Source: APXvYqzND3qJO+X7rGwmXjyWOGo7yuQQOnxCqVFCr+1kxGCEKNbb6bF5poI+TQvkmuF3C5Oy1BVzkw== X-Received: by 2002:a50:a886:: with SMTP id k6mr51048650edc.211.1558020559731; Thu, 16 May 2019 08:29:19 -0700 (PDT) Received: from brauner.io ([193.96.224.243]) by smtp.gmail.com with ESMTPSA id b4sm1889513edf.7.2019.05.16.08.29.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 16 May 2019 08:29:19 -0700 (PDT) Date: Thu, 16 May 2019 17:29:16 +0200 From: Christian Brauner To: Oleg Nesterov Cc: Aleksa Sarai , jannh@google.com, viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, arnd@arndb.de, akpm@linux-foundation.org, dhowells@redhat.com, ebiederm@xmission.com, elena.reshetova@intel.com, keescook@chromium.org, luto@amacapital.net, luto@kernel.org, tglx@linutronix.de, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, joel@joelfernandes.org, dancol@google.com, serge@hallyn.com, Geert Uytterhoeven Subject: Re: [PATCH v1 1/2] pid: add pidfd_open() Message-ID: <20190516152915.3t2wofeu3xsyhfbd@brauner.io> References: <20190516135944.7205-1-christian@brauner.io> <20190516142659.GB22564@redhat.com> <20190516145607.j43xyj26k6l5vmbd@yavin> <20190516150611.GC22564@redhat.com> <20190516151202.hrawrx7hxllmz2di@yavin> <20190516152252.GD22564@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190516152252.GD22564@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Thu, May 16, 2019 at 05:22:53PM +0200, Oleg Nesterov wrote: > On 05/17, Aleksa Sarai wrote: > > > > On 2019-05-16, Oleg Nesterov wrote: > > > On 05/17, Aleksa Sarai wrote: > > > > On 2019-05-16, Oleg Nesterov wrote: > > > > > On 05/16, Christian Brauner wrote: > > > > > > With the introduction of pidfds through CLONE_PIDFD it is possible to > > > > > > created pidfds at process creation time. > > > > > > > > > > Now I am wondering why do we need CLONE_PIDFD, you can just do > > > > > > > > > > pid = fork(); > > > > > pidfd_open(pid); > > > > > > > > While the race window would be exceptionally short, there is the > > > > possibility that the child will die > > > > > > Yes, > > > > > > > and their pid will be recycled > > > > before you do pidfd_open(). > > > > > > No. > > > > > > Unless the caller's sub-thread does wait() before pidfd_open(), of course. > > > Or unless you do signal(SIGCHILD, SIG_IGN). > > > > What about CLONE_PARENT? > > I should have mentioned CLONE_PARENT ;) > > Of course in this case the child can be reaped before pidfd_open(). But how often > do you or other people use clone(CLONE_PARENT) ? not to mention you can trivially > eliminate/detect this race if you really need this. > > Don't get me wrong, I am not trying to say that CLONE_PIDFD is a bad idea. > > But to me pidfd_open() is much more useful. Say, as a perl programmer I can easily > use pidfd_open(), but not CLONE_PIDFD. Right, but for a libc, service- or container manager CLONE_PIDFD is much nicer when spawning processes quickly. :) I think both are very good to have. Thanks, Oleg. As always super helpful reviews. :) Christian