]> git.ipfire.org Git - thirdparty/linux.git/commit
ipvs: use resizable hash table for services
authorJulian Anastasov <ja@ssi.bg>
Tue, 3 Mar 2026 21:04:06 +0000 (23:04 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 4 Mar 2026 10:45:45 +0000 (11:45 +0100)
commit840aac3d900d09ec8fb8efe41bd7d09f9eb15538
tree828b1061ed1d7acdab2edb022db2eedcab6a4d5b
parentb655388111cf7e43f70e49db64bdaa42bcb8a038
ipvs: use resizable hash table for services

Make the hash table for services resizable in the bit range of 4-20.
Table is attached only while services are present. Resizing is done
by delayed work based on load (the number of hashed services).
Table grows when load increases 2+ times (above 12.5% with lfactor=-3)
and shrinks 8+ times when load decreases 16+ times (below 0.78%).

Switch to jhash hashing to reduce the collisions for multiple
services.

Add a hash_key field into the service to store the table ID in
the highest bit and the entry's hash value in the lowest bits. The
lowest part of the hash value is used as bucket ID, the remaining
part is used to filter the entries in the bucket before matching
the keys and as result, helps the lookup operation to access only
one cache line. By knowing the table ID and bucket ID for entry,
we can unlink it without calculating the hash value and doing
lookup by keys. We need only to validate the saved hash_key under
lock.

Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Florian Westphal <fw@strlen.de>
include/net/ip_vs.h
net/netfilter/ipvs/ip_vs_ctl.c