diff options
| author | Vinicius Sampaio <vldsampaio@pm.me> | 2026-07-30 10:21:32 +0000 |
|---|---|---|
| committer | Eduard Zingerman <eddyz87@gmail.com> | 2026-08-20 23:58:07 -0700 |
| commit | 705249119d942e7228d9207800ddfa13e4601b19 (patch) | |
| tree | 8f080e98965b09fa4b9de72c8f8c81bed5a464d5 /scripts/Makefile.thinlto | |
| parent | b601a4ecbe672371776785bd7ac142af0ac395ac (diff) | |
| download | linux-next-705249119d942e7228d9207800ddfa13e4601b19.tar.gz linux-next-705249119d942e7228d9207800ddfa13e4601b19.zip | |
bpf: Avoid redundant min()/max() in cnum signed bounds
Simplify the smin() and smax() calculation by removing the integer min
and max calculation on the non-overflowing branch. This is a valid
simplification because when the arc does not cross the signed
ST_MAX/ST_MIN boundary, the signed order of the endpoints is preserved,
so base is the signed minimum and base + size is the signed maximum.
Therefore, the min()/max() calls are redundant.
We've also run benchmarks to compare the performance of this change.
With O2 optimization we have:
smin() results:
| Test | smin | smin_new |
| ------------------------ | ----------- | ----------- |
| empty | 1.866 ns/op | 1.477 ns/op |
| positive range | 1.870 ns/op | 1.248 ns/op |
| negative range | 1.657 ns/op | 1.246 ns/op |
| cross zero | 1.870 ns/op | 1.660 ns/op |
| signed overflow boundary | 1.463 ns/op | 1.049 ns/op |
| signed overflow range | 1.519 ns/op | 1.050 ns/op |
| unsigned overflow range | 1.883 ns/op | 1.669 ns/op |
| full range | 1.555 ns/op | 1.049 ns/op |
smax() results:
| Test | smax | smax_new |
| ------------------------ | ----------- | ----------- |
| empty | 1.462 ns/op | 1.456 ns/op |
| positive range | 1.250 ns/op | 1.249 ns/op |
| negative range | 1.259 ns/op | 1.297 ns/op |
| cross zero | 1.471 ns/op | 1.475 ns/op |
| signed overflow boundary | 1.056 ns/op | 1.260 ns/op |
| signed overflow range | 1.049 ns/op | 1.259 ns/op |
| unsigned overflow range | 1.470 ns/op | 1.477 ns/op |
| full range | 1.072 ns/op | 1.263 ns/op |
You can check the full implementation of these tests on this repository:
https://github.com/OpenSourceVerif/open-verified-artifacts/tree/cnum-refactor-verif/cnum/benches
Lean4 proofs showing that the new implementation preserves soundness of
these operations are available at:
https://github.com/OpenSourceVerif/open-verified-artifacts/tree/cnum-refactor-verif/cnum/lean
Co-developed-by: Yazhou Tang <tangyazhou518@outlook.com>
Co-developed-by: Shenghao Yuan <shenghaoyuan0928@163.com>
Signed-off-by: Yazhou Tang <tangyazhou518@outlook.com>
Signed-off-by: Shenghao Yuan <shenghaoyuan0928@163.com>
Signed-off-by: Vinicius Sampaio <vldsampaio@pm.me>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Link: https://patch.msgid.link/20260730102129.15209-4-vldsampaio@pm.me
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
