All of lore.kernel.org
 help / color / mirror / Atom feed
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: Thu, 27 Nov 2025 15:48:02 +0100	[thread overview]
Message-ID: <aShkog5k8nsD5YsA@strlen.de> (raw)
In-Reply-To: <176424684236.194326.12739516403715190883.stgit@firesoul>

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).

I think a non-rfc version would have to add a new mode, plus the
userspace change, and an explanation why -m random can't be used,
esp.  because the changelog above implies to me that -m random would work
for this :-)

  reply	other threads:[~2025-11-27 14:48 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 [this message]
2025-12-08 14:46     ` Florian Westphal
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=aShkog5k8nsD5YsA@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 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.