Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757921Ab0FIRKZ (ORCPT ); Wed, 9 Jun 2010 13:10:25 -0400 Received: from THUNK.ORG ([69.25.196.29]:43533 "EHLO thunker.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753355Ab0FIRKY (ORCPT ); Wed, 9 Jun 2010 13:10:24 -0400 Date: Wed, 9 Jun 2010 13:10:15 -0400 From: tytso@mit.edu To: Linus Torvalds Cc: Ingo Molnar , Salman , Andrew Morton , peterz@infradead.org, akpm@inux-foundation.org, linux-kernel@vger.kernel.org, tytso@google.com, Thomas Gleixner Subject: Re: [PATCH] Fix a race in pid generation that causes pids to be reused immediately. Message-ID: <20100609171015.GE6162@thunk.org> Mail-Followup-To: tytso@mit.edu, Linus Torvalds , Ingo Molnar , Salman , Andrew Morton , peterz@infradead.org, akpm@inux-foundation.org, linux-kernel@vger.kernel.org, tytso@google.com, Thomas Gleixner References: <20100609062438.29081.91635.stgit@bumblebee1.mtv.corp.google.com> <20100609094850.GA23292@elte.hu> <20100609155041.GD6162@thunk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on thunker.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1053 Lines: 22 On Wed, Jun 09, 2010 at 09:06:37AM -0700, Linus Torvalds wrote: > > That seems to be purely an artifact of the cleverness of avoiding re-doing > the whole loop, no? If we _had_ re-done the whole loop (the "normal" > cmpxchg model), we would have re-started the whole pid search and handled > the overflow in the existing overflow handling code. This brings up a question. If we're going to use a cmpxchg() loop, is there any point to doing the test-and-set game with the bitmap? It should be just as fast to just use cmpxchg as it is to do the test-and-set, and isn't it more likely that various CPU architectures will have the cmpxchg than test-and-set-bit? We might be able to radically simplify alloc_pidmap(). Would that cause a huge problem on some non-Intel architectures, though? - Ted -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/