From 8907fd511a04dafb10c5c152dca4a80e053a9a72 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Fri, 9 Oct 2026 01:54:13 +0530 Subject: [PATCH] Tools: Stop counting plain loops as a hard blocker in the selftest audit for/while lower since #106. The iterator loops (bpf_for, bpf_repeat) and the bpf_loop helper do not, so they keep a hard label of their own, and a do { } while (0) macro is no longer read as a loop. Against bpf-next 5714ca8 the programs with no hard blocker go from 29 to 39. Co-Authored-By: Claude Opus 5.5 (1M context) --- tools/selftest-audit.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/selftest-audit.py b/tools/selftest-audit.py index 26f6798..3a6d78b 100755 --- a/tools/selftest-audit.py +++ b/tools/selftest-audit.py @@ -15,7 +15,7 @@ negatives in both directions, and the envelope it encodes (the helper, map and construct lists below) must be kept in step with the compiler by hand. Re-run it after a feature lands to see what the feature unlocked. The lists were last reconciled against pythonbpf/helper and pythonbpf/maps when scalar @bpfglobal -support and integer signedness merged. +support, integer signedness and loops merged. """ import argparse @@ -70,7 +70,10 @@ NOT_HELPERS = { # cost a careful rewrite can absorb). Order does not matter. PATTERNS = [ # control flow - ("loop", "hard", r"\b(for|while)\s*\(|\bbpf_for\b|\bbpf_repeat\b|\bbpf_loop\s*\("), + # plain for/while lower since loops landed (#106); `do { } while (0)` is a + # macro idiom, not a loop. Iterator loops and the bpf_loop helper are not. + ("open_coded_loop", "hard", r"\bbpf_for(_each)?\b|\bbpf_repeat\b|\bbpf_loop\s*\("), + ("do_while", "soft", r"\}\s*while\s*\((?!\s*0\s*\))"), ("goto", "hard", r"\bgoto\s+\w+"), ("switch", "hard", r"\bswitch\s*\("), ("ternary", "soft", r"\?[^?:]*:"),