Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5011030imu; Sun, 25 Nov 2018 14:56:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/XmyI01V5nfU7e70s4KZqPVI5FIgFWglCA7WHyYLkC8laL/kQKq31kSKU5ueCscpKkgMBY3 X-Received: by 2002:a63:2586:: with SMTP id l128mr22660201pgl.104.1543186585049; Sun, 25 Nov 2018 14:56:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543186585; cv=none; d=google.com; s=arc-20160816; b=tzNtenhhKyhxpXUtlH/+lmGyYRveiDVbhOtXe8bTeeUx04cKbic9moURjd2y9aUgGq 1ToIIYjk1CKZySmhu4ZdihW85usnImOtuy3y+eURJ9+Cnp5jyaeE+o2iX9LOtMmziP8f Fr94vqZRodDAU9iuJ3GRJoA5ZYjkOVEBICIjaabrXpWADCmOHe2WDF+PkJ3HIl6MQOVt fZu4HRvyPoA3N7k58ZgyBNAQsDUyi5L5yqCp83T+mijOG+OY5nbKdY6JbShp1kUrEYIZ RfB2T6bxdwqamuS4TA9ZofdezVHsavxplyECGcaVtpeQdpz/yXLHNAWjDuJc8L3fHnRt nlJw== 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; bh=z99qdrTBWp5xMtiUjFw1LBsfraa43zVIrjq+6GmVTsA=; b=lxwjbEHJrxgYwsglrvgLd/0fODPdh3M6NlhYtaZtCC+Du2oZt09G1E8MFJlf7Nbqq7 l+YhIeMgLuveFbryWDLyI3UIW5Cp7P5fM93U53GRYIK29kobzYQrup7PUTd3kTRM5zI6 bcVSXfpanDdPbAWuJDUn/hdhXt1YubRa7Fz+lf37wFv/FahHSQn5ZVTcNa4wexz+/tTU XAVloWBMDwDio7S3Bcfj8A25LoDTBpVcGlgBfQZu25iBh/Agl6lhoztfIL9S3PXz7BYM jM6hnWzvNS0V59Mm80gRjKlPOl7+P8286Zkh0UEArhWaGkbVbh44iwdGqBTAWjvSNifU +0Ng== ARC-Authentication-Results: i=1; mx.google.com; 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 z19si21946190pfc.95.2018.11.25.14.56.10; Sun, 25 Nov 2018 14:56:25 -0800 (PST) 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; 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 S1726138AbeKZJrs (ORCPT + 99 others); Mon, 26 Nov 2018 04:47:48 -0500 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:51412 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbeKZJrs (ORCPT ); Mon, 26 Nov 2018 04:47:48 -0500 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id C13998081B; Sun, 25 Nov 2018 23:55:30 +0100 (CET) Date: Sun, 25 Nov 2018 23:55:33 +0100 From: Pavel Machek To: Matthew Wilcox Cc: Daniel Colascione , linux-kernel , Linux API , Tim Murray , Primiano Tucci , Joel Fernandes , Jonathan Corbet , Andrew Morton , Mike Rapoport , Roman Gushchin , Vlastimil Babka , "Dennis Zhou (Facebook)" , Prashant Dhamdhere , "Eric W. Biederman" , rostedt@goodmis.org, tglx@linutronix.de, mingo@kernel.org, linux@dominikbrodowski.net, pasha.tatashin@oracle.com, jpoimboe@redhat.com, ard.biesheuvel@linaro.org, Michal Hocko , David Howells , ktsanaktsidis@zendesk.com, "open list:DOCUMENTATION" Subject: Re: [PATCH] Add /proc/pid_generation Message-ID: <20181125225533.GB30242@amd> References: <20181121201452.77173-1-dancol@google.com> <20181121203150.GK3065@bombadil.infradead.org> <20181122020633.GN3065@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TRYliJ5NKNqkz5bu" Content-Disposition: inline In-Reply-To: <20181122020633.GN3065@bombadil.infradead.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --TRYliJ5NKNqkz5bu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed 2018-11-21 18:06:33, Matthew Wilcox wrote: > On Wed, Nov 21, 2018 at 12:38:20PM -0800, Daniel Colascione wrote: > > On Wed, Nov 21, 2018 at 12:31 PM Matthew Wilcox w= rote: > > > > > > On Wed, Nov 21, 2018 at 12:14:44PM -0800, Daniel Colascione wrote: > > > > This change adds a per-pid-namespace 64-bit generation number, > > > > incremented on PID rollover, and exposes it via a new proc file > > > > /proc/pid_generation. By examining this file before and after /proc > > > > enumeration, user code can detect the potential reuse of a PID and > > > > restart the task enumeration process, repeating until it gets a > > > > coherent snapshot. > > > > > > > > PID rollover ought to be rare, so in practice, scan repetitions will > > > > be rare. > > > > > > Then why does it need to be 64-bit? > >=20 > > [Resending because of accidental HTML. I really need to switch to a > > better email client.] > >=20 > > Because 64 bits is enough for anyone. :-) A u64 is big enough that > > we'll never observe an overflow on a running system, and PID > > namespaces are rare enough that we won't miss the four extra bytes we > > use by upgrading from a u32. And after reading about some security > > problems caused by too-clever handling of 32-bit rollover, I'd rather > > the code be obviously correct than save a trivial amount of space. >=20 > I don't think you understand how big 4 billion is. If it happens once a > second, it will take 136 years for a 2^32 count to roll over. How often > does a PID roll over happen? Well, the cost of 64-bit vs. 32-bit is really small here... I'd go with 64bits. If you have 1000 CPUs, rollovers may be faster.. Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --TRYliJ5NKNqkz5bu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlv7KGUACgkQMOfwapXb+vKUpACguxRTw5+EBG5s9D4iEpat3sen udYAnRn+k2NI+lNteoHed7ikYIohN7P4 =pK2+ -----END PGP SIGNATURE----- --TRYliJ5NKNqkz5bu--