From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759582Ab0FJQjU (ORCPT ); Thu, 10 Jun 2010 12:39:20 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:47264 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752225Ab0FJQjR convert rfc822-to-8bit (ORCPT ); Thu, 10 Jun 2010 12:39:17 -0400 MIME-Version: 1.0 In-Reply-To: References: <20100609210014.7464.92234.stgit@bumblebee1.mtv.corp.google.com> <1276119207.1745.154.camel@laptop> Date: Thu, 10 Jun 2010 09:39:02 -0700 Message-ID: Subject: Re: [PATCH] Fix a race in pid generation that causes pids to be reused immediately. From: Linus Torvalds To: Salman Qazi Cc: Michel Lespinasse , Peter Zijlstra , akpm@linux-foundation.org, mingo@elte.hu, linux-kernel@vger.kernel.org, tytso@google.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 9, 2010 at 10:55 PM, Salman Qazi wrote: > On Wed, Jun 9, 2010 at 10:17 PM, Michel Lespinasse wrote: >> >> As shown by the three compares version, the question here does not depend on >> the max_pid value. So, we can replace max_pid with any integer >= max_pid >> without changing the result. I like the logical argument, and cannot fault it. >> This is nice because, replacing max_pid with >> 2^32, the expression simplifies to: >> >> (unsigned)(a - base) < (unsigned)(b - base) >> >> I think I like this form after all :) Sounds right to me. > I don't mind doing this, if nobody disagrees.  Should be fine with a > comment on top explaining the intention? Yes. And lots of testing (including, very much, the whole max_pid roll-over, of course). The logic of it all seems impeccable, but nothing beats testing. Thanks, Linus