From e1cde2d5e92f6728a022754650b9cb1e38358d50 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 27 Feb 2025 11:12:23 -0800 Subject: [PATCH] perf ftrace: Use atomic inc to update histogram in BPF It should use an atomic instruction to update even if the histogram is keyed by delta as it's also used for stats. Cc: Gabriele Monaco Link: https://lore.kernel.org/r/20250227191223.1288473-3-namhyung@kernel.org Signed-off-by: Namhyung Kim --- tools/perf/util/bpf_skel/func_latency.bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/bpf_skel/func_latency.bpf.c b/tools/perf/util/bpf_skel/func_latency.bpf.c index ad7054744678..e731a79a753a 100644 --- a/tools/perf/util/bpf_skel/func_latency.bpf.c +++ b/tools/perf/util/bpf_skel/func_latency.bpf.c @@ -142,7 +142,7 @@ do_lookup: if (!hist) return 0; - *hist += 1; + __sync_fetch_and_add(hist, 1); __sync_fetch_and_add(&total, delta); // always in nsec __sync_fetch_and_add(&count, 1); -- 2.50.1