|
50 | 50 | */
|
51 | 51 | static struct {
|
52 | 52 | struct futex_hash_bucket *queues;
|
53 |
| - unsigned long hashsize; |
| 53 | + unsigned long hashmask; |
54 | 54 | } __futex_data __read_mostly __aligned(2*sizeof(long));
|
55 | 55 | #define futex_queues (__futex_data.queues)
|
56 |
| -#define futex_hashsize (__futex_data.hashsize) |
| 56 | +#define futex_hashmask (__futex_data.hashmask) |
57 | 57 |
|
58 | 58 |
|
59 | 59 | /*
|
@@ -119,7 +119,7 @@ struct futex_hash_bucket *futex_hash(union futex_key *key)
|
119 | 119 | u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4,
|
120 | 120 | key->both.offset);
|
121 | 121 |
|
122 |
| - return &futex_queues[hash & (futex_hashsize - 1)]; |
| 122 | + return &futex_queues[hash & futex_hashmask]; |
123 | 123 | }
|
124 | 124 |
|
125 | 125 |
|
@@ -1127,27 +1127,28 @@ void futex_exit_release(struct task_struct *tsk)
|
1127 | 1127 |
|
1128 | 1128 | static int __init futex_init(void)
|
1129 | 1129 | {
|
| 1130 | + unsigned long hashsize, i; |
1130 | 1131 | unsigned int futex_shift;
|
1131 |
| - unsigned long i; |
1132 | 1132 |
|
1133 | 1133 | #ifdef CONFIG_BASE_SMALL
|
1134 |
| - futex_hashsize = 16; |
| 1134 | + hashsize = 16; |
1135 | 1135 | #else
|
1136 |
| - futex_hashsize = roundup_pow_of_two(256 * num_possible_cpus()); |
| 1136 | + hashsize = roundup_pow_of_two(256 * num_possible_cpus()); |
1137 | 1137 | #endif
|
1138 | 1138 |
|
1139 | 1139 | futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues),
|
1140 |
| - futex_hashsize, 0, 0, |
| 1140 | + hashsize, 0, 0, |
1141 | 1141 | &futex_shift, NULL,
|
1142 |
| - futex_hashsize, futex_hashsize); |
1143 |
| - futex_hashsize = 1UL << futex_shift; |
| 1142 | + hashsize, hashsize); |
| 1143 | + hashsize = 1UL << futex_shift; |
1144 | 1144 |
|
1145 |
| - for (i = 0; i < futex_hashsize; i++) { |
| 1145 | + for (i = 0; i < hashsize; i++) { |
1146 | 1146 | atomic_set(&futex_queues[i].waiters, 0);
|
1147 | 1147 | plist_head_init(&futex_queues[i].chain);
|
1148 | 1148 | spin_lock_init(&futex_queues[i].lock);
|
1149 | 1149 | }
|
1150 | 1150 |
|
| 1151 | + futex_hashmask = hashsize - 1; |
1151 | 1152 | return 0;
|
1152 | 1153 | }
|
1153 | 1154 | core_initcall(futex_init);
|
0 commit comments