@@ -1585,8 +1585,11 @@ static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack)if(!netif_device_present(dev)){/* may be detached because parent is runtime-suspended */-if(dev->dev.parent)+if(dev->dev.parent){+rtnl_unlock();pm_runtime_resume(dev->dev.parent);+rtnl_lock();+}if(!netif_device_present(dev))return-ENODEV;}
From: Leon Romanovsky <leon@kernel.org> Date: 2021-08-09 05:56:27
On Mon, Aug 09, 2021 at 11:28:09AM +0800, AceLan Kao wrote:
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
The rtnl_lock() has been called in rtnetlink_rcv_msg(), and then in
__dev_open() it calls pm_runtime_resume() to resume devices, and in
some devices' resume function(igb_resum,igc_resume) they calls rtnl_lock()
again. That leads to a recursive lock.
It should leave the devices' resume function to decide if they need to
call rtnl_lock()/rtnl_unlock(),
Why? It doesn't sound right that drivers internally decide if to take or
release some external to them lock without seeing full picture.
Most of the time, device driver authors do it wrong. I afraid that igs
is one of such drivers that did it wrong.
Thanks
@@ -1585,8 +1585,11 @@ static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack)if(!netif_device_present(dev)){/* may be detached because parent is runtime-suspended */-if(dev->dev.parent)+if(dev->dev.parent){+rtnl_unlock();pm_runtime_resume(dev->dev.parent);+rtnl_lock();+}if(!netif_device_present(dev))return-ENODEV;}
From: AceLan Kao <acelan.kao@canonical.com> Date: 2021-08-10 01:58:15
Leon Romanovsky [off-list ref] 於 2021年8月9日 週一 下午1:51寫道:
On Mon, Aug 09, 2021 at 11:28:09AM +0800, AceLan Kao wrote:
quoted
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
The rtnl_lock() has been called in rtnetlink_rcv_msg(), and then in
__dev_open() it calls pm_runtime_resume() to resume devices, and in
some devices' resume function(igb_resum,igc_resume) they calls rtnl_lock()
again. That leads to a recursive lock.
It should leave the devices' resume function to decide if they need to
call rtnl_lock()/rtnl_unlock(),
Why? It doesn't sound right that drivers internally decide if to take or
release some external to them lock without seeing full picture.
From what I observed, this is the only calling path that acquired
rtnl_lock() before calling drivers' resume function.
So, it encounters recursive lock while driver is going to cal rtnl_lock() again.
Most of the time, device driver authors do it wrong. I afraid that igs
is one of such drivers that did it wrong.
The issues could be if we remove rtnl_lock in device drivers, then in
other calling path, it won't be protected by the rtnl lock,
and maybe we shouldn't call pm_runtime_resume() here(within rtnl
lock), for device drivers don't know if they are protected by the rtnl
lock while their resume() got called.
@@ -1585,8 +1585,11 @@ static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack)if(!netif_device_present(dev)){/* may be detached because parent is runtime-suspended */-if(dev->dev.parent)+if(dev->dev.parent){+rtnl_unlock();pm_runtime_resume(dev->dev.parent);+rtnl_lock();+}if(!netif_device_present(dev))return-ENODEV;}--
From: Leon Romanovsky <leon@kernel.org> Date: 2021-08-10 07:08:10
On Tue, Aug 10, 2021 at 09:57:57AM +0800, AceLan Kao wrote:
Leon Romanovsky [off-list ref] 於 2021年8月9日 週一 下午1:51寫道:
quoted
On Mon, Aug 09, 2021 at 11:28:09AM +0800, AceLan Kao wrote:
quoted
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
The rtnl_lock() has been called in rtnetlink_rcv_msg(), and then in
__dev_open() it calls pm_runtime_resume() to resume devices, and in
some devices' resume function(igb_resum,igc_resume) they calls rtnl_lock()
again. That leads to a recursive lock.
It should leave the devices' resume function to decide if they need to
call rtnl_lock()/rtnl_unlock(),
Why? It doesn't sound right that drivers internally decide if to take or
release some external to them lock without seeing full picture.
From what I observed, this is the only calling path that acquired
rtnl_lock() before calling drivers' resume function.
So, it encounters recursive lock while driver is going to cal rtnl_lock() again.
I clearly see the problem, but don't agree with a solution.
quoted
Most of the time, device driver authors do it wrong. I afraid that igs
is one of such drivers that did it wrong.
The issues could be if we remove rtnl_lock in device drivers, then in
other calling path, it won't be protected by the rtnl lock,
and maybe we shouldn't call pm_runtime_resume() here(within rtnl
lock), for device drivers don't know if they are protected by the rtnl
lock while their resume() got called.
This is exactly the problem, every driver guesses if rtnl_lock is needed
or not in specific path. It is wrong by design. You should ensure that
all paths that are triggered through rtnl should hold rtnl_lock.
You dropped rtnl_lock() without any protection, it is 100% bug.
Thanks
@@ -1585,8 +1585,11 @@ static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack)if(!netif_device_present(dev)){/* may be detached because parent is runtime-suspended */-if(dev->dev.parent)+if(dev->dev.parent){+rtnl_unlock();pm_runtime_resume(dev->dev.parent);+rtnl_lock();+}if(!netif_device_present(dev))return-ENODEV;}--
From: AceLan Kao <acelan.kao@canonical.com> Date: 2021-08-23 03:35:47
Leon Romanovsky [off-list ref] 於 2021年8月10日 週二 下午3:08寫道:
On Tue, Aug 10, 2021 at 09:57:57AM +0800, AceLan Kao wrote:
quoted
Leon Romanovsky [off-list ref] 於 2021年8月9日 週一 下午1:51寫道:
quoted
On Mon, Aug 09, 2021 at 11:28:09AM +0800, AceLan Kao wrote:
quoted
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
The rtnl_lock() has been called in rtnetlink_rcv_msg(), and then in
__dev_open() it calls pm_runtime_resume() to resume devices, and in
some devices' resume function(igb_resum,igc_resume) they calls rtnl_lock()
again. That leads to a recursive lock.
It should leave the devices' resume function to decide if they need to
call rtnl_lock()/rtnl_unlock(),
Why? It doesn't sound right that drivers internally decide if to take or
release some external to them lock without seeing full picture.
From what I observed, this is the only calling path that acquired
rtnl_lock() before calling drivers' resume function.
So, it encounters recursive lock while driver is going to cal rtnl_lock() again.
I clearly see the problem, but don't agree with a solution.
quoted
quoted
Most of the time, device driver authors do it wrong. I afraid that igs
is one of such drivers that did it wrong.
The issues could be if we remove rtnl_lock in device drivers, then in
other calling path, it won't be protected by the rtnl lock,
and maybe we shouldn't call pm_runtime_resume() here(within rtnl
lock), for device drivers don't know if they are protected by the rtnl
lock while their resume() got called.
This is exactly the problem, every driver guesses if rtnl_lock is needed
or not in specific path. It is wrong by design. You should ensure that
all paths that are triggered through rtnl should hold rtnl_lock.
Hi Jesse, Tony,
As you are the Intel Ethernet drivers' maintainers, do you have any
idea about this?
We can reproduce this issue on the machine with PCI Ethernet card
using igb or igc driver.
You dropped rtnl_lock() without any protection, it is 100% bug.
Thanks
@@ -1585,8 +1585,11 @@ static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack)if(!netif_device_present(dev)){/* may be detached because parent is runtime-suspended */-if(dev->dev.parent)+if(dev->dev.parent){+rtnl_unlock();pm_runtime_resume(dev->dev.parent);+rtnl_lock();+}if(!netif_device_present(dev))return-ENODEV;}--
From: "Nguyen, Anthony L" <anthony.l.nguyen@intel.com> Date: 2021-08-24 02:45:19
On Mon, 2021-08-23 at 11:26 +0800, AceLan Kao wrote:
Leon Romanovsky [off-list ref] 於 2021年8月10日 週二 下午3:08寫道:
quoted
On Tue, Aug 10, 2021 at 09:57:57AM +0800, AceLan Kao wrote:
quoted
Leon Romanovsky [off-list ref] 於 2021年8月9日 週一 下午1:51寫道:
quoted
On Mon, Aug 09, 2021 at 11:28:09AM +0800, AceLan Kao wrote:
quoted
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
The rtnl_lock() has been called in rtnetlink_rcv_msg(), and
then in
__dev_open() it calls pm_runtime_resume() to resume devices,
and in
some devices' resume function(igb_resum,igc_resume) they
calls rtnl_lock()
again. That leads to a recursive lock.
It should leave the devices' resume function to decide if
they need to
call rtnl_lock()/rtnl_unlock(),
Why? It doesn't sound right that drivers internally decide if
to take or
release some external to them lock without seeing full picture.
From what I observed, this is the only calling path that acquired
rtnl_lock() before calling drivers' resume function.
So, it encounters recursive lock while driver is going to cal
rtnl_lock() again.
I clearly see the problem, but don't agree with a solution.
quoted
quoted
Most of the time, device driver authors do it wrong. I afraid
that igs
is one of such drivers that did it wrong.
The issues could be if we remove rtnl_lock in device drivers,
then in
other calling path, it won't be protected by the rtnl lock,
and maybe we shouldn't call pm_runtime_resume() here(within rtnl
lock), for device drivers don't know if they are protected by the
rtnl
lock while their resume() got called.
This is exactly the problem, every driver guesses if rtnl_lock is
needed
or not in specific path. It is wrong by design. You should ensure
that
all paths that are triggered through rtnl should hold rtnl_lock.
Hi Jesse, Tony,
As you are the Intel Ethernet drivers' maintainers, do you have any
idea about this?
We can reproduce this issue on the machine with PCI Ethernet card
using igb or igc driver.
Adding Aleks and Sasha for their input as they are the leads for the
two drivers.
quoted
You dropped rtnl_lock() without any protection, it is 100% bug.
Thanks
@@ -1585,8 +1585,11 @@ static int __dev_open(struct
net_device *dev, struct netlink_ext_ack *extack)
if (!netif_device_present(dev)) {
/* may be detached because parent is runtime-
suspended */
- if (dev->dev.parent)
+ if (dev->dev.parent) {
+ rtnl_unlock();
pm_runtime_resume(dev->dev.parent);
+ rtnl_lock();
+ }
if (!netif_device_present(dev))
return -ENODEV;
}
--
2.25.1