[PATCH] vxlan: using hash_lock to protect one budegt in vxlan_flush

From: Litao Jiao
Date: Thu Apr 11 2019 - 03:14:07 EST


The hash_lock will hold long time in vxlan_flush when stopping the
vxlan device in which there has lots of vxlan fdb entries;it would
affect the bh process in local cpu; and other cpu would wait for
a long time in vxlan_snoop until the hash_lock is released;so
using hash_lock to protect one budegt in vxlan_flush could
reduce the continuous holding time of the lock.

Signed-off-by: Litao Jiao <jiaolitao@xxxxxxxxxxxx>
---
drivers/net/vxlan.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index d76dfed..306703e 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2816,9 +2816,10 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all)
{
unsigned int h;

- spin_lock_bh(&vxlan->hash_lock);
for (h = 0; h < FDB_HASH_SIZE; ++h) {
struct hlist_node *p, *n;
+
+ spin_lock_bh(&vxlan->hash_lock);
hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) {
struct vxlan_fdb *f
= container_of(p, struct vxlan_fdb, hlist);
@@ -2828,8 +2829,8 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all)
if (!is_zero_ether_addr(f->eth_addr))
vxlan_fdb_destroy(vxlan, f, true, true);
}
+ spin_unlock_bh(&vxlan->hash_lock);
}
- spin_unlock_bh(&vxlan->hash_lock);
}

/* Cleanup timer and forwarding table on shutdown */
--
1.9.1