]> err.no Git - linux-2.6/commitdiff
[PATCH] free_uid() locking improvement
authorAndrew Morton <akpm@osdl.org>
Fri, 24 Mar 2006 11:15:47 +0000 (03:15 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 24 Mar 2006 15:33:20 +0000 (07:33 -0800)
Reduce lock hold times in free_uid().

Cc: Ingo Molnar <mingo@elte.hu>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/user.c

index d9deae43a9abbb0f8dfaeeb078e8fb83311bc481..2116642f42c62a2f6b02a7238a336d82621ad31f 100644 (file)
@@ -105,15 +105,19 @@ void free_uid(struct user_struct *up)
 {
        unsigned long flags;
 
+       if (!up)
+               return;
+
        local_irq_save(flags);
-       if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
+       if (atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
                uid_hash_remove(up);
+               spin_unlock_irqrestore(&uidhash_lock, flags);
                key_put(up->uid_keyring);
                key_put(up->session_keyring);
                kmem_cache_free(uid_cachep, up);
-               spin_unlock(&uidhash_lock);
+       } else {
+               local_irq_restore(flags);
        }
-       local_irq_restore(flags);
 }
 
 struct user_struct * alloc_uid(uid_t uid)