Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Wed, 25 Sep 2002 04:34:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Wed, 25 Sep 2002 04:34:58 -0400 Received: from mx2.elte.hu ([157.181.151.9]:47051 "HELO mx2.elte.hu") by vger.kernel.org with SMTP id ; Wed, 25 Sep 2002 04:34:57 -0400 Date: Wed, 25 Sep 2002 10:48:49 +0200 (CEST) From: Ingo Molnar Reply-To: Ingo Molnar To: Linus Torvalds Cc: "David S. Miller" , , Oleg Drokin , Subject: [patch] pidhash-2.5.38-A0 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1120 Lines: 39 the attached patch removes the cmpxchg from the PID allocator and replaces it with a spinlock. This spinlock is hit only a couple of times per bootup, so it's not a performance issue. Ingo --- linux/kernel/pid.c.orig Wed Sep 25 10:36:13 2002 +++ linux/kernel/pid.c Wed Sep 25 10:38:55 2002 @@ -53,6 +53,8 @@ static pidmap_t *map_limit = pidmap_array + PIDMAP_ENTRIES; +static spinlock_t pidmap_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; + inline void free_pidmap(int pid) { pidmap_t *map = pidmap_array + pid / BITS_PER_PAGE; @@ -77,8 +79,13 @@ * Free the page if someone raced with us * installing it: */ - if (cmpxchg(&map->page, NULL, (void *) page)) + spin_lock(&pidmap_lock); + if (map->page) free_page(page); + else + map->page = (void *)page; + spin_unlock(&pidmap_lock); + if (!map->page) break; } - 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/