From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.62 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796085317; b=twtenONqmK4d8xCC8RTTdhw5IMTLSDL+fSaxUuQgQTqK2JX0wARUkQQ2eho71GzvPRWC 5+bjco2p2MpBTumT8MFgqZhaum3apRa9hDpN7fWrTBNn2Gzntb0uFKlugeIJmfyHlT3Xs EABJjZ253jZuWg6VdNODZsvS1X+pRjYGF7/7Z0ZYlVKo+VJAuoHQfB9u3VsSxySOCQ5pn NheAkT3jywGPrY60CKte5RajjoRDHEGvTEIRRJkYv514sfozITIuBPu/1AuynRAN+aI1L jxreCngfp1rNm+wB1Q4EUkGz33TW123IXNGr/IeCJR/qHhGKJPvkYiXLCUUU6fBRTOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796085317; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=NfzU5O0pXCPucBTa7AWhVzU32cZNjStJSPJ36yOTjvU=; b=4mltfVVEcMQ6a9KP/rAACBBoc3AEQnBEiKSdNDZaNA0iBtzJOKs/NBUnufLK6SVqdicS sKqS/KSys0VUuLlNbCd8nxYbxc06AVWw4XEQo/pweXuxtttbKSHsg8Iq6hyG93HJF+I/k KyUl8LZtUebt7/kjELf3oTAfMtDG/kNPprIWuPTS3eRhU9pTjQ5gecYqExrxMWXNeJXhI WsHtk3SUVcN723VHPveX9NalxIq/fLTPAkwA2xOhI5KM0lVxNshL8f41CITEQY/YZcV5p dnyf8KM1TAtQy/w1dwRT3lVlyG0mEHpiFhh0zQfvC/h/oKOnDtiOzxdPZ2EroLwq9IA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=QoJGPIyr; arc=none smtp.remote-ip=195.10.208.62 Received: from mout-b-202.mailbox.org (mout-b-202.mailbox.org [195.10.208.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7363606A33C; Tue, 1 Dec 2026 00:35:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A7363606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=QoJGPIyr Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-202.mailbox.org (Postfix) with ESMTPS id 4jdhk90Nb1zKm48; Tue, 01 Dec 2026 01:35:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796085313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NfzU5O0pXCPucBTa7AWhVzU32cZNjStJSPJ36yOTjvU=; b=QoJGPIyrUnFiLaDz0TSKscq9HM4zRMfqenpgHNG5CgFmWxomLYaN5cDav5HFpwFUJoHCZ8 HR8GToojCxnRnsUuw74aKAU0ZrE/sAq0x3NkViIXgSuPzAlx/Jc1bKDtJlILRVNh/a2eXP y3ts357+yyzL4vvv0mgTyRDOFGRRq1TWAVNJ8BMlYW+3q9dEEVwcGkE+N78MJ5Vr3C4iHm h0878Kf7YvMO2qyApqBoR7KlHw6MlHCG61836BHKNl6vjppUm93XGVV9HwyI16I+6b5jW5 yyTGEweQTy3F7gOtEkx12Oydqu9F+JOeoJ4AqkQtNE916QXhTaZ+3cK3UztaNA== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=antonio@mandelbit.com From: Antonio Quartulli To: Omar Ramadan Cc: Antonio Quartulli , Taehee Yoo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , 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 , Satish Kharat , Andrew Lunn , Simon Horman , Shuah Khan , Kees Cook , "Gustavo A. R. Silva" , 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 Message-ID: <20261201003458.3731956-4-antonio@mandelbit.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261107184437.2783174-4-omar@blockcast.net> References: <20261107184437.2783174-1-omar@blockcast.net> <20261107184437.2783174-4-omar@blockcast.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4jdhk90Nb1zKm48 On Sat, Nov 07, 2026 at 06:44:28PM +0000, Omar Ramadan wrote:=0D > +static bool amt_ofl_op_overran(struct amt_offload_bound *b, ktime_t t0)= =0D > +{=0D > + u32 tmo =3D b->caps.op_timeout_ms;=0D [...]=0D > + return tmo && ktime_ms_delta(ktime_get(), t0) > tmo;=0D > +}=0D =0D This runs only after the op has returned, so it can't detect a wedged=0D provider:=0D =0D - Hung op: the reconciler keeps st->mutex. amt_offload_teardown() then=0D blocks in mutex_lock(&st->mutex) with RTNL held, so any ip link del or=0D unregistration of the lower stalls RTNL system-wide.=0D =0D - Slow but successful op: amt_ofl_reset() flushes every object and=0D requeues every group. If the provider is consistently slower than=0D op_timeout_ms, the first replayed op overruns again, and the cycle=0D repeats with no backoff. Offload never engages. Selftest case 6=0D converges only because it sets stall_ms back to 0.=0D =0D Please drop the timeout and the reset/replay machinery (see 1/9).=0D =0D > +static bool amt_ofl_op_done(struct amt_offload_state *st,=0D > + struct amt_offload_bound *b, u64 epoch, bool overran)=0D > +{=0D > + if (overran)=0D > + amt_ofl_reset(st, b);=0D > + if (b->pub.epoch =3D=3D epoch)=0D > + return true;=0D =0D The ops are serialised under st->mutex, so the epoch only changes=0D through the reset just above it. "Stale" is therefore exactly=0D "overran", and the stale counter always equals the reset counter.=0D I think the epoch is adding nothing here, no?=0D =0D > +static void amt_ofl_desync(struct amt_offload_state *st)=0D > +{=0D > + if (st->desync)=0D > + return;=0D > + WRITE_ONCE(st->desync, true);=0D =0D Nothing ever clears desync: not teardown, not rebind, not provider=0D re-registration. So one failed GFP_ATOMIC allocation in=0D amt_ofl_member_add() keeps the relay in software until it is deleted.=0D Meanwhile offload/bound reads 1, and a required-mode relay keeps=0D carrier up. As your nomem comment already suggests, rebuild the desired=0D state from the tunnel walk in process context, then clear the flag.=0D =0D > + if (!st->enospc || !st->enospc_at ||=0D > + st->hw_objs + max(st->enospc_at / 8, 1U) > st->enospc_at)=0D > + return;=0D =0D The hysteresis can park groups forever:=0D - Every error parks a group (-ENOMEM, -EINVAL, -EIO), not only -ENOSPC.=0D =0D - A refusal with nothing programmed leaves enospc_at =3D=3D 0, so that=0D group is never retried short of a reset or a rebind.=0D =0D - On a steady or growing relay, hw_objs never falls by an eighth.=0D =0D - Endpoints added for the refused group stay programmed and keep using=0D the table that was full.=0D =0D - hw_objs mixes endpoints and groups, so endpoint churn can unpark=0D groups that were refused for a full group table.=0D =0D Retrying -ENOSPC on a timer with backoff and rolling back the unused=0D endpoints would fix it. Better still, leave this policy to the driver.=0D =0D > + hlist_for_each_entry(m, &tunnel->offload_members, tun_node) {=0D > + if (!memcmp(&m->grp->key, &gkey, sizeof(gkey))) {=0D =0D Every join and leave walks the tunnel's member list under st->lock,=0D which is shared by the whole relay and taken with BH disabled. With=0D max_groups at its policy limit of 4096, a gateway joining all its=0D groups costs about 8M memcmp() calls with BH off (!)...=0D Storing the member pointer in the gnode should make this O(1).=0D =0D > +static unsigned int amt_offload_op_budget =3D 1000;=0D > +module_param_named(offload_op_budget, amt_offload_op_budget, uint, 0444)= ;=0D =0D Please drop the module parameter.=0D =0D The budget also doesn't bound teardown. A teardown waits on st->mutex=0D for a running pass, which can still issue up to 1000 group_disable=0D calls from its gone list, or an unbudgeted release after desync.=0D Teardown then issues one op per remaining object, all with RTNL held.=0D Calling ->flush() once at teardown would bound it.=0D =0D > +static void amt_tunnel_unlink(struct amt_dev *amt,=0D > + struct amt_tunnel_list *tunnel)=0D > +{=0D > + list_del_rcu(&tunnel->list);=0D > + amt->nr_tunnels--;=0D > + amt_ofl_tunnel_gone(amt, tunnel);=0D > +}=0D =0D You list the tunnel-lifetime windows as inherited. In software a gnode=0D added after amt_clear_groups() is harmless, because the fan-out walks=0D tunnel_list. Here it becomes a member hanging off a freed tunnel that=0D no later tunnel_gone removes, so the provider keeps replicating to a=0D gateway that has left until the relay is deleted. That makes the net=0D series a hard prerequisite, and member_add should refuse a tunnel that=0D has already been unlinked.=0D =0D Regards,=0D Antonio=0D