lkml.org 
[lkml]   [2002]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] pidhash-2.5.38-A0

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/

\
 
 \ /
  Last update: 2005-03-22 13:29    [W:0.057 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site