Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp760831yba; Thu, 16 May 2019 08:30:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyc8D5zIBCdJQ6tzAM7Awr57FGy0+O7YGp2sqODxBjGsDRkF689xrdWJy/0SiDXVQTRIlSr X-Received: by 2002:a63:5fcc:: with SMTP id t195mr14682120pgb.120.1558020650122; Thu, 16 May 2019 08:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558020650; cv=none; d=google.com; s=arc-20160816; b=swqEBT7F2cq2r0yEvnMgcv3GXaHmcRw+sg2XiykY9HF0p+G+l3k21LrKNcsaCA/AJE K7HIKIXBysvUeKX9+qBRS1uLpNAeKHSVebOdVld7Y58yvp/3IEmONLOPn5BbNUvkBqPu BO//S+/VeysullKYgKTNFiDtcWgPd4miAZ0VAg0UbtWPDO5WPmSmCPIneRLgJGpkbuCV ABh3mA+pglLOqOOybB1AhVF7JKv/NZfb3tV7y+C4J7951MbyKfxCUv9iieiRkyoq4gtb hU8iUALKflkXj58Khw1Ld2605jaEbqaDutqLMUKcfD6BRr8EFDmzdbf3z7yKpbZxXTQR RiwQ== 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=ZqfBKUXmncS+f99++ptXSxdqupLw9zmhEoHFhOKQ3+w=; b=ixleFNnKGEzyxfFV4uDMeTzbI8I0Zk2f4Gbn3I507nkvqM1B88WFDMIYKCFc+2ecuu 1uNW7UBaxPezYqcT1asZNZeiFB/LG36fABhZ/EX1YbysUPsJY5Eq5vctgcioziHYFYKA lnXpihq7NRTrhb+FKx+DHiQmtmDf4Juxpyy6Tf2HoRX8ipNaHZwSW61+4QuQra69uwrc +/2fJgLqScSGnEZ6uyBlx6pxu8q/VVAQDmREIohelUcPndnno+0PNTvQNRf8wFk7q4aP reEL9ZsO+vc7W6lTTk9df8mFyi/pcnVzs6DYSmrGgOZu5kB1VEyccMUrt5LJ0x1ubp4u StbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b="TH4z/rM7"; 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 s24si874230pfd.78.2019.05.16.08.30.32; Thu, 16 May 2019 08:30:50 -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="TH4z/rM7"; 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 S1727771AbfEPP3W (ORCPT + 99 others); Thu, 16 May 2019 11:29:22 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:44112 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbfEPP3V (ORCPT ); Thu, 16 May 2019 11:29:21 -0400 Received: by mail-ed1-f65.google.com with SMTP id b8so5784021edm.11 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=ucagzLRmjkXyJvDXm8zjLj9r3uZz/AQfGzs6X9ghtacl+F5WyuW2OPn8sliReXmgg1 4h+5EEF4We7Ap7UPUZWOtG3j9PhzKvcpD6Hnvp4gpnYPohBhmsOaoq33RSDyIbGeNurj ZSTl2Fps9LDZ+0dLoHTe5Ase2DBLTYByKMGgEZ942vlT3Y3HvK0+jV5tnIk0XZ8uzHBh yM6ytXy97T54yfw02EiO4Mf8tv3VXurDKUFKkM8l51H77S9j6jDzDY3J0HCPYJeGMzC/ E42IV9vmr5/H6kUiLMAMRJSencTgkIPNAdBwll+mNhFt7k08/0nb8sjZQ4PSoapeY5FF 31Jw== X-Gm-Message-State: APjAAAUS+KUOyTgB+SWpKyV/QnmxGUT60XYyelVxPMjG8tK9FIq8r3C/ sTrDWpagMrXvzqHHBBRb29VpGw== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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