[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210105185902.3922928-12-olteanv@gmail.com>
Date: Tue, 5 Jan 2021 20:59:01 +0200
From: Vladimir Oltean <olteanv@...il.com>
To: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Pablo Neira Ayuso <pablo@...filter.org>,
Jiri Benc <jbenc@...hat.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jamal Hadi Salim <jhs@...atatu.com>,
Stephen Hemminger <stephen@...workplumber.org>,
Eric Dumazet <edumazet@...gle.com>,
George McCollister <george.mccollister@...il.com>,
Oleksij Rempel <o.rempel@...gutronix.de>,
Jay Vosburgh <j.vosburgh@...il.com>,
Veaceslav Falico <vfalico@...il.com>,
Andy Gospodarek <andy@...yhouse.net>,
Arnd Bergmann <arnd@...db.de>,
Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andriin@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Taehee Yoo <ap420073@...il.com>,
Jiri Pirko <jiri@...lanox.com>,
Björn Töpel <bjorn.topel@...el.com>,
Paolo Abeni <pabeni@...hat.com>,
Christian Brauner <christian.brauner@...ntu.com>,
Florian Westphal <fw@...len.de>, linux-s390@...r.kernel.org,
intel-wired-lan@...ts.osuosl.org, linux-parisc@...r.kernel.org,
linux-scsi@...r.kernel.org, linux-usb@...r.kernel.org,
dev@...nvswitch.org
Subject: [RFC PATCH v2 net-next 11/12] net: mark ndo_get_stats64 as being able to sleep
From: Vladimir Oltean <vladimir.oltean@....com>
Now that all callers have been converted to not use atomic context when
calling dev_get_stats, it is time to update the documentation and put a
notice in the function that it expects process context.
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
Documentation/networking/netdevices.rst | 8 ++++++--
Documentation/networking/statistics.rst | 9 ++++-----
net/core/dev.c | 2 ++
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Documentation/networking/netdevices.rst b/Documentation/networking/netdevices.rst
index 5a85fcc80c76..944599722c76 100644
--- a/Documentation/networking/netdevices.rst
+++ b/Documentation/networking/netdevices.rst
@@ -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.
diff --git a/Documentation/networking/statistics.rst b/Documentation/networking/statistics.rst
index 234abedc29b2..ad3e353df0dd 100644
--- a/Documentation/networking/statistics.rst
+++ b/Documentation/networking/statistics.rst
@@ -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
diff --git a/net/core/dev.c b/net/core/dev.c
index d48b75479b3e..6b7cdf8ab875 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10389,6 +10389,8 @@ void dev_get_stats(struct net_device *dev, struct rtnl_link_stats64 *storage)
{
const struct net_device_ops *ops = dev->netdev_ops;
+ might_sleep();
+
if (ops->ndo_get_stats64) {
memset(storage, 0, sizeof(*storage));
ops->ndo_get_stats64(dev, storage);
--
2.25.1
Powered by blists - more mailing lists