From: Vladimir Oltean <olteanv@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: DENG Qingfang <dqfext@gmail.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Kurt Kanzenbach <kurt@linutronix.de>,
Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, Sean Wang <sean.wang@mediatek.com>,
Landen Chao <Landen.Chao@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
George McCollister <george.mccollister@gmail.com>
Subject: Re: [RFC PATCH net-next 2/4] net: dsa: remove the "dsa_to_port in a loop" antipattern from the core
Date: Tue, 10 Aug 2021 19:35:33 +0300 [thread overview]
Message-ID: <20210810163533.bn7zq2dzcilfm6o5@skbuf> (raw)
In-Reply-To: <20210810113532.tvu5dk5g7lbnrdjn@skbuf>
On Tue, Aug 10, 2021 at 02:35:32PM +0300, Vladimir Oltean wrote:
> On Tue, Aug 10, 2021 at 02:41:07AM -0700, Florian Fainelli wrote:
> > On 8/9/2021 8:33 PM, DENG Qingfang wrote:
> > > On Mon, Aug 09, 2021 at 10:03:18PM +0300, Vladimir Oltean wrote:
> > > > Ever since Vivien's conversion of the ds->ports array into a dst->ports
> > > > list, and the introduction of dsa_to_port, iterations through the ports
> > > > of a switch became quadratic whenever dsa_to_port was needed.
> > >
> > > So, what is the benefit of a linked list here? Do we allow users to
> > > insert/delete a dsa_port at runtime? If not, how about using a
> > > dynamically allocated array instead?
> >
> > The goal was to flatten the space while doing cross switch operations, which
> > would have otherwise required iterating over dsa_switch instances within a
> > dsa_switch_tree, and then over dsa_port within each dsa_switch.
>
> To expand on that: technically dsa_port_touch() _does_ happen at
> runtime, since multiple switches in a cross-chip tree probe
> asynchronously. To use a dynamically allocated array would mean to
> preallocate the sum of all DSA switch ports' worth of memory, and to
> preallocate an index for each DSA switch within that single array.
> Overall a list is simpler.
If I were to guess where Qingfang was hinting at, is that the receive
path now needs to iterate over a list, whereas before it simply indexed
an array:
static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
int device, int port)
{
struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_switch_tree *dst = cpu_dp->dst;
struct dsa_port *dp;
list_for_each_entry(dp, &dst->ports, list)
if (dp->ds->index == device && dp->index == port &&
dp->type == DSA_PORT_TYPE_USER)
return dp->slave;
return NULL;
}
I will try in the following days to make a prototype implementation of
converting back the linked list into an array and see if there is any
justifiable performance improvement.
[ even if this would make the "multiple CPU ports in LAG" implementation
harder ]
next prev parent reply other threads:[~2021-08-10 16:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-09 19:03 [RFC PATCH net-next 0/4] Remove the "dsa_to_port in a loop" antipattern Vladimir Oltean
2021-08-09 19:03 ` [RFC PATCH net-next 1/4] net: dsa: introduce a dsa_port_is_unused helper Vladimir Oltean
2021-08-10 9:34 ` Florian Fainelli
2021-08-09 19:03 ` [RFC PATCH net-next 2/4] net: dsa: remove the "dsa_to_port in a loop" antipattern from the core Vladimir Oltean
2021-08-10 3:33 ` DENG Qingfang
2021-08-10 9:41 ` Florian Fainelli
2021-08-10 11:35 ` Vladimir Oltean
2021-08-10 16:35 ` Vladimir Oltean [this message]
2021-08-10 17:04 ` DENG Qingfang
2021-08-11 17:32 ` Vladimir Oltean
2021-08-10 9:37 ` Florian Fainelli
2021-08-09 19:03 ` [RFC PATCH net-next 3/4] net: dsa: remove the "dsa_to_port in a loop" antipattern from drivers Vladimir Oltean
2021-08-09 19:03 ` [RFC PATCH net-next 4/4] net: dsa: b53: express b53_for_each_port in terms of dsa_switch_for_each_port Vladimir Oltean
2021-08-10 9:39 ` Florian Fainelli
2021-08-10 13:14 ` Vladimir Oltean
2021-08-09 19:31 ` [RFC PATCH net-next 0/4] Remove the "dsa_to_port in a loop" antipattern 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=20210810163533.bn7zq2dzcilfm6o5@skbuf \
--to=olteanv@gmail.com \
--cc=Landen.Chao@mediatek.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sean.wang@mediatek.com \
--cc=vivien.didelot@gmail.com \
--cc=vladimir.oltean@nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox