diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2024-08-20 10:54:32 +0300 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2024-09-03 11:47:16 +0300 |
commit | 4a1d3acd6ea86075e77fcc1188c3fc372833ba73 (patch) | |
tree | 012b8e3b4860e90f0ee4f465dd6dddb06ba746af /net/ipv4 | |
parent | 1ef7f50ccc6e8e2b5de96ad1e304684a277a3055 (diff) | |
download | linux-4a1d3acd6ea86075e77fcc1188c3fc372833ba73.tar.xz |
netfilter: nft_counter: Use u64_stats_t for statistic.
The nft_counter uses two s64 counters for statistics. Those two are
protected by a seqcount to ensure that the 64bit variable is always
properly seen during updates even on 32bit architectures where the store
is performed by two writes. A side effect is that the two counter (bytes
and packet) are written and read together in the same window.
This can be replaced with u64_stats_t. write_seqcount_begin()/ end() is
replaced with u64_stats_update_begin()/ end() and behaves the same way
as with seqcount_t on 32bit architectures. Additionally there is a
preempt_disable on PREEMPT_RT to ensure that a reader does not preempt a
writer.
On 64bit architectures the macros are removed and the reads happen
without any retries. This also means that the reader can observe one
counter (bytes) from before the update and the other counter (packets)
but that is okay since there is no requirement to have both counter from
the same update window.
Convert the statistic to u64_stats_t. There is one optimisation:
nft_counter_do_init() and nft_counter_clone() allocate a new per-CPU
counter and assign a value to it. During this assignment preemption is
disabled which is not needed because the counter is not yet exposed to
the system so there can not be another writer or reader. Therefore
disabling preemption is omitted and raw_cpu_ptr() is used to obtain a
pointer to a counter for the assignment.
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/ipv4')
0 files changed, 0 insertions, 0 deletions