Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2100096imu; Fri, 23 Nov 2018 04:42:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/X9upKhV/0PyM/jDX3+zs2UvOJ3Irw1pta80Ga7/jkzgQcVRU7MYkT4kDGbuTk8yQKUwsut X-Received: by 2002:a17:902:ba83:: with SMTP id k3-v6mr14999987pls.200.1542976934036; Fri, 23 Nov 2018 04:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542976934; cv=none; d=google.com; s=arc-20160816; b=NnVUuaRBuxQdywpazoUHFFsvVhV6PeLl1tmh1He1lFhbzfxEzkqwzEQ9icFWGXfu3M boMDNeftdtdswBgJTvGXaqZJWlHwSgA1dEn/O8BKGuU/CHus7pEbDFSiU6hEzAWjZGI8 UAIG9hpd0BtA0bd66o/6xEKFZBJiFNtHjC+1LYFU3YiC/g1h/Zsn9rrK2pt1sB4IR35K P8ZHsceYqc8l9GCchZHpHVETzJ2/GzJIK454T8mqC9jGVZ4TL7hjVzHqNvENMCKwB8on OOXBhJsdOuqMFXSutoldTNb40b0yWw0vdANDwQVs7kglmS3QgLunkot9uTdQIZS/DO+R 9Ceg== 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=Z3EPiPu1X+xb8IBEGNK1cO+GoiCEHmNlRUQ2fgYN8M0=; b=GTyUKAa00J/EnpoK2Ht2UZ8Pd1akm92sSp4/t3KptqbUidv1jo5Q6XDFl+/p3JTGQF PZofsnGfbyG4xvMDnX0AJibn+88G/S1BL6Y86K/3C9dPa8ez4yq01TgJR3QI0Bttof2o PRN3Rpw4NsFOSy5RvX7eb8hxR/DTHrS61E3PHkPCwtUG95ptrtNCAw4XVFYJuxlVQoiw AhVEVmjkEjXMiSuaxnMpiR0nufyjlKEVtKe5HK5K9CIm8NHXr23LrPdpZiBwj+bt2vEX IImHUSCfvoZYA1Sn72B/fQF/rkdro9D3iGSEJ8gXcJ0bq0IdCiC0WocwmV2QhmDhWGEK N7Wg== 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 n1si50583112pgq.36.2018.11.23.04.41.50; Fri, 23 Nov 2018 04:42:13 -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 S2394728AbeKVWGA (ORCPT + 99 others); Thu, 22 Nov 2018 17:06:00 -0500 Received: from aws.guarana.org ([13.237.110.252]:34278 "EHLO aws.guarana.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394706AbeKVWGA (ORCPT ); Thu, 22 Nov 2018 17:06:00 -0500 X-Greylist: delayed 448 seconds by postgrey-1.27 at vger.kernel.org; Thu, 22 Nov 2018 17:05:58 EST Received: by aws.guarana.org (Postfix, from userid 1006) id DF51DA18AB; Thu, 22 Nov 2018 11:19:30 +0000 (UTC) Date: Thu, 22 Nov 2018 11:19:30 +0000 From: Kevin Easton To: Daniel Colascione Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, timmurray@google.com, primiano@google.com, joelaf@google.com, Jonathan Corbet , Andrew Morton , Mike Rapoport , Roman Gushchin , Vlastimil Babka , "Dennis Zhou (Facebook)" , Prashant Dhamdhere , "Eric W. Biederman" , "Steven Rostedt (VMware)" , Thomas Gleixner , Ingo Molnar , Dominik Brodowski , Pavel Tatashin , Josh Poimboeuf , Ard Biesheuvel , Michal Hocko , MatthewWilcox@ip-172-31-15-78 Subject: Re: [PATCH] Add /proc/pid_generation Message-ID: <20181122111930.GA7164@ip-172-31-15-78> References: <20181121201452.77173-1-dancol@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181121201452.77173-1-dancol@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. I see downthread this patch has been withdrawn, but nonetheless I'm still curious - does this actually solve the problem? It seems to me that a PID could be reused within a scan even if the generation number remains the same at the beginning and end of a scan: Say you have a very long-lived task with PID 500 allocated in generation 0. The PID creation has since wrapped and we are now allocating from the start of the range again, with generation 1. We begin a scan of /proc, read the generation (1) and at this point, our task dies and PID 500 is then reallocated to a new task. We finish our scan, generation is still 1 but PID 500 is now ambiguous. Am I wrong? - Kevin