]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
bpf: sk_storage: Prefer to get a free cache_idx
authorMartin KaFai Lau <kafai@fb.com>
Wed, 17 Jun 2020 17:42:26 +0000 (10:42 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 18 Jun 2020 21:41:09 +0000 (14:41 -0700)
commit7c7982cbadbb63eb76401ddc4ef090cf7ae274b4
treeec72373aaeaa183802cb6cc4bd46feb2098541aa
parent7bd3a33ae6d2b820bc44a206f9b81b96840219fd
bpf: sk_storage: Prefer to get a free cache_idx

The cache_idx is currently picked by RR.  There is chance that
the same cache_idx will be picked by multiple sk_storage_maps while
other cache_idx is still unused.  e.g. It could happen when the
sk_storage_map is recreated during the restart of the user
space process.

This patch tracks the usage count for each cache_idx.  There is
16 of them now (defined in BPF_SK_STORAGE_CACHE_SIZE).
It will try to pick the free cache_idx.  If none was found,
it would pick one with the minimal usage count.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200617174226.2301909-1-kafai@fb.com
net/core/bpf_sk_storage.c