All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	UNGLinuxDriver@microchip.com, "DENG Qingfang" <dqfext@gmail.com>,
	"Kurt Kanzenbach" <kurt@linutronix.de>,
	"Hauke Mehrtens" <hauke@hauke-m.de>,
	"Woojung Huh" <woojung.huh@microchip.com>,
	"Sean Wang" <sean.wang@mediatek.com>,
	"Landen Chao" <Landen.Chao@mediatek.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"George McCollister" <george.mccollister@gmail.com>,
	"John Crispin" <john@phrozen.org>,
	"Aleksander Jan Bajkowski" <olek2@wp.pl>,
	"Egil Hjelmeland" <privat@egil-hjelmeland.no>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	"Prasanna Vengateshan" <prasanna.vengateshan@microchip.com>,
	"Ansuel Smith" <ansuelsmth@gmail.com>,
	"Alvin Šipraga" <alsi@bang-olufsen.dk>,
	"Claudiu Manoil" <claudiu.manoil@nxp.com>
Subject: [PATCH v5 net-next 08/10] net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work
Date: Sun, 24 Oct 2021 20:17:55 +0300	[thread overview]
Message-ID: <20211024171757.3753288-9-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20211024171757.3753288-1-vladimir.oltean@nxp.com>

After talking with Ido Schimmel, it became clear that rtnl_lock is not
actually required for anything that is done inside the
SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE deferred work handlers.

The reason why it was probably added by Arkadi Sharshevsky in commit
c9eb3e0f8701 ("net: dsa: Add support for learning FDB through
notification") was to offer the same locking/serialization guarantees as
.ndo_fdb_{add,del} and avoid reworking any drivers.

DSA has implemented .ndo_fdb_add and .ndo_fdb_del until commit
b117e1e8a86d ("net: dsa: delete dsa_legacy_fdb_add and
dsa_legacy_fdb_del") - that is to say, until fairly recently.

But those methods have been deleted, so now we are free to drop the
rtnl_lock as well.

Note that exposing DSA switch drivers to an unlocked method which was
previously serialized by the rtnl_mutex is a potentially dangerous
affair. Driver writers couldn't ensure that their internal locking
scheme does the right thing even if they wanted.

We could err on the side of paranoia and introduce a switch-wide lock
inside the DSA framework, but that seems way overreaching. Instead, we
could check as many drivers for regressions as we can, fix those first,
then let this change go in once it is assumed to be fairly safe.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
v1->v5: none

 net/dsa/slave.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 9d9fef668eba..adcfb2cb4e61 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2413,7 +2413,6 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work)
 
 	dp = dsa_to_port(ds, switchdev_work->port);
 
-	rtnl_lock();
 	switch (switchdev_work->event) {
 	case SWITCHDEV_FDB_ADD_TO_DEVICE:
 		if (switchdev_work->host_addr)
@@ -2448,7 +2447,6 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work)
 
 		break;
 	}
-	rtnl_unlock();
 
 	dev_put(switchdev_work->dev);
 	kfree(switchdev_work);
-- 
2.25.1


  parent reply	other threads:[~2021-10-24 17:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-24 17:17 [PATCH v5 net-next 00/10] Drop rtnl_lock from DSA .port_fdb_{add,del} Vladimir Oltean
2021-10-24 17:17 ` [PATCH v5 net-next 01/10] net: dsa: avoid refcount warnings when ->port_{fdb,mdb}_del returns error Vladimir Oltean
2021-10-24 17:17 ` [PATCH v5 net-next 02/10] net: dsa: sja1105: wait for dynamic config command completion on writes too Vladimir Oltean
2021-10-24 17:17 ` [PATCH v5 net-next 03/10] net: dsa: sja1105: serialize access to the dynamic config interface Vladimir Oltean
2021-10-24 17:17 ` [PATCH v5 net-next 04/10] net: mscc: ocelot: serialize access to the MAC table Vladimir Oltean
2021-10-24 17:17 ` [PATCH v5 net-next 05/10] net: dsa: b53: serialize access to the ARL table Vladimir Oltean
2021-10-24 17:17 ` [PATCH v5 net-next 06/10] net: dsa: lantiq_gswip: serialize access to the PCE registers Vladimir Oltean
2021-10-24 17:17 ` [PATCH v5 net-next 07/10] net: dsa: introduce locking for the address lists on CPU and DSA ports Vladimir Oltean
2021-10-24 17:17 ` Vladimir Oltean [this message]
2021-10-24 17:17 ` [PATCH v5 net-next 09/10] selftests: lib: forwarding: allow tests to not require mz and jq Vladimir Oltean
2021-10-25  6:36   ` Ido Schimmel
2021-10-24 17:17 ` [PATCH v5 net-next 10/10] selftests: net: dsa: add a stress test for unlocked FDB operations Vladimir Oltean
2021-10-25 12:10 ` [PATCH v5 net-next 00/10] Drop rtnl_lock from DSA .port_fdb_{add,del} patchwork-bot+netdevbpf

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=20211024171757.3753288-9-vladimir.oltean@nxp.com \
    --to=vladimir.oltean@nxp.com \
    --cc=Landen.Chao@mediatek.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alsi@bang-olufsen.dk \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=dqfext@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=george.mccollister@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=olek2@wp.pl \
    --cc=olteanv@gmail.com \
    --cc=prasanna.vengateshan@microchip.com \
    --cc=privat@egil-hjelmeland.no \
    --cc=sean.wang@mediatek.com \
    --cc=vivien.didelot@gmail.com \
    --cc=woojung.huh@microchip.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.