Re: [PATCH 2/5] rhashtable: reorder some inline functions and macros.

From: Jakub Kicinski
Date: Tue May 14 2019 - 15:27:13 EST


On Fri, 12 Apr 2019 11:52:08 +1000, NeilBrown wrote:
> This patch only moves some code around, it doesn't
> change the code at all.
> A subsequent patch will benefit from this as it needs
> to add calls to functions which are now defined before the
> call-site, but weren't before.
>
> Signed-off-by: NeilBrown <neilb@xxxxxxxx>

Hi Neil, I think this patch introduces as slew of sparse warnigns:

include/linux/rhashtable.h:724:23: warning: incorrect type in argument 2 (different address spaces)
include/linux/rhashtable.h:724:23: expected struct rhash_lock_head **bkt
include/linux/rhashtable.h:724:23: got struct rhash_lock_head [noderef] <asn:4>**[assigned] bkt
include/linux/rhashtable.h:728:33: warning: incorrect type in argument 2 (different address spaces)
include/linux/rhashtable.h:728:33: expected struct rhash_lock_head **bkt
include/linux/rhashtable.h:728:33: got struct rhash_lock_head [noderef] <asn:4>**[assigned] bkt
include/linux/rhashtable.h:760:41: warning: incorrect type in argument 2 (different address spaces)
include/linux/rhashtable.h:760:41: expected struct rhash_lock_head **bkt
include/linux/rhashtable.h:760:41: got struct rhash_lock_head [noderef] <asn:4>**[assigned] bkt
include/linux/rhashtable.h:801:25: warning: incorrect type in argument 2 (different address spaces)
include/linux/rhashtable.h:801:25: expected struct rhash_lock_head **bkt
include/linux/rhashtable.h:801:25: got struct rhash_lock_head [noderef] <asn:4>**[assigned] bkt
include/linux/rhashtable.h:1003:23: warning: incorrect type in argument 2 (different address spaces)
include/linux/rhashtable.h:1003:23: expected struct rhash_lock_head **bkt
include/linux/rhashtable.h:1003:23: got struct rhash_lock_head [noderef] <asn:4>**[assigned] bkt
include/linux/rhashtable.h:1047:41: warning: incorrect type in argument 2 (different address spaces)
include/linux/rhashtable.h:1047:41: expected struct rhash_lock_head **bkt
include/linux/rhashtable.h:1047:41: got struct rhash_lock_head [noderef] <asn:4>**[assigned] bkt
include/linux/rhashtable.h:1054:25: warning: incorrect type in argument 2 (different address spaces)
include/linux/rhashtable.h:1054:25: expected struct rhash_lock_head **bkt
include/linux/rhashtable.h:1054:25: got struct rhash_lock_head [noderef] <asn:4>**[assigned] bkt

Is there any chance to get those fixed? Presumably a __force would be
appropriate? Maybe like this?

diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index f7714d3b46bd..997017a85032 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -325,27 +325,28 @@ static inline struct rhash_lock_head __rcu **rht_bucket_insert(
*/

static inline void rht_lock(struct bucket_table *tbl,
- struct rhash_lock_head **bkt)
+ struct rhash_lock_head __rcu **bkt)
{
+
local_bh_disable();
- bit_spin_lock(0, (unsigned long *)bkt);
+ bit_spin_lock(0, (unsigned long __force *)bkt);
lock_map_acquire(&tbl->dep_map);
}

static inline void rht_lock_nested(struct bucket_table *tbl,
- struct rhash_lock_head **bucket,
+ struct rhash_lock_head __rcu **bkt,
unsigned int subclass)
{
local_bh_disable();
- bit_spin_lock(0, (unsigned long *)bucket);
+ bit_spin_lock(0, (unsigned long __force *)bkt);
lock_acquire_exclusive(&tbl->dep_map, subclass, 0, NULL, _THIS_IP_);
}

static inline void rht_unlock(struct bucket_table *tbl,
- struct rhash_lock_head **bkt)
+ struct rhash_lock_head __rcu **bkt)
{
lock_map_release(&tbl->dep_map);
- bit_spin_unlock(0, (unsigned long *)bkt);
+ bit_spin_unlock(0, (unsigned long __force *)bkt);
local_bh_enable();
}