From ba6306e3f648a857ae52ddcabc2859542fd2f94c Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 16 May 2019 15:19:46 +0800 Subject: rhashtable: Remove RCU marking from rhash_lock_head The opaque type rhash_lock_head should not be marked with __rcu because it can never be dereferenced. We should apply the RCU marking when we turn it into a pointer which can be dereferenced. This patch does exactly that. This fixes a number of sparse warnings as well as getting rid of some unnecessary RCU checking. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- lib/rhashtable.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 6529fe1b45c1..7708699a5b96 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -34,7 +34,7 @@ union nested_table { union nested_table __rcu *table; - struct rhash_lock_head __rcu *bucket; + struct rhash_lock_head *bucket; }; static u32 head_hashfn(struct rhashtable *ht, @@ -216,7 +216,7 @@ static struct bucket_table *rhashtable_last_table(struct rhashtable *ht, } static int rhashtable_rehash_one(struct rhashtable *ht, - struct rhash_lock_head __rcu **bkt, + struct rhash_lock_head **bkt, unsigned int old_hash) { struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); @@ -269,7 +269,7 @@ static int rhashtable_rehash_chain(struct rhashtable *ht, unsigned int old_hash) { struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); - struct rhash_lock_head __rcu **bkt = rht_bucket_var(old_tbl, old_hash); + struct rhash_lock_head **bkt = rht_bucket_var(old_tbl, old_hash); int err; if (!bkt) @@ -478,7 +478,7 @@ fail: } static void *rhashtable_lookup_one(struct rhashtable *ht, - struct rhash_lock_head __rcu **bkt, + struct rhash_lock_head **bkt, struct bucket_table *tbl, unsigned int hash, const void *key, struct rhash_head *obj) { @@ -529,7 +529,7 @@ static void *rhashtable_lookup_one(struct rhashtable *ht, } static struct bucket_table *rhashtable_insert_one(struct rhashtable *ht, - struct rhash_lock_head __rcu **bkt, + struct rhash_lock_head **bkt, struct bucket_table *tbl, unsigned int hash, struct rhash_head *obj, @@ -584,7 +584,7 @@ static void *rhashtable_try_insert(struct rhashtable *ht, const void *key, { struct bucket_table *new_tbl; struct bucket_table *tbl; - struct rhash_lock_head __rcu **bkt; + struct rhash_lock_head **bkt; unsigned int hash; void *data; @@ -1166,8 +1166,8 @@ void rhashtable_destroy(struct rhashtable *ht) } EXPORT_SYMBOL_GPL(rhashtable_destroy); -struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tbl, - unsigned int hash) +struct rhash_lock_head **__rht_bucket_nested(const struct bucket_table *tbl, + unsigned int hash) { const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *)); unsigned int index = hash & ((1 << tbl->nest) - 1); @@ -1195,10 +1195,10 @@ struct rhash_lock_head __rcu **__rht_bucket_nested(const struct bucket_table *tb } EXPORT_SYMBOL_GPL(__rht_bucket_nested); -struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl, - unsigned int hash) +struct rhash_lock_head **rht_bucket_nested(const struct bucket_table *tbl, + unsigned int hash) { - static struct rhash_lock_head __rcu *rhnull; + static struct rhash_lock_head *rhnull; if (!rhnull) INIT_RHT_NULLS_HEAD(rhnull); @@ -1206,9 +1206,9 @@ struct rhash_lock_head __rcu **rht_bucket_nested(const struct bucket_table *tbl, } EXPORT_SYMBOL_GPL(rht_bucket_nested); -struct rhash_lock_head __rcu **rht_bucket_nested_insert(struct rhashtable *ht, - struct bucket_table *tbl, - unsigned int hash) +struct rhash_lock_head **rht_bucket_nested_insert(struct rhashtable *ht, + struct bucket_table *tbl, + unsigned int hash) { const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *)); unsigned int index = hash & ((1 << tbl->nest) - 1); -- cgit v1.2.3-59-g8ed1b From e9458a4e337db565191e3f1cee71bb553802def4 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 16 May 2019 15:19:48 +0800 Subject: rhashtable: Fix cmpxchg RCU warnings As cmpxchg is a non-RCU mechanism it will cause sparse warnings when we use it for RCU. This patch adds explicit casts to silence those warnings. This should probably be moved to RCU itself in future. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- lib/rhashtable.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 7708699a5b96..935ec80f213f 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -131,7 +131,7 @@ static union nested_table *nested_table_alloc(struct rhashtable *ht, INIT_RHT_NULLS_HEAD(ntbl[i].bucket); } - if (cmpxchg(prev, NULL, ntbl) == NULL) + if (cmpxchg((union nested_table **)prev, NULL, ntbl) == NULL) return ntbl; /* Raced with another thread. */ kfree(ntbl); @@ -296,7 +296,8 @@ static int rhashtable_rehash_attach(struct rhashtable *ht, * rcu_assign_pointer(). */ - if (cmpxchg(&old_tbl->future_tbl, NULL, new_tbl) != NULL) + if (cmpxchg((struct bucket_table **)&old_tbl->future_tbl, NULL, + new_tbl) != NULL) return -EEXIST; return 0; -- cgit v1.2.3-59-g8ed1b From 38a04b83ab3033905114d608737504e66350088b Mon Sep 17 00:00:00 2001 From: Philippe Mazenauer Date: Fri, 17 May 2019 10:44:44 +0000 Subject: lib: Correct comment of prandom_seed Variable 'entropy' was wrongly documented as 'seed', changed comment to reflect actual variable name. ../lib/random32.c:179: warning: Function parameter or member 'entropy' not described in 'prandom_seed' ../lib/random32.c:179: warning: Excess function parameter 'seed' description in 'prandom_seed' Signed-off-by: Philippe Mazenauer Acked-by: Lee Jones Signed-off-by: David S. Miller --- lib/random32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/random32.c b/lib/random32.c index 4aaa76404d56..763b920a6206 100644 --- a/lib/random32.c +++ b/lib/random32.c @@ -171,9 +171,9 @@ static void prandom_seed_early(struct rnd_state *state, u32 seed, /** * prandom_seed - add entropy to pseudo random number generator - * @seed: seed value + * @entropy: entropy value * - * Add some additional seeding to the prandom pool. + * Add some additional entropy to the prandom pool. */ void prandom_seed(u32 entropy) { -- cgit v1.2.3-59-g8ed1b