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=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham 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 1BE27C43441 for ; Thu, 22 Nov 2018 11:27:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D89A12087E for ; Thu, 22 Nov 2018 11:27:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D89A12087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=guarana.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394732AbeKVWGA (ORCPT ); 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