Skip to content

Commit

Permalink
libbpf-tools/softirqs: Fix logarithmic calculation issue
Browse files Browse the repository at this point in the history
Should use log2l.
When there is a function call, R1 unbounded memory access problem occurs,
so inline is used.

Signed-off-by: Feng Yang <[email protected]>
  • Loading branch information
kknjh committed Feb 7, 2025
1 parent 3896116 commit 6cade19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libbpf-tools/softirqs.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static int handle_entry(unsigned int vec_nr)
return 0;
}

static int handle_exit(unsigned int vec_nr)
static __always_inline int handle_exit(unsigned int vec_nr)
{
if (!is_target_cpu())
return 0;
Expand All @@ -66,7 +66,7 @@ static int handle_exit(unsigned int vec_nr)
u64 slot;

hist = &hists[vec_nr];
slot = log2(delta);
slot = log2l(delta);
if (slot >= MAX_SLOTS)
slot = MAX_SLOTS - 1;
__sync_fetch_and_add(&hist->slots[slot], 1);
Expand Down

0 comments on commit 6cade19

Please sign in to comment.