From: Namhyung Kim Date: Thu, 27 Feb 2025 19:12:23 +0000 (-0800) Subject: perf ftrace: Use atomic inc to update histogram in BPF X-Git-Tag: block-6.15-20250403~13^2~63 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=e1cde2d5e92f6728a022754650b9cb1e38358d50;p=linux-block.git 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 --- 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);