Skip to content

Commit

Permalink
bpf: ensure speculations drops are reported when needed
Browse files Browse the repository at this point in the history
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@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed May 31, 2023
1 parent 67a6679 commit 9019e92
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bpf/speculation.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ noinline uint32_t dt_speculation(void)
#define SEARCH(n) \
do { \
if (n > (uint64_t) &NSPEC) \
return 0; \
goto no_spec; \
id = (n); \
if (bpf_map_update_elem(&specs, &id, &zero, \
BPF_NOEXIST) == 0) \
Expand Down Expand Up @@ -99,6 +99,7 @@ noinline uint32_t dt_speculation(void)
}
#endif

no_spec:
return dt_no_spec(busy ? DT_STATE_SPEC_BUSY : DT_STATE_SPEC_UNAVAIL);
}

Expand Down

0 comments on commit 9019e92

Please sign in to comment.