All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Tobias Waldekranz <tobias@waldekranz.com>,
	davem@davemloft.net, kuba@kernel.org, vivien.didelot@gmail.com,
	olteanv@gmail.com, j.vosburgh@gmail.com, vfalico@gmail.com,
	andy@greyhouse.net, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/4] net: dsa: Link aggregation support
Date: Fri, 20 Nov 2020 14:30:50 +0100	[thread overview]
Message-ID: <20201120133050.GF1804098@lunn.ch> (raw)
In-Reply-To: <5e2d23da-7107-e45e-0ab3-72269d7b6b24@gmail.com>

On Thu, Nov 19, 2020 at 06:43:38PM -0800, Florian Fainelli wrote:
> 
> 
> On 11/19/2020 4:30 PM, Andrew Lunn wrote:
> >> +static struct dsa_lag *dsa_lag_get(struct dsa_switch_tree *dst,
> >> +				   struct net_device *dev)
> >> +{
> >> +	unsigned long busy = 0;
> >> +	struct dsa_lag *lag;
> >> +	int id;
> >> +
> >> +	list_for_each_entry(lag, &dst->lags, list) {
> >> +		set_bit(lag->id, &busy);
> >> +
> >> +		if (lag->dev == dev) {
> >> +			kref_get(&lag->refcount);
> >> +			return lag;
> >> +		}
> >> +	}
> >> +
> >> +	id = find_first_zero_bit(&busy, BITS_PER_LONG);
> >> +	if (id >= BITS_PER_LONG)
> >> +		return ERR_PTR(-ENOSPC);
> >> +
> >> +	lag = kzalloc(sizeof(*lag), GFP_KERNEL);
> >> +	if (!lag)
> >> +		return ERR_PTR(-ENOMEM);
> > 
> > Hi Tobias
> > 
> > My comment last time was to statically allocated them at probe
> > time. Worse case scenario is each port is alone in a LAG. Pointless,
> > but somebody could configure it. In dsa_tree_setup_switches() you can
> > count the number of ports and then allocate an array, or while setting
> > up a port, add one more lag to the list of lags.
> 
> The allocation is allowed to sleep (have not checked the calling context
> of dsa_lag_get() whether this is OK) so what would be the upside of
> doing upfront dsa_lag allocation which could be wasteful?

Hi Florian

It fits the pattern for the rest of the DSA core. We never allocate
anything at runtime. That keeps the error handling simple, we don't
need to deal with ENOMEM errors, undoing whatever we might of done,
implementing transactions etc.

And the memory involved here is small. I guess around 80 bytes per
lag? So even for a 10 port switch, we are only talking about 800
bytes. That is not a lot.

       Andrew

  reply	other threads:[~2020-11-20 13:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 14:45 [PATCH net-next 0/4] net: dsa: Link aggregation support Tobias Waldekranz
2020-11-19 14:45 ` [PATCH net-next 1/4] net: bonding: Notify ports about their initial state Tobias Waldekranz
2020-11-19 18:18   ` Jay Vosburgh
2020-11-19 21:20     ` Tobias Waldekranz
2020-11-19 14:45 ` [PATCH net-next 2/4] net: dsa: Link aggregation support Tobias Waldekranz
2020-11-20  0:30   ` Andrew Lunn
2020-11-20  2:43     ` Florian Fainelli
2020-11-20 13:30       ` Andrew Lunn [this message]
2020-11-26 22:36         ` Tobias Waldekranz
2020-11-26 22:57           ` Andrew Lunn
2020-11-27  9:19             ` Tobias Waldekranz
2020-11-27 16:28               ` Andrew Lunn
2020-11-27 23:19                 ` Tobias Waldekranz
2020-11-28  5:19                   ` Florian Fainelli
2020-11-28 16:38                     ` Andrew Lunn
2020-11-28 19:48                       ` Tobias Waldekranz
2020-11-19 14:45 ` [PATCH net-next 3/4] net: dsa: mv88e6xxx: " Tobias Waldekranz
2020-11-19 14:45 ` [PATCH net-next 4/4] net: dsa: tag_dsa: Support reception of packets from LAG devices Tobias Waldekranz

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=20201120133050.GF1804098@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=j.vosburgh@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=tobias@waldekranz.com \
    --cc=vfalico@gmail.com \
    --cc=vivien.didelot@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 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.