Skip to content

Commit

Permalink
tools/syscount: Use lock_xadd to guarantee atomicity of addition oper…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
xingfeng2510 authored and yonghong-song committed Aug 10, 2022
1 parent dda13ed commit 408fb40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/syscount.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ def handle_errno(errstr):
val = data.lookup_or_try_init(&key, &zero);
if (val) {
val->count++;
val->total_ns += bpf_ktime_get_ns() - *start_ns;
lock_xadd(&val->count, 1);
lock_xadd(&val->total_ns, bpf_ktime_get_ns() - *start_ns);
}
#else
u64 *val, zero = 0;
val = data.lookup_or_try_init(&key, &zero);
if (val) {
++(*val);
lock_xadd(val, 1);
}
#endif
return 0;
Expand Down

0 comments on commit 408fb40

Please sign in to comment.