@@ -64,8 +64,12 @@ ndo_do_ioctl:
Context: process
ndo_get_stats:
- Synchronization: dev_base_lock rwlock.
- Context: nominally process, but don't sleep inside an rwlock
+ Synchronization:
+ none. netif_lists_lock(net) might be held, but not guaranteed.
+ It is illegal to hold rtnl_lock() in this method, since it will
+ cause a lock inversion with netif_lists_lock and a deadlock.
+ Context:
+ process
ndo_start_xmit:
Synchronization: __netif_tx_lock spinlock.
@@ -155,11 +155,10 @@ Drivers must ensure best possible compliance with
Please note for example that detailed error statistics must be
added into the general `rx_error` / `tx_error` counters.
-The `.ndo_get_stats64` callback can not sleep because of accesses
-via `/proc/net/dev`. If driver may sleep when retrieving the statistics
-from the device it should do so periodically asynchronously and only return
-a recent copy from `.ndo_get_stats64`. Ethtool interrupt coalescing interface
-allows setting the frequency of refreshing statistics, if needed.
+Drivers may sleep when retrieving the statistics from the device, or they might
+read the counters periodically and only return in `.ndo_get_stats64` a recent
+copy collected asynchronously. In the latter case, the ethtool interrupt
+coalescing interface allows setting the frequency of refreshing statistics.
Retrieving ethtool statistics is a multi-syscall process, drivers are advised
to keep the number of statistics constant to avoid race conditions with
@@ -10409,6 +10409,8 @@ int __must_check dev_get_stats(struct net_device *dev,
const struct net_device_ops *ops = dev->netdev_ops;
int err = 0;
+ might_sleep();
+
if (ops->ndo_get_stats64) {
memset(storage, 0, sizeof(*storage));
err = ops->ndo_get_stats64(dev, storage);