Skip to content

Commit

Permalink
libbpf-tools/syscount: use atomic_add for counter
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <[email protected]>
  • Loading branch information
fuweid authored and yonghong-song committed Sep 8, 2021
1 parent 6677321 commit 65d7839
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libbpf-tools/syscount.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ int sys_exit(struct trace_event_raw_sys_exit *args)
key = (count_by_process) ? pid : args->id;
val = bpf_map_lookup_or_try_init(&data, &key, &zero);
if (val) {
val->count++;
__sync_fetch_and_add(&val->count, 1);
if (count_by_process)
save_proc_name(val);
if (measure_latency)
val->total_ns += bpf_ktime_get_ns() - *start_ts;
__sync_fetch_and_add(&val->total_ns, bpf_ktime_get_ns() - *start_ts);
}
return 0;
}
Expand Down

0 comments on commit 65d7839

Please sign in to comment.