Commit 3552138a authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-remove-rtnl_lock-from-the-callers-of-queue-apis'

Stanislav Fomichev says:

====================
net: remove rtnl_lock from the callers of queue APIs

All drivers that use queue management APIs already depend on the netdev
lock. Ultimately, we want to have most of the paths that work with
specific netdev to be rtnl_lock-free (ethtool mostly in particular).
Queue API currently has a much smaller API surface, so start with
rtnl_lock from it:

- add mutex to each dmabuf binding (to replace rtnl_lock)
- move netdev lock management to the callers of netdev_rx_queue_restart
  and drop rtnl_lock
====================

Link: https://patch.msgid.link/20250311144026.4154277-1-sdf@fomichev.me


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 17fef204 1d22d306
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -745,8 +745,8 @@ operations:
            - irq-suspend-timeout

kernel-family:
  headers: [ "linux/list.h"]
  sock-priv: struct list_head
  headers: [ "net/netdev_netlink.h"]
  sock-priv: struct netdev_nl_sock

mcast-groups:
  list:
+2 −2
Original line number Diff line number Diff line
@@ -11381,14 +11381,14 @@ static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify,
	if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag))
		return;

	rtnl_lock();
	netdev_lock(irq->bp->dev);
	if (netif_running(irq->bp->dev)) {
		err = netdev_rx_queue_restart(irq->bp->dev, irq->ring_nr);
		if (err)
			netdev_err(irq->bp->dev,
				   "RX queue restart failed: err=%d\n", err);
	}
	rtnl_unlock();
	netdev_unlock(irq->bp->dev);
}

static void bnxt_irq_affinity_release(struct kref *ref)
+2 −2
Original line number Diff line number Diff line
@@ -787,7 +787,7 @@ nsim_qreset_write(struct file *file, const char __user *data,
	if (ret != 2)
		return -EINVAL;

	rtnl_lock();
	netdev_lock(ns->netdev);
	if (queue >= ns->netdev->real_num_rx_queues) {
		ret = -EINVAL;
		goto exit_unlock;
@@ -801,7 +801,7 @@ nsim_qreset_write(struct file *file, const char __user *data,

	ret = count;
exit_unlock:
	rtnl_unlock();
	netdev_unlock(ns->netdev);
	return ret;
}

+12 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NET_NETDEV_NETLINK_H
#define __NET_NETDEV_NETLINK_H

#include <linux/list.h>

struct netdev_nl_sock {
	struct mutex lock;
	struct list_head bindings;
};

#endif	/* __NET_NETDEV_NETLINK_H */
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@

/* Device memory support */

/* Protected by rtnl_lock() */
static DEFINE_XARRAY_FLAGS(net_devmem_dmabuf_bindings, XA_FLAGS_ALLOC1);

static const struct memory_provider_ops dmabuf_devmem_ops;
@@ -128,9 +127,10 @@ void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding)
		rxq->mp_params.mp_priv = NULL;
		rxq->mp_params.mp_ops = NULL;

		netdev_lock(binding->dev);
		rxq_idx = get_netdev_rx_queue_index(rxq);

		WARN_ON(netdev_rx_queue_restart(binding->dev, rxq_idx));
		netdev_unlock(binding->dev);
	}

	xa_erase(&net_devmem_dmabuf_bindings, binding->id);
Loading