Skip to contentSkip to conversation

netfilter: nft_set_pipapo: restore cloned mapping table memcg accounting

PATCH Applied Karl Mehltretter 2 participants 2 messages Oct 10 – Oct 11

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 netfilter: nft_set_pipapo: restore cloned mapping table memcg accounting

The 6.6.y backport of commit 69e687cea79f
("netfilter: nf_tables: missing objects with no memcg accounting") changed the pipapo_clone() mapping-table allocation to GFP_KERNEL_ACCOUNT.

The later stable backport of commit 07ace0bbe03b ("netfilter:
nft_set_pipapo: do not rely on ZERO_SIZE_PTR") rewrote this allocation and changed the flag back to GFP_KERNEL. Upstream applied the ZERO_SIZE_PTR change before the memcg accounting change and retains GFP_KERNEL_ACCOUNT after both.

nft_pipapo_deactivate() clones a populated set before looking up an element to delete. If the element is absent, priv->dirty remains false and the clone is retained. Its mapping tables therefore remain allocated without being charged to the requesting memory cgroup.

Restore GFP_KERNEL_ACCOUNT for the cloned mapping table.

Fixes 32bad10de347 ("netfilter: nft_set_pipapo: do not rely on ZERO_SIZE_PTR")
Assisted-by LLM

---
Changes in v2:
- Split the combined 6.1.y/6.6.y submission into one email per branch.
- Keep only the Fixes tag for this branch.
- Refresh the diff against 6.6.158; the code change is unchanged.
- Add fresh build, runtime and matched A/B results for this branch.

Original submission:
https://lore.kernel.org/r/[email protected]/

Testing on 6.6.158: built a minimal x86_64 kernel with GCC 15.2.0 and booted it in QEMU with CONFIG_MEMCG=y. A 64-element two-field interval set passed creation, lookup, update, rollback, deletion, flush and reuse checks.

Matched unpatched and patched boots used the same kernel configuration and initramfs. During a normal update from a memory cgroup, both cloned mapping-table allocations (512 bytes each) had accounted=false without the patch. With the patch, both used GFP_KERNEL_ACCOUNT and had accounted=true. Both variants passed normal set operations without kernel warnings.

Earlier A/B testing on 6.1.186 and 6.6.155 measured 524,288 additional charged bytes for the cloned mapping tables of a 32,768-element two-field set. An unmodified 6.12.107 control already accounted that allocation.

 net/netfilter/nft_set_pipapo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_set_pipapo.c +1 -1
index 7c8d28a031ad..4c3bb5d61a3b 100644
@@ -1465,7 +1465,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
 				goto out_mt;
 
 			dst->mt = kvmalloc_array(src->rules, sizeof(*src->mt),
-						 GFP_KERNEL);
+						 GFP_KERNEL_ACCOUNT);
 			if (!dst->mt)
 				goto out_mt;
 
maintainer Applied
#1 lore raw
Quoted 1 line

Restore GFP_KERNEL_ACCOUNT for the cloned mapping table.

Queued for 6.6, thanks.

Signature · 2 lines
Thanks,
Sasha