Skip to content

Commit

Permalink
[PATCH] free_uid() locking improvement
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Mar 24, 2006
1 parent 3cf64b9 commit 36f5741
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kernel/user.c
Expand Up @@ -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)
Expand Down

0 comments on commit 36f5741

Please sign in to comment.