Skip to content

Commit 897eefe

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nft_set_pipapo: prefer kvmalloc for scratch maps
The scratchmap size depends on the number of elements in the set. For huge sets, each scratch map can easily require very large allocations, e.g. for 100k entries each scratch map will require close to 64kbyte of memory. Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent d8d871a commit 897eefe

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

net/netfilter/nft_set_pipapo.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ static void pipapo_free_scratch(const struct nft_pipapo_match *m, unsigned int c
11521152

11531153
mem = s;
11541154
mem -= s->align_off;
1155-
kfree(mem);
1155+
kvfree(mem);
11561156
}
11571157

11581158
/**
@@ -1173,10 +1173,9 @@ static int pipapo_realloc_scratch(struct nft_pipapo_match *clone,
11731173
void *scratch_aligned;
11741174
u32 align_off;
11751175
#endif
1176-
scratch = kzalloc_node(struct_size(scratch, map,
1177-
bsize_max * 2) +
1178-
NFT_PIPAPO_ALIGN_HEADROOM,
1179-
GFP_KERNEL_ACCOUNT, cpu_to_node(i));
1176+
scratch = kvzalloc_node(struct_size(scratch, map, bsize_max * 2) +
1177+
NFT_PIPAPO_ALIGN_HEADROOM,
1178+
GFP_KERNEL_ACCOUNT, cpu_to_node(i));
11801179
if (!scratch) {
11811180
/* On failure, there's no need to undo previous
11821181
* allocations: this means that some scratch maps have

0 commit comments

Comments
 (0)