Skip to content

netfilter: x_tables: pack percpu counter allocations

Florian Westphal netfilter-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 1 replyIn review
  2. v23 patches 1 replySuperseded
  3. v13 patches 3 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3netfilter: x_tables: pass xt_counters struct instead of packet counterinclude/linux/netfilter/x_tables.h net/ipv4/netfilter/arp_tables.c net/ipv4/netfilter/ip_tables.c +2 more+16 -120 replies
2/3netfilter: x_tables: pass xt_counters struct to counter allocatorinclude/linux/netfilter/x_tables.h net/ipv4/netfilter/arp_tables.c net/ipv4/netfilter/ip_tables.c +2 more+34 -380 replies
3/3netfilter: x_tables: pack percpu counter allocationsinclude/linux/netfilter/x_tables.h net/ipv4/netfilter/arp_tables.c net/ipv4/netfilter/ip_tables.c +2 more+48 -190 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchEric Dumazet
1/3A-b
2/3A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 nf-next 0/3] netfilter: x_tables: pack percpu counter allocations

... to speed up iptables(-restore) calls.

Especially a pattern like

for i in $(seq 1 1000) ; iptables -A FORWARD ;done

is expensive, because adding the rule doubles the percpu counters (allocate
2nd blob, then free old one, including its percpu counters).
This causes frequent expansion and shrinking of percpu memory pool.

This change batches calls to the allocator by packing multiple counters in 4k memory chunks.

Heavily based on suggestions from Eric Dumazet.

The only change in v3 is in patch #2 which assigned garbage on UP (was fixed by next patch, but better to not do it in first place).