All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Tobias Waldekranz <tobias@waldekranz.com>
Subject: Re: [PATCH v3 net-next] net: dsa: reference count the host mdb addresses
Date: Sat, 12 Dec 2020 23:06:41 +0100	[thread overview]
Message-ID: <20201212220641.GA2781095@lunn.ch> (raw)
In-Reply-To: <20201212203901.351331-1-vladimir.oltean@nxp.com>

> +	/* Complication created by the fact that addition has two phases, but
> +	 * deletion only has one phase, and we need reference counting.
> +	 * The strategy is to do the memory allocation in the prepare phase,
> +	 * but initialize the refcount in the commit phase.
> +	 *
> +	 * Have mdb	| mdb has refcount > 0	| Commit phase	| Resolution
> +	 * -------------+-----------------------+---------------+---------------
> +	 * no		| -			| no		| Alloc & proceed

This does not look right.

The point of the prepare phase is to allow all the different layers
involved to allocate whatever they need and to validate they can do
the requested action. Any layer can say, No, stop, i cannot do
this. The commit phase will then not happen. But that also means the
prepare phase should not do any state changes. So you should not be
proceeding here, just allocating.

And you need some way to cleanup the allocated memory when the commit
never happens because some other layer has said No!

     Andrew

  reply	other threads:[~2020-12-12 22:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12 20:39 [PATCH v3 net-next] net: dsa: reference count the host mdb addresses Vladimir Oltean
2020-12-12 22:06 ` Andrew Lunn [this message]
2020-12-12 22:18   ` Vladimir Oltean
2020-12-13  0:08     ` Andrew Lunn
2020-12-13  0:14       ` Vladimir Oltean
2020-12-13  0:34         ` Andrew Lunn
2020-12-13  0:49           ` Vladimir Oltean
2020-12-13  1:42             ` Florian Fainelli

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=20201212220641.GA2781095@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tobias@waldekranz.com \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.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.