From: Florian Westphal <fw@strlen.de>
To: Jesper Dangaard Brouer <hawk@kernel.org>
Cc: netfilter-devel@vger.kernel.org,
Pablo Neira Ayuso <pablo@netfilter.org>,
netdev@vger.kernel.org, phil@nwl.cc,
Eric Dumazet <eric.dumazet@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
kernel-team@cloudflare.com, mfleming@cloudflare.com,
matt@readmodwrite.com
Subject: Re: [PATCH nf-next RFC 2/3] xt_statistic: do nth-mode accounting per CPU
Date: Mon, 8 Dec 2025 15:46:13 +0100 [thread overview]
Message-ID: <aTbktQxxH5gUJrB6@strlen.de> (raw)
In-Reply-To: <aShkog5k8nsD5YsA@strlen.de>
Florian Westphal <fw@strlen.de> wrote:
> Jesper Dangaard Brouer <hawk@kernel.org> wrote:
> > The atomic cmpxchg operations for the nth-mode matching is a scaling
> > concern, on our production servers with 192 CPUs. The iptables rules that
> > does sampling of every 10000 packets exists on INPUT and OUTPUT chains.
> > Thus, these nth-counter rules are hit for every packets on the system with
> > high concurrency.
>
> > Our use-case is statistical sampling, where we don't need an accurate packet
> > across all CPUs in the system. Thus, we implement per-CPU counters for the
> > nth-mode match.
> >
> > This replaces the XT_STATISTIC_MODE_NTH, to avoid having to change userspace
> > tooling. We keep and move atomic variant under XT_STATISTIC_MODE_NTH_ATOMIC
> > mode, which userspace can easily be extended to leverage if this is
> > necessary.
>
> This patch seems acceptable to me (aside from the deliberate userspace
> breakage).
>
> But I do wonder why you can't move to random sampling instead, it
> doesn't suffer from this problem (i.e. -m statistic --mode random).
Addendum, did not think of this before. Another alternative is to
prefix '-m statistic' with '-m cpu' so only one core will do the
sampling. If this should be done on all cpus then xtables
framework would require n rules for n cpus which scales poorly.
In nftables one could use verdict map with 'meta cpu' as a hash key,
then one would be able to fanout based on processing cpu.
next prev parent reply other threads:[~2025-12-08 14:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 12:33 [PATCH nf-next RFC 0/3] netfilter: x_tables: statistic nth match account GRO/GSO packets Jesper Dangaard Brouer
2025-11-27 12:33 ` [PATCH nf-next RFC 1/3] xt_statistic: taking GRO/GSO into account for nth-match Jesper Dangaard Brouer
2025-11-27 14:40 ` Florian Westphal
2025-12-05 16:23 ` Jesper Dangaard Brouer
2025-12-08 10:37 ` Nick Wood
2025-12-08 14:18 ` Florian Westphal
2025-11-27 12:34 ` [PATCH nf-next RFC 2/3] xt_statistic: do nth-mode accounting per CPU Jesper Dangaard Brouer
2025-11-27 14:48 ` Florian Westphal
2025-12-08 14:46 ` Florian Westphal [this message]
2025-11-27 12:34 ` [PATCH nf-next RFC 3/3] xt_statistic: DEBUG patch Jesper Dangaard Brouer
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=aTbktQxxH5gUJrB6@strlen.de \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=hawk@kernel.org \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=matt@readmodwrite.com \
--cc=mfleming@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/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;
as well as URLs for NNTP newsgroup(s).