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 15:22:26 +0000 [thread overview]
Message-ID: <20201207152225.hcvdq2n7ayo63f6k@skbuf> (raw)
In-Reply-To: <20201207010040.eriknpcidft3qul6@skbuf>
On Mon, Dec 07, 2020 at 03:00:40AM +0200, Vladimir Oltean wrote:
> 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?
And there are also issues which are more subtle (or maybe just to me, at
the time I wrote the patch). Like the fact that the netdev adjacency
lists are not protected by net->netdev_lists_lock, but still by the RTNL
mutex and RCU. I think that in order for the iteration through lower
interfaces to capture a consistent state of the adjancency lists of all
interfaces, the __netdev_adjacent_dev_link_lists and
__netdev_adjacent_dev_unlink_lists functions would need to be run under
the net->netdev_lists_lock, and not just under some lock per-netdev.
But this is raising the locking domain covered by net->netdev_lists_lock
to more than I initially intended. I'll try to do this and see how it
works.
next prev parent reply other threads:[~2020-12-07 15:23 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
2020-12-07 15:22 ` Vladimir Oltean [this message]
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=20201207152225.hcvdq2n7ayo63f6k@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