mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@mandelbit.com>
To: Omar Ramadan <omar@blockcast.net>
Cc: Antonio Quartulli <antonio@mandelbit.com>,
	Taehee Yoo <ap420073@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
	saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com,
	mbloch@nvidia.com, brett.creeley@amd.com, sgoutham@marvell.com,
	anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
	intel-wired-lan@lists.osuosl.org,
	Ido Schimmel <idosch@nvidia.com>,
	Satish Kharat <satishkh@cisco.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [RFC PATCH net-next 3/9] amt: offload group object, desired state and reconciler
Date: Tue,  1 Dec 2026 01:34:50 +0100	[thread overview]
Message-ID: <20261201003458.3731956-4-antonio@mandelbit.com> (raw)
In-Reply-To: <20261107184437.2783174-4-omar@blockcast.net>

On Sat, Nov 07, 2026 at 06:44:28PM +0000, Omar Ramadan wrote:
> +static bool amt_ofl_op_overran(struct amt_offload_bound *b, ktime_t t0)
> +{
> +	u32 tmo = b->caps.op_timeout_ms;
[...]
> +	return tmo && ktime_ms_delta(ktime_get(), t0) > tmo;
> +}

This runs only after the op has returned, so it can't detect a wedged
provider:

- Hung op: the reconciler keeps st->mutex. amt_offload_teardown() then
  blocks in mutex_lock(&st->mutex) with RTNL held, so any ip link del or
  unregistration of the lower stalls RTNL system-wide.

- Slow but successful op: amt_ofl_reset() flushes every object and
  requeues every group. If the provider is consistently slower than
  op_timeout_ms, the first replayed op overruns again, and the cycle
  repeats with no backoff. Offload never engages. Selftest case 6
  converges only because it sets stall_ms back to 0.

Please drop the timeout and the reset/replay machinery (see 1/9).

> +static bool amt_ofl_op_done(struct amt_offload_state *st,
> +			    struct amt_offload_bound *b, u64 epoch, bool overran)
> +{
> +	if (overran)
> +		amt_ofl_reset(st, b);
> +	if (b->pub.epoch == epoch)
> +		return true;

The ops are serialised under st->mutex, so the epoch only changes
through the reset just above it. "Stale" is therefore exactly
"overran", and the stale counter always equals the reset counter.
I think the epoch is adding nothing here, no?

> +static void amt_ofl_desync(struct amt_offload_state *st)
> +{
> +	if (st->desync)
> +		return;
> +	WRITE_ONCE(st->desync, true);

Nothing ever clears desync: not teardown, not rebind, not provider
re-registration. So one failed GFP_ATOMIC allocation in
amt_ofl_member_add() keeps the relay in software until it is deleted.
Meanwhile offload/bound reads 1, and a required-mode relay keeps
carrier up. As your nomem comment already suggests, rebuild the desired
state from the tunnel walk in process context, then clear the flag.

> +	if (!st->enospc || !st->enospc_at ||
> +	    st->hw_objs + max(st->enospc_at / 8, 1U) > st->enospc_at)
> +		return;

The hysteresis can park groups forever:
- Every error parks a group (-ENOMEM, -EINVAL, -EIO), not only -ENOSPC.

- A refusal with nothing programmed leaves enospc_at == 0, so that
  group is never retried short of a reset or a rebind.

- On a steady or growing relay, hw_objs never falls by an eighth.

- Endpoints added for the refused group stay programmed and keep using
  the table that was full.

- hw_objs mixes endpoints and groups, so endpoint churn can unpark
  groups that were refused for a full group table.

Retrying -ENOSPC on a timer with backoff and rolling back the unused
endpoints would fix it. Better still, leave this policy to the driver.

> +	hlist_for_each_entry(m, &tunnel->offload_members, tun_node) {
> +		if (!memcmp(&m->grp->key, &gkey, sizeof(gkey))) {

Every join and leave walks the tunnel's member list under st->lock,
which is shared by the whole relay and taken with BH disabled. With
max_groups at its policy limit of 4096, a gateway joining all its
groups costs about 8M memcmp() calls with BH off (!)...
Storing the member pointer in the gnode should make this O(1).

> +static unsigned int amt_offload_op_budget = 1000;
> +module_param_named(offload_op_budget, amt_offload_op_budget, uint, 0444);

Please drop the module parameter.

The budget also doesn't bound teardown. A teardown waits on st->mutex
for a running pass, which can still issue up to 1000 group_disable
calls from its gone list, or an unbudgeted release after desync.
Teardown then issues one op per remaining object, all with RTNL held.
Calling ->flush() once at teardown would bound it.

> +static void amt_tunnel_unlink(struct amt_dev *amt,
> +			      struct amt_tunnel_list *tunnel)
> +{
> +	list_del_rcu(&tunnel->list);
> +	amt->nr_tunnels--;
> +	amt_ofl_tunnel_gone(amt, tunnel);
> +}

You list the tunnel-lifetime windows as inherited. In software a gnode
added after amt_clear_groups() is harmless, because the fan-out walks
tunnel_list. Here it becomes a member hanging off a freed tunnel that
no later tunnel_gone removes, so the provider keeps replicating to a
gateway that has left until the relay is deleted. That makes the net
series a hard prerequisite, and member_add should refuse a tunnel that
has already been unlinked.

Regards,
Antonio

  reply	other threads:[~2026-12-01  0:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 18:44 [RFC PATCH net-next 0/9] amt: relay replication offload provider contract (RFC, not for merge, seeking a provider) Omar Ramadan
2026-11-07 18:44 ` [RFC PATCH net-next 1/9] amt: add the relay replication offload provider header Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-11-07 18:44 ` [RFC PATCH net-next 2/9] amt: offload provider registry and lower-device lifecycle Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-11-07 18:44 ` [RFC PATCH net-next 3/9] amt: offload group object, desired state and reconciler Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli [this message]
2026-11-07 18:44 ` [RFC PATCH net-next 4/9] amt: offload TX handoff, ingress punt rule and counters Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-11-07 18:44 ` [RFC PATCH net-next 5/9] amt: add IFLA_AMT_OFFLOAD_MODE Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-11-07 18:44 ` [RFC PATCH net-next 6/9] amt: KUnit cases for the offload contract Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-11-07 18:44 ` [RFC PATCH net-next 7/9] netdevsim: add a TX reference provider for AMT relay offload Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-11-07 18:44 ` [RFC PATCH net-next 8/9] selftests: net: add amt_offload.sh " Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-11-07 18:44 ` [RFC PATCH net-next 9/9] MAINTAINERS: amt: cover the offload header and netdevsim provider Omar Ramadan
2026-12-01  0:34   ` Antonio Quartulli
2026-12-01  0:34 ` [RFC PATCH net-next 0/9] amt: relay replication offload provider contract (RFC, not for merge, seeking a provider) Antonio Quartulli

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=20261201003458.3731956-4-antonio@mandelbit.com \
    --to=antonio@mandelbit.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ap420073@gmail.com \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=omar@blockcast.net \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=saeedm@nvidia.com \
    --cc=satishkh@cisco.com \
    --cc=sgoutham@marvell.com \
    --cc=shuah@kernel.org \
    --cc=tariqt@nvidia.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

all inboxes | Powered by JetHome®