projects/linux·commit 36f57413

[PATCH] free_uid() locking improvement

36f57413 · Andrew Morton <[email protected]> · 2006-03-24 03:15:47 -08:00

Reduce lock hold times in free_uid().

Cc: Ingo Molnar <[email protected]>
Cc: "Paul E. McKenney" <[email protected]>
Cc: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
36f574135e36b86bb6ae794bf1d0fce3efa5601f
Parents
3cf64b93

Changes

1 files changed · +7 −3

FileStatusAddDelContent
kernel/user.cmodified+7−3View file

kernel/user.c

View file
diff --git a/kernel/user.c b/kernel/user.c
index d9deae4..2116642 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -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)