]> Gentwo Git Trees - linux/.git/commit
bpf: Improve the general precision of tnum_mul
authorNandakumar Edamana <nandakumar@nandakumar.co.in>
Tue, 26 Aug 2025 03:45:23 +0000 (09:15 +0530)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 27 Aug 2025 22:00:26 +0000 (15:00 -0700)
commit1df7dad4d5c49335b72e26d833def960b2de76e3
tree9f96e2afa5ac408fe3b108e964b586fe4c238793
parent2465bb83e0b44e19ae7e3ad07148db61fbe0e2bf
bpf: Improve the general precision of tnum_mul

Drop the value-mask decomposition technique and adopt straightforward
long-multiplication with a twist: when LSB(a) is uncertain, find the
two partial products (for LSB(a) = known 0 and LSB(a) = known 1) and
take a union.

Experiment shows that applying this technique in long multiplication
improves the precision in a significant number of cases (at the cost
of losing precision in a relatively lower number of cases).

Signed-off-by: Nandakumar Edamana <nandakumar@nandakumar.co.in>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
Reviewed-by: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/20250826034524.2159515-1-nandakumar@nandakumar.co.in
include/linux/tnum.h
kernel/bpf/tnum.c