Skip to contentSkip to conversation

netfilter: nft_set_pipapo: increment data in one step

PATCH In review Florian Westphal 2 participants 2 messages Mar 18 – Mar 21

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nft_set_pipapo: increment data in one step

For unkown reason the C version increments the data pointer in two steps. Switch to a single invocation of NFT_PIPAPO_GROUPS_PADDED_SIZE() helper, like the avx2 implementation.

---
 net/netfilter/nft_set_pipapo.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/netfilter/nft_set_pipapo.c +1 -3
index 7fd24e0cc428..50d4a4f04309 100644
@@ -452,8 +452,6 @@ static struct nft_pipapo_elem *pipapo_get_slow(const struct nft_pipapo_match *m,
 			pipapo_and_field_buckets_4bit(f, res_map, data);
 		NFT_PIPAPO_GROUP_BITS_ARE_8_OR_4;
 
-		data += f->groups / NFT_PIPAPO_GROUPS_PER_BYTE(f);
-
 		/* Now populate the bitmap for the next field, unless this is
 		 * the last field, in which case return the matched 'ext'
 		 * pointer if any.
@@ -498,7 +496,7 @@ static struct nft_pipapo_elem *pipapo_get_slow(const struct nft_pipapo_match *m,
 		map_index = !map_index;
 		swap(res_map, fill_map);
 
-		data += NFT_PIPAPO_GROUPS_PADDING(f);
+		data += NFT_PIPAPO_GROUPS_PADDED_SIZE(f);
 	}
 
 	__local_unlock_nested_bh(&scratch->bh_lock);
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · On Wed, 18 Mar 2026 14:38:34 +0100 Florian Westphal <[email protected]> wrote:

For unkown reason the C version increments the data pointer in two steps.

That's because before commit e807b13cb3e3 ("nft_set_pipapo: Generalise group size for buckets") pipapo_get() contained the whole lookup implementation with __bitmap_and(), and 'data' was used as pointer to move between bit groups, and incremented as we went through them.

With that commit, we don't need to keep 'data' updated during the lookup anymore, so I just replaced the initial increment, but I didn't notice that 'data' isn't used at all before the second increment now, and that the two increments could be merged.

Quoted 4 lines

Switch to a single invocation of NFT_PIPAPO_GROUPS_PADDED_SIZE() helper, like the avx2 implementation.

Signature · 1 line
Stefano