mlxsw: spectrum_router: hw_stats: Use tracker helpers to hold & put netdevices
authorPetr Machata <petrm@nvidia.com>
Thu, 27 Jul 2023 15:59:23 +0000 (17:59 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 28 Jul 2023 20:38:45 +0000 (13:38 -0700)
Using the tracking helpers makes it easier to debug netdevice refcount
imbalances when CONFIG_NET_DEV_REFCNT_TRACKER is enabled.

Convert dev_hold() / dev_put() to netdev_hold() / netdev_put() in the
router code that deals with hw_stats events.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/b972314cfef4f4c24e66e60d13cffa5d606d1bf3.1690471774.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 0744497..3ecd34a 100644 (file)
@@ -8308,6 +8308,7 @@ mlxsw_sp_router_port_l3_stats_report_delta(struct mlxsw_sp_rif *rif,
 struct mlxsw_sp_router_hwstats_notify_work {
        struct work_struct work;
        struct net_device *dev;
+       netdevice_tracker dev_tracker;
 };
 
 static void mlxsw_sp_router_hwstats_notify_work(struct work_struct *work)
@@ -8319,7 +8320,7 @@ static void mlxsw_sp_router_hwstats_notify_work(struct work_struct *work)
        rtnl_lock();
        rtnl_offload_xstats_notify(hws_work->dev);
        rtnl_unlock();
-       dev_put(hws_work->dev);
+       netdev_put(hws_work->dev, &hws_work->dev_tracker);
        kfree(hws_work);
 }
 
@@ -8339,7 +8340,7 @@ mlxsw_sp_router_hwstats_notify_schedule(struct net_device *dev)
                return;
 
        INIT_WORK(&hws_work->work, mlxsw_sp_router_hwstats_notify_work);
-       dev_hold(dev);
+       netdev_hold(dev, &hws_work->dev_tracker, GFP_KERNEL);
        hws_work->dev = dev;
        mlxsw_core_schedule_work(&hws_work->work);
 }