diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2021-10-27 11:13:52 -0700 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2021-10-27 11:13:53 -0700 |
| commit | f9d532fc5d6c2577687221869f6e7433eb177ec7 (patch) | |
| tree | 5ee181827d5064079aaa77ce0e3523a70daf1e86 /include/linux | |
| parent | 689624f037ce219d42312534eff4dc470b54dec4 (diff) | |
| parent | 61a0abaee2092eee69e44fe60336aa2f5b578938 (diff) | |
Merge branch 'bpf: use 32bit safe version of u64_stats'
Eric Dumazet says:
====================
From: Eric Dumazet <edumazet@google.com>
Two first patches fix bugs added in 5.1 and 5.5
Third patch replaces the u64 fields in struct bpf_prog_stats
with u64_stats_t ones to avoid possible sampling errors,
in case of load/store stearing.
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/filter.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index 47f80adbe744..9782e3245852 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -553,9 +553,9 @@ struct bpf_binary_header { }; struct bpf_prog_stats { - u64 cnt; - u64 nsecs; - u64 misses; + u64_stats_t cnt; + u64_stats_t nsecs; + u64_stats_t misses; struct u64_stats_sync syncp; } __aligned(2 * sizeof(u64)); @@ -612,13 +612,14 @@ static __always_inline u32 __bpf_prog_run(const struct bpf_prog *prog, if (static_branch_unlikely(&bpf_stats_enabled_key)) { struct bpf_prog_stats *stats; u64 start = sched_clock(); + unsigned long flags; ret = dfunc(ctx, prog->insnsi, prog->bpf_func); stats = this_cpu_ptr(prog->stats); - u64_stats_update_begin(&stats->syncp); - stats->cnt++; - stats->nsecs += sched_clock() - start; - u64_stats_update_end(&stats->syncp); + flags = u64_stats_update_begin_irqsave(&stats->syncp); + u64_stats_inc(&stats->cnt); + u64_stats_add(&stats->nsecs, sched_clock() - start); + u64_stats_update_end_irqrestore(&stats->syncp, flags); } else { ret = dfunc(ctx, prog->insnsi, prog->bpf_func); } |
