All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>, Tobias Waldekranz <tobias@waldekranz.com>
Cc: 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: Thu, 19 Nov 2020 18:43:38 -0800	[thread overview]
Message-ID: <5e2d23da-7107-e45e-0ab3-72269d7b6b24@gmail.com> (raw)
In-Reply-To: <20201120003009.GW1804098@lunn.ch>



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?
-- 
Florian

  reply	other threads:[~2020-11-20  2:43 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 [this message]
2020-11-20 13:30       ` Andrew Lunn
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=5e2d23da-7107-e45e-0ab3-72269d7b6b24@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --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.