summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorQiliang Yuan <realwujing@gmail.com>2026-01-20 05:32:34 +0300
committerAndrii Nakryiko <andrii@kernel.org>2026-01-20 22:32:28 +0300
commitf81c07a6e98e3171d0c4c5ab79f5aeff71b42c44 (patch)
tree7742b4c51a866b0e60f8f4e63aaed53390097deb /include/linux
parent713edc71449f122491f8860be49b40f27d5f46b5 (diff)
downloadlinux-f81c07a6e98e3171d0c4c5ab79f5aeff71b42c44.tar.xz
bpf/verifier: Optimize ID mapping reset in states_equal
Currently, reset_idmap_scratch() performs a 4.7KB memset() in every states_equal() call. Optimize this by using a counter to track used ID mappings, replacing the O(N) memset() with an O(1) reset and bounding the search loop in check_ids(). Signed-off-by: Qiliang Yuan <realwujing@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/bpf/20260120023234.77673-1-realwujing@gmail.com
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bpf_verifier.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 130bcbd66f60..8355b585cd18 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -692,6 +692,7 @@ struct bpf_id_pair {
struct bpf_idmap {
u32 tmp_id_gen;
+ u32 cnt;
struct bpf_id_pair map[BPF_ID_MAP_SIZE];
};