patch-2.4.0-test12 linux/kernel/user.c

Next file: linux/lib/vsprintf.c
Previous file: linux/kernel/timer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test11/linux/kernel/user.c linux/kernel/user.c
@@ -8,7 +8,6 @@
  * able to have per-user limits for system resources. 
  */
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
@@ -74,29 +73,12 @@
 	}
 }
 
-/*
- * For SMP, we need to re-test the user struct counter
- * after having acquired the spinlock. This allows us to do
- * the common case (not freeing anything) without having
- * any locking.
- */
-#ifdef CONFIG_SMP
-  #define uid_hash_free(up)	(!atomic_read(&(up)->__count))
-#else
-  #define uid_hash_free(up)	(1)
-#endif
-
 void free_uid(struct user_struct *up)
 {
-	if (up) {
-		if (atomic_dec_and_test(&up->__count)) {
-			spin_lock(&uidhash_lock);
-			if (uid_hash_free(up)) {
-				uid_hash_remove(up);
-				kmem_cache_free(uid_cachep, up);
-			}
-			spin_unlock(&uidhash_lock);
-		}
+	if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
+		uid_hash_remove(up);
+		kmem_cache_free(uid_cachep, up);
+		spin_unlock(&uidhash_lock);
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)