OSDN Git Service

bpf: compute hashes in bloom filter similar to hashmap
authorAnton Protopopov <aspsk@isovalent.com>
Sun, 2 Apr 2023 11:43:40 +0000 (11:43 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 2 Apr 2023 15:44:49 +0000 (08:44 -0700)
commit92b2e810f0d3a2c05d8cf12a800592b238d458df
tree82c98bc9cc83fee106fbc86c678fa22563cd5ea8
parent5b85575ad4280171c382e888b006cb8d12c35bde
bpf: compute hashes in bloom filter similar to hashmap

If the value size in a bloom filter is a multiple of 4, then the jhash2()
function is used to compute hashes. The length parameter of this function
equals to the number of 32-bit words in input. Compute it in the hot path
instead of pre-computing it, as this is translated to one extra shift to
divide the length by four vs. one extra memory load of a pre-computed length.

Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
Link: https://lore.kernel.org/r/20230402114340.3441-1-aspsk@isovalent.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/bloom_filter.c