aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-03-12 10:28:40 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-12 23:02:30 -0400
commita5b6846f9e1a080493210013385c28faecee36f0 (patch)
tree6b068157f7e2efb5d71978d3a63d14754bcd6a7c /include/linux
parent9497df88ab5567daa001829051c5f87161a81ff0 (diff)
rhashtable: kill ht->shift atomic operations
Commit c0c09bfdc415 ("rhashtable: avoid unnecessary wakeup for worker queue") changed ht->shift to be atomic, which is actually unnecessary. Instead of leaving the current shift in the core rhashtable structure, it can be cached inside the individual bucket tables. There, it will only be initialized once during a new table allocation in the shrink/expansion slow path, and from then onward it stays immutable for the rest of the bucket table liftime. That allows shift to be non-atomic. The patch also moves hash_rnd management into the table setup. The rhashtable structure now consumes 3 instead of 4 cachelines. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Ying Xue <ying.xue@windriver.com> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/rhashtable.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 5ef8ea551556..c93ff8ac474a 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -50,6 +50,7 @@ struct rhash_head {
50 * struct bucket_table - Table of hash buckets 50 * struct bucket_table - Table of hash buckets
51 * @size: Number of hash buckets 51 * @size: Number of hash buckets
52 * @hash_rnd: Random seed to fold into hash 52 * @hash_rnd: Random seed to fold into hash
53 * @shift: Current size (1 << shift)
53 * @locks_mask: Mask to apply before accessing locks[] 54 * @locks_mask: Mask to apply before accessing locks[]
54 * @locks: Array of spinlocks protecting individual buckets 55 * @locks: Array of spinlocks protecting individual buckets
55 * @buckets: size * hash buckets 56 * @buckets: size * hash buckets
@@ -57,6 +58,7 @@ struct rhash_head {
57struct bucket_table { 58struct bucket_table {
58 size_t size; 59 size_t size;
59 u32 hash_rnd; 60 u32 hash_rnd;
61 u32 shift;
60 unsigned int locks_mask; 62 unsigned int locks_mask;
61 spinlock_t *locks; 63 spinlock_t *locks;
62 64
@@ -99,7 +101,6 @@ struct rhashtable_params {
99 * @tbl: Bucket table 101 * @tbl: Bucket table
100 * @future_tbl: Table under construction during expansion/shrinking 102 * @future_tbl: Table under construction during expansion/shrinking
101 * @nelems: Number of elements in table 103 * @nelems: Number of elements in table
102 * @shift: Current size (1 << shift)
103 * @p: Configuration parameters 104 * @p: Configuration parameters
104 * @run_work: Deferred worker to expand/shrink asynchronously 105 * @run_work: Deferred worker to expand/shrink asynchronously
105 * @mutex: Mutex to protect current/future table swapping 106 * @mutex: Mutex to protect current/future table swapping
@@ -110,12 +111,11 @@ struct rhashtable {
110 struct bucket_table __rcu *tbl; 111 struct bucket_table __rcu *tbl;
111 struct bucket_table __rcu *future_tbl; 112 struct bucket_table __rcu *future_tbl;
112 atomic_t nelems; 113 atomic_t nelems;
113 atomic_t shift; 114 bool being_destroyed;
114 struct rhashtable_params p; 115 struct rhashtable_params p;
115 struct work_struct run_work; 116 struct work_struct run_work;
116 struct mutex mutex; 117 struct mutex mutex;
117 struct list_head walkers; 118 struct list_head walkers;
118 bool being_destroyed;
119}; 119};
120 120
121/** 121/**