From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jiri Benc <jbenc@redhat.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Eric Dumazet <edumazet@google.com>,
George McCollister <george.mccollister@gmail.com>,
Oleksij Rempel <o.rempel@pengutronix.de>,
Jay Vosburgh <j.vosburgh@gmail.com>,
Veaceslav Falico <vfalico@gmail.com>,
Andy Gospodarek <andy@greyhouse.net>
Subject: Re: [RFC PATCH net-next 05/13] net: bonding: hold the netdev lists lock when retrieving device statistics
Date: Mon, 7 Dec 2020 01:00:40 +0000 [thread overview]
Message-ID: <20201207010040.eriknpcidft3qul6@skbuf> (raw)
In-Reply-To: <20201206235919.393158-6-vladimir.oltean@nxp.com>
On Mon, Dec 07, 2020 at 01:59:11AM +0200, Vladimir Oltean wrote:
> In the effort of making .ndo_get_stats64 be able to sleep, we need to
> ensure the callers of dev_get_stats do not use atomic context.
>
> The bonding driver uses an RCU read-side critical section to ensure the
> integrity of the list of network interfaces, because the driver iterates
> through all net devices in the netns to find the ones which are its
> configured slaves. We still need some protection against an interface
> registering or deregistering, and the writer-side lock, the netns mutex,
> is fine for that, because it offers sleepable context.
>
> This mutex now serves double duty. It offers code serialization,
> something which the stats_lock already did. So now that serves no
> purpose, let's remove it.
>
> Cc: Jay Vosburgh <j.vosburgh@gmail.com>
> Cc: Veaceslav Falico <vfalico@gmail.com>
> Cc: Andy Gospodarek <andy@greyhouse.net>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
There is a very obvious deadlock here which happens when we have
bond-over-bond and the upper calls dev_get_stats from the lower.
Conceptually, the same can happen even in any number of stacking
combinations between bonding, net_failover, [ insert any other driver
that takes net->netdev_lists_lock here ].
There would be two approaches trying to solve this issue:
- using mutex_lock_nested where we aren't sure that we are top level
- ensuring through convention that user space always takes
net->netdev_lists_lock when calling dev_get_stats, and documenting
that, and therefore making it unnecessary to lock in bonding.
I took neither of the two approaches (I don't really like either one too
much), hence [ one of ] the reasons for the RFC. Comments?
next prev parent reply other threads:[~2020-12-07 1:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-06 23:59 [RFC PATCH net-next 00/13] Make .ndo_get_stats64 sleepable Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 01/13] RDMA/mlx4: remove bogus dev_base_lock usage Vladimir Oltean
2020-12-08 6:43 ` Leon Romanovsky
2020-12-06 23:59 ` [RFC PATCH net-next 02/13] net: mark dev_base_lock for deprecation Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 03/13] net: introduce a mutex for the netns interface lists Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 04/13] s390/appldata_net_sum: hold the netdev lists lock when retrieving device statistics Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 05/13] net: bonding: " Vladimir Oltean
2020-12-07 1:00 ` Vladimir Oltean [this message]
2020-12-07 15:22 ` Vladimir Oltean
2020-12-08 23:57 ` Jakub Kicinski
2020-12-09 0:03 ` Vladimir Oltean
2020-12-09 0:17 ` Jakub Kicinski
2020-12-09 1:14 ` Vladimir Oltean
2020-12-09 1:28 ` Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 06/13] net_failover: " Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 07/13] parisc/led: remove trailing whitespaces Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 08/13] parisc/led: reindent the code that gathers device statistics Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 09/13] parisc/led: hold the netdev lists lock when retrieving " Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 10/13] net: procfs: " Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 11/13] net: sysfs: don't hold dev_base_lock while " Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 12/13] net: mark ndo_get_stats64 as being able to sleep Vladimir Oltean
2020-12-06 23:59 ` [RFC PATCH net-next 13/13] net: remove obsolete comments about ndo_get_stats64 context from eth drivers Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201207010040.eriknpcidft3qul6@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=andrew@lunn.ch \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=j.vosburgh@gmail.com \
--cc=jbenc@redhat.com \
--cc=jhs@mojatatu.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pablo@netfilter.org \
--cc=paul.gortmaker@windriver.com \
--cc=stephen@networkplumber.org \
--cc=vfalico@gmail.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).