From: Florian Westphal <fw@strlen.de>
To: Jozsef Kadlecsik <kadlec@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf] netfilter: ipset: remove need to allocate memory on delete operations
Date: Sun, 9 Aug 2026 16:24:12 +0200 [thread overview]
Message-ID: <aniNjO71_0Bv2UMI@strlen.de> (raw)
In-Reply-To: <abb4fda6-444f-2c79-573a-740529e468c9@netfilter.org>
Jozsef Kadlecsik <kadlec@netfilter.org> wrote:
> > /* Book-keeping of the prefixes added to the set */
> > struct net_prefix {
> > - u8 cidr; /* the cidr value */
> > - u32 count; /* number of elements of this cidr */
> > + u32 cidr:8;
> > + u32 count:24;
> > };
> > +#define CIDR_MAX_COUNT ((1 << 24) - 1)
>
> Could it be changed to
>
> struct net_prefix {
> u64 cidr:8;
> u64 count:24;
> };
> #define CIDR_MAX_COUNT ((1 << 56) - 1)
>
> (and the other required changes below)?
Only for 64bit builds, because WRITE_ONCE() is not atomic on 32bit.
If we do it for 32 bit builds, all read side paths would need to
switch to write seqcount use (including the normal case, i.e.
nets[i]->count++ / count. ATM only the "it became 0 and has
to be moved) uses the sequence write lock, so read side never
retries for typical updates.
> 2**24 is a lot but still a reachable limit.
Hmm. 16m entries... I guess its possible for very small prefix
lengths? We could use BITS_PER_LONG == 64 but it gets more ugly then.
> > + if (np.count) {
> > + WRITE_ONCE(nets->nets[found], np);
> > goto unlock;
This should be the typical case, which doesn't change the
write seq side, hence no retry on reader side.
This would have to be changed if we no longer rely
on READ/WRITE_ONCE.
next prev parent reply other threads:[~2026-08-09 14:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 17:02 [PATCH nf] netfilter: ipset: remove need to allocate memory on delete operations Florian Westphal
2026-08-09 11:15 ` Jozsef Kadlecsik
2026-08-09 14:24 ` Florian Westphal [this message]
2026-08-10 15:10 ` Jozsef Kadlecsik
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=aniNjO71_0Bv2UMI@strlen.de \
--to=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=netfilter-devel@vger.kernel.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 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.