From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: <netdev@vger.kernel.org>, Willem de Bruijn <willemb@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jay Vosburgh <j.vosburgh@gmail.com>,
Veaceslav Falico <vfalico@gmail.com>,
Eric Dumazet <edumazet@google.com>
Cc: <weiyongjun1@huawei.com>, Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [RFC PATCH] bonding: use mutex lock in bond_get_stats()
Date: Fri, 15 Feb 2019 21:50:56 +0800 [thread overview]
Message-ID: <20190215135056.18376-1-wangkefeng.wang@huawei.com> (raw)
With CONFIG_DEBUG_SPINLOCK=y, we find following stack,
BUG: spinlock wrong CPU on CPU#0, ip/16047
lock: 0xffff803f5febc998, .magic: dead4ead, .owner: ip/16047, .owner_cpu: 0
CPU: 1 PID: 16047 Comm: ip Kdump: loaded Tainted: G E 4.19.12.aarch64 #1
Hardware name: Huawei TaiShan 2280 V2/BC82AMDA, BIOS TA BIOS TaiShan 2280 V2 - B900 01/29/2019
Call trace:
dump_backtrace+0x0/0x1c0
show_stack+0x24/0x30
dump_stack+0x90/0xbc
spin_dump+0x84/0xa8
do_raw_spin_unlock+0xf8/0x100
_raw_spin_unlock+0x20/0x30
bond_get_stats+0x110/0x140 [bonding]
rtnl_fill_stats+0x50/0x150
rtnl_fill_ifinfo+0x4d4/0xd18
rtnl_dump_ifinfo+0x200/0x3a8
netlink_dump+0x100/0x2b0
netlink_recvmsg+0x310/0x3e8
sock_recvmsg+0x58/0x68
___sys_recvmsg+0xd0/0x278
__sys_recvmsg+0x74/0xd0
__arm64_sys_recvmsg+0x2c/0x38
el0_svc_common+0x7c/0x118
el0_svc_handler+0x30/0x40
el0_svc+0x8/0xc
and then lead to softlockup issue, fix this by using mutex lock instead
of spin lock.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
Not sure if this is right fix, please correct me if I'm wrong.
drivers/net/bonding/bond_main.c | 6 +++---
include/net/bonding.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 485462d3087f..3f7849525759 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3452,7 +3452,7 @@ static void bond_get_stats(struct net_device *bond_dev,
struct list_head *iter;
struct slave *slave;
- spin_lock_nested(&bond->stats_lock, bond_get_nest_level(bond_dev));
+ mutex_lock_nested(&bond->stats_lock, bond_get_nest_level(bond_dev));
memcpy(stats, &bond->bond_stats, sizeof(*stats));
rcu_read_lock();
@@ -3468,7 +3468,7 @@ static void bond_get_stats(struct net_device *bond_dev,
rcu_read_unlock();
memcpy(&bond->bond_stats, stats, sizeof(*stats));
- spin_unlock(&bond->stats_lock);
+ mutex_unlock(&bond->stats_lock);
}
static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)
@@ -4284,7 +4284,7 @@ void bond_setup(struct net_device *bond_dev)
struct bonding *bond = netdev_priv(bond_dev);
spin_lock_init(&bond->mode_lock);
- spin_lock_init(&bond->stats_lock);
+ mutex_init(&bond->stats_lock);
bond->params = bonding_defaults;
/* Initialize pointers */
diff --git a/include/net/bonding.h b/include/net/bonding.h
index b46d68acf701..3a6dbb2b376c 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -205,7 +205,7 @@ struct bonding {
* ALB mode (6) - to sync the use and modifications of its hash table
*/
spinlock_t mode_lock;
- spinlock_t stats_lock;
+ struct mutex stats_lock;
u8 send_peer_notif;
u8 igmp_retrans;
#ifdef CONFIG_PROC_FS
--
2.20.1
next reply other threads:[~2019-02-15 13:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 13:50 Kefeng Wang [this message]
2019-02-15 13:57 ` [RFC PATCH] bonding: use mutex lock in bond_get_stats() Eric Dumazet
2019-02-16 5:35 ` Kefeng Wang
2019-02-16 18:18 ` Eric Dumazet
2019-02-18 6:39 ` Kefeng Wang
2019-02-17 6:27 ` Cong Wang
2019-02-21 13:32 ` [bonding] 86838ad7bd: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c kernel test robot
2019-02-21 13:54 ` Kefeng Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190215135056.18376-1-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=j.vosburgh@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=vfalico@gmail.com \
--cc=weiyongjun1@huawei.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).