]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Convert uid hash to hlist
authorPavel Emelyanov <xemul@openvz.org>
Wed, 19 Sep 2007 05:46:44 +0000 (22:46 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 19 Sep 2007 18:24:18 +0000 (11:24 -0700)
Surprisingly, but (spotted by Alexey Dobriyan) the uid hash still uses
list_heads, thus occupying twice as much place as it could.  Convert it to
hlist_heads.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/sched.h
include/linux/user_namespace.h
kernel/user.c
kernel/user_namespace.c

index f4e324ed2e4478e5282ba3b4c0f33339fc581dd8..6239bc2c2baa61d4ffef54cbd77fa1f294634534 100644 (file)
@@ -593,7 +593,7 @@ struct user_struct {
 #endif
 
        /* Hash table maintenance information */
-       struct list_head uidhash_list;
+       struct hlist_node uidhash_node;
        uid_t uid;
 };
 
index 1101b0ce878f67973d5037f7b651cabf1fb8d28e..b5f41d4c2eec71a3d3c786128f0f980f0b41317d 100644 (file)
@@ -11,7 +11,7 @@
 
 struct user_namespace {
        struct kref             kref;
-       struct list_head        uidhash_table[UIDHASH_SZ];
+       struct hlist_head       uidhash_table[UIDHASH_SZ];
        struct user_struct      *root_user;
 };
 
index e080ba863ae33167ebaf8aecd0b9588a2a9b6acf..add57c7e4c074237572da1b9beaf4592b4488896 100644 (file)
@@ -55,21 +55,22 @@ struct user_struct root_user = {
 /*
  * These routines must be called with the uidhash spinlock held!
  */
-static inline void uid_hash_insert(struct user_struct *up, struct list_head *hashent)
+static inline void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent)
 {
-       list_add(&up->uidhash_list, hashent);
+       hlist_add_head(&up->uidhash_node, hashent);
 }
 
 static inline void uid_hash_remove(struct user_struct *up)
 {
-       list_del(&up->uidhash_list);
+       hlist_del(&up->uidhash_node);
 }
 
-static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
+static inline struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent)
 {
        struct user_struct *user;
+       struct hlist_node *h;
 
-       list_for_each_entry(user, hashent, uidhash_list) {
+       hlist_for_each_entry(user, h, hashent, uidhash_node) {
                if(user->uid == uid) {
                        atomic_inc(&user->__count);
                        return user;
@@ -118,7 +119,7 @@ void free_uid(struct user_struct *up)
 
 struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
 {
-       struct list_head *hashent = uidhashentry(ns, uid);
+       struct hlist_head *hashent = uidhashentry(ns, uid);
        struct user_struct *up;
 
        spin_lock_irq(&uidhash_lock);
@@ -207,7 +208,7 @@ static int __init uid_cache_init(void)
                        0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
 
        for(n = 0; n < UIDHASH_SZ; ++n)
-               INIT_LIST_HEAD(init_user_ns.uidhash_table + n);
+               INIT_HLIST_HEAD(init_user_ns.uidhash_table + n);
 
        /* Insert the root user immediately (init already runs as root) */
        spin_lock_irq(&uidhash_lock);
index 85af9422ea6e0163afd849f59237752825a62406..e7ba1bf8457caed4144f2ad10e2f7a1800aec14c 100644 (file)
@@ -39,7 +39,7 @@ static struct user_namespace *clone_user_ns(struct user_namespace *old_ns)
        kref_init(&ns->kref);
 
        for (n = 0; n < UIDHASH_SZ; ++n)
-               INIT_LIST_HEAD(ns->uidhash_table + n);
+               INIT_HLIST_HEAD(ns->uidhash_table + n);
 
        /* Insert new root user.  */
        ns->root_user = alloc_uid(ns, 0);