sunrpc: Pass lockdep expression to RCU lists
diff mbox series

Message ID 20200219093504.16290-1-frextrite@gmail.com
State New
Headers show
Series
  • sunrpc: Pass lockdep expression to RCU lists
Related show

Commit Message

Amol Grover Feb. 19, 2020, 9:35 a.m. UTC
detail->hash_table[] is traversed using hlist_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of detail->hash_lock.

Hence, add corresponding lockdep expression to silence false-positive
warnings, and harden RCU lists.

Signed-off-by: Amol Grover <frextrite@gmail.com>
---
 net/sunrpc/cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

J. Bruce Fields March 3, 2020, 4:37 p.m. UTC | #1
On Wed, Feb 19, 2020 at 03:05:05PM +0530, Amol Grover wrote:
> detail->hash_table[] is traversed using hlist_for_each_entry_rcu
> outside an RCU read-side critical section but under the protection
> of detail->hash_lock.
> 
> Hence, add corresponding lockdep expression to silence false-positive
> warnings, and harden RCU lists.

Thanks, applying for 5.7.--b.

> 
> Signed-off-by: Amol Grover <frextrite@gmail.com>
> ---
>  net/sunrpc/cache.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
> index f740cb51802a..5db5f5b94726 100644
> --- a/net/sunrpc/cache.c
> +++ b/net/sunrpc/cache.c
> @@ -97,7 +97,8 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
>  	spin_lock(&detail->hash_lock);
>  
>  	/* check if entry appeared while we slept */
> -	hlist_for_each_entry_rcu(tmp, head, cache_list) {
> +	hlist_for_each_entry_rcu(tmp, head, cache_list,
> +				 lockdep_is_held(&detail->hash_lock)) {
>  		if (detail->match(tmp, key)) {
>  			if (cache_is_expired(detail, tmp)) {
>  				hlist_del_init_rcu(&tmp->cache_list);
> -- 
> 2.24.1

Patch
diff mbox series

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index f740cb51802a..5db5f5b94726 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -97,7 +97,8 @@  static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
 	spin_lock(&detail->hash_lock);
 
 	/* check if entry appeared while we slept */
-	hlist_for_each_entry_rcu(tmp, head, cache_list) {
+	hlist_for_each_entry_rcu(tmp, head, cache_list,
+				 lockdep_is_held(&detail->hash_lock)) {
 		if (detail->match(tmp, key)) {
 			if (cache_is_expired(detail, tmp)) {
 				hlist_del_init_rcu(&tmp->cache_list);