From: Ralf Lici <ralf@mandelbit.com>
To: qiliang.yuan@linux.dev
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@kernel.org,
horms@kernel.org, idosch@nvidia.com, kuba@kernel.org,
kuniyu@google.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com, razor@blackwall.org
Subject: Re: [PATCH net-next v4 2/4] ipv6: take fib6_sernum from a sequence shared by all netns
Date: Fri, 20 Nov 2026 18:52:41 +0100 [thread overview]
Message-ID: <20261120175241.289834-1-ralf@mandelbit.com> (raw)
In-Reply-To: <20261117-bug-net-netns-move-rcu-barrier-v4-2-43e1ca0aac7f@linux.dev>
Hi Qiliang,
I stumbled upon this series while looking for what caused a conflict
patchwork reported on one of my series [1], which touches the same code.
On Tue, 17 Nov 2026 21:28:31 -0500, Qiliang Yuan wrote:
> 2^31 bumps. fib6_new_sernum() callers only hold their own table's
> tb6_lock, so two tables of one netns can store their values in either
> order, and fib6_sernum is no longer monotonic per netns. It is only
> compared for equality, so this costs at most an extra invalidation.
Eric raised this on v1 [2], and for the equality checks I agree: values
are not reused, so a stale value cannot match. What the atomic_set
changes is the ordering. It comes after the full barrier of the cmpxchg,
so nothing orders it before the node stamp in fib6_update_sernum: a
reader can sample the new fn_sernum while still reading the old
generation (this one is allowed on arm64). Nothing in the tree compares
the two today, but my series relies on that order, since it brackets the
lookup and cookie sampling with two reads of the generation.
The late store also loses the guarantee that a reader seeing a value
sees the routing changes published before it. With the per-netns
cmpxchg, each update reads from the previous one. Here, CPU0 can draw 2
and stall while CPU1 links a route, draws 3 and publishes it, and then
CPU0 stores 2. LKMM allows a reader that reads 2 to miss CPU1's route
(x86 and arm64 forbid it in practice), and a per-cpu dst of a nexthop
object allocated from that lookup records 2 and passes rt6_is_valid
until the next bump.
Drawing from the shared sequence but publishing with a cmpxchg on the
per-netns counter keeps both, at the cost of a wasted draw on
contention:
static int fib6_new_sernum(struct net *net)
{
int old = atomic_read(&net->ipv6.fib6_sernum);
int new;
do {
new = fib6_sernum_draw();
} while (!atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new));
return new;
}
where fib6_sernum_draw is your current loop on fib6_sernum_seq. I
checked both cases with LKMM litmus tests: they are reachable with
atomic_set and forbidden with the cmpxchg publish.
1/4 has the same pattern for rt_genid, and IPv4 bumps can run
concurrently too, since xfrm policy insertion does not hold RTNL.
[1] https://lore.kernel.org/netdev/cover.1795166508.git.ralf@mandelbit.com/
[2] https://lore.kernel.org/netdev/CAL4WiioL+wiv3jgqeT1qiZ2mGWQ+HV+mEQP2K0aFMCpjDvwYDg@mail.gmail.com/
--
Ralf Lici
Mandelbit Srl
next prev parent reply other threads:[~2026-11-20 17:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 2:28 [PATCH net-next v4 0/4] net: make moving a device to another netns cheaper Qiliang Yuan
2026-11-18 2:28 ` [PATCH net-next v4 1/4] ipv4: draw rt_genid from a sequence shared by all netns Qiliang Yuan
2026-11-18 2:28 ` [PATCH net-next v4 2/4] ipv6: take fib6_sernum " Qiliang Yuan
2026-11-20 17:52 ` Ralf Lici [this message]
2026-11-18 2:28 ` [PATCH net-next v4 3/4] nexthop: release cached routes when a nexthop leaves a group Qiliang Yuan
2026-11-18 2:28 ` [PATCH net-next v4 4/4] net: remove rcu_barrier() from __dev_change_net_namespace() Qiliang Yuan
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=20261120175241.289834-1-ralf@mandelbit.com \
--to=ralf@mandelbit.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qiliang.yuan@linux.dev \
--cc=razor@blackwall.org \
/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®