2020-01-15 15:57:51

by Madhuparna Bhowmik

[permalink] [raw]
Subject: [PATCH] net: xen-netback: hash.c: Use built-in RCU list checking

From: Madhuparna Bhowmik <[email protected]>

list_for_each_entry_rcu has built-in RCU and lock checking.
Pass cond argument to list_for_each_entry_rcu.

Signed-off-by: Madhuparna Bhowmik <[email protected]>
---
drivers/net/xen-netback/hash.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
index 10d580c3dea3..6b7532f7c936 100644
--- a/drivers/net/xen-netback/hash.c
+++ b/drivers/net/xen-netback/hash.c
@@ -51,7 +51,8 @@ static void xenvif_add_hash(struct xenvif *vif, const u8 *tag,

found = false;
oldest = NULL;
- list_for_each_entry_rcu(entry, &vif->hash.cache.list, link) {
+ list_for_each_entry_rcu(entry, &vif->hash.cache.list, link,
+ lockdep_is_held(&vif->hash.cache.lock)) {
/* Make sure we don't add duplicate entries */
if (entry->len == len &&
memcmp(entry->tag, tag, len) == 0)
@@ -102,7 +103,8 @@ static void xenvif_flush_hash(struct xenvif *vif)

spin_lock_irqsave(&vif->hash.cache.lock, flags);

- list_for_each_entry_rcu(entry, &vif->hash.cache.list, link) {
+ list_for_each_entry_rcu(entry, &vif->hash.cache.list, link,
+ lockdep_is_held(&vif->hash.cache.lock)) {
list_del_rcu(&entry->link);
vif->hash.cache.count--;
kfree_rcu(entry, rcu);
--
2.17.1


2020-01-15 17:42:16

by Wei Liu

[permalink] [raw]
Subject: Re: [PATCH] net: xen-netback: hash.c: Use built-in RCU list checking

On Wed, Jan 15, 2020 at 09:25:53PM +0530, [email protected] wrote:
> From: Madhuparna Bhowmik <[email protected]>
>
> list_for_each_entry_rcu has built-in RCU and lock checking.
> Pass cond argument to list_for_each_entry_rcu.
>
> Signed-off-by: Madhuparna Bhowmik <[email protected]>

Acked-by: Wei Liu <[email protected]>

2020-01-17 09:59:17

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: xen-netback: hash.c: Use built-in RCU list checking

From: [email protected]
Date: Wed, 15 Jan 2020 21:25:53 +0530

> From: Madhuparna Bhowmik <[email protected]>
>
> list_for_each_entry_rcu has built-in RCU and lock checking.
> Pass cond argument to list_for_each_entry_rcu.
>
> Signed-off-by: Madhuparna Bhowmik <[email protected]>

Applied to net-next.