[DTrace-devel] [PATCH] bpf: ensure speculations drops are reported when needed

Kris Van Hees kris.van.hees at oracle.com
Tue May 30 18:25:51 UTC 2023


The unrolled loop in dt_speculation() would return without recording
a speculation drop if an iteration was attempted beyond the configured
NSPEC value.  Depending on how the compiler optimized the code, that
could lead to an early return from the function without ever calling
dt_no_spec().

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 bpf/speculation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bpf/speculation.c b/bpf/speculation.c
index 82d09e1a..7f4ebd34 100644
--- a/bpf/speculation.c
+++ b/bpf/speculation.c
@@ -54,7 +54,7 @@ noinline uint32_t dt_speculation(void)
 #define SEARCH(n)							\
 	do {								\
 		if (n > (uint64_t) &NSPEC)				\
-			return 0;					\
+			break;						\
 		id = (n);						\
 		if (bpf_map_update_elem(&specs, &id, &zero,		\
 			BPF_NOEXIST) == 0)				\
-- 
2.40.1




More information about the DTrace-devel mailing list