Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert uid hash to hlist

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>

authored by

Pavel Emelyanov and committed by
Linus Torvalds
735de223 d8a4821d

+11 -10
+1 -1
include/linux/sched.h
··· 593 593 #endif 594 594 595 595 /* Hash table maintenance information */ 596 - struct list_head uidhash_list; 596 + struct hlist_node uidhash_node; 597 597 uid_t uid; 598 598 }; 599 599
+1 -1
include/linux/user_namespace.h
··· 11 11 12 12 struct user_namespace { 13 13 struct kref kref; 14 - struct list_head uidhash_table[UIDHASH_SZ]; 14 + struct hlist_head uidhash_table[UIDHASH_SZ]; 15 15 struct user_struct *root_user; 16 16 }; 17 17
+8 -7
kernel/user.c
··· 55 55 /* 56 56 * These routines must be called with the uidhash spinlock held! 57 57 */ 58 - static inline void uid_hash_insert(struct user_struct *up, struct list_head *hashent) 58 + static inline void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent) 59 59 { 60 - list_add(&up->uidhash_list, hashent); 60 + hlist_add_head(&up->uidhash_node, hashent); 61 61 } 62 62 63 63 static inline void uid_hash_remove(struct user_struct *up) 64 64 { 65 - list_del(&up->uidhash_list); 65 + hlist_del(&up->uidhash_node); 66 66 } 67 67 68 - static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent) 68 + static inline struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent) 69 69 { 70 70 struct user_struct *user; 71 + struct hlist_node *h; 71 72 72 - list_for_each_entry(user, hashent, uidhash_list) { 73 + hlist_for_each_entry(user, h, hashent, uidhash_node) { 73 74 if(user->uid == uid) { 74 75 atomic_inc(&user->__count); 75 76 return user; ··· 119 118 120 119 struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid) 121 120 { 122 - struct list_head *hashent = uidhashentry(ns, uid); 121 + struct hlist_head *hashent = uidhashentry(ns, uid); 123 122 struct user_struct *up; 124 123 125 124 spin_lock_irq(&uidhash_lock); ··· 208 207 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 209 208 210 209 for(n = 0; n < UIDHASH_SZ; ++n) 211 - INIT_LIST_HEAD(init_user_ns.uidhash_table + n); 210 + INIT_HLIST_HEAD(init_user_ns.uidhash_table + n); 212 211 213 212 /* Insert the root user immediately (init already runs as root) */ 214 213 spin_lock_irq(&uidhash_lock);
+1 -1
kernel/user_namespace.c
··· 39 39 kref_init(&ns->kref); 40 40 41 41 for (n = 0; n < UIDHASH_SZ; ++n) 42 - INIT_LIST_HEAD(ns->uidhash_table + n); 42 + INIT_HLIST_HEAD(ns->uidhash_table + n); 43 43 44 44 /* Insert new root user. */ 45 45 ns->root_user = alloc_uid(ns, 0);