[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZZfbNIuyEiS+m7Ih@linux.intel.com>
Date: Fri, 5 Jan 2024 11:34:28 +0100
From: Stanislaw Gruszka <stanislaw.gruszka@...ux.intel.com>
To: Heiner Kallweit <hkallweit1@...il.com>
Cc: Jakub Kicinski <kuba@...nel.org>,
Johannes Berg <johannes@...solutions.net>, netdev@...r.kernel.org,
Johannes Berg <johannes.berg@...el.com>,
Marc MERLIN <marc@...lins.org>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>
Subject: Re: [PATCH net v3] net: ethtool: do runtime PM outside RTNL
On Thu, Jan 04, 2024 at 10:05:12AM +0100, Heiner Kallweit wrote:
> On 04.01.2024 09:25, Stanislaw Gruszka wrote:
> For me the main question is the following. In igc_resume() you have
>
> rtnl_lock();
> if (!err && netif_running(netdev))
> err = __igc_open(netdev, true);
>
> if (!err)
> netif_device_attach(netdev);
> rtnl_unlock();
>
> Why is the global rtnl_lock() needed here? The netdev is in detached
> state what protects from e.g. userspace activity, see all the
> netif_device_present() checks in net core.
Good question. Initially I thought that the lock can be removed
for the exact reason you wrote. I.e. the analogus change as you
did for igb could de done ( ac8c58f5b535 ).
But after more detailed examination I can see the need for lock.
__igc_open() calls at least one function that require rtnl_lock:
netif_set_real_num_rx_queues().
Despite using netif_device_attach() without the rtnl_lock at
various places it's not safe. After:
if (!test_and_set_bit(__LINK_STATE_PRESENT, &dev->state) &&
netif_running(dev)) {
the full link down can be performed without rtnl_lock, so we can do
netif_tx_wake_all_queues(dev);
__netdev_watchdog_up(dev);
during closing or after device is closed.
Just found those two. I think there could be more reasons.
Regards
Stanislaw
Powered by blists - more mailing lists