[patch] pidhash-2.5.38-A0

From: Ingo Molnar (mingo@elte.hu)
Date: Wed Sep 25 2002 - 03:48:49 EST


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/



This archive was generated by hypermail 2b29 : Mon Sep 30 2002 - 22:00:22 EST