summaryrefslogtreecommitdiff
path: root/kernel/nsproxy.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2024-08-20 09:54:32 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-28 21:59:57 +0100
commitfa81cb19f5b708921d4c2ca7bd5ef38f80f8d2c9 (patch)
treefc6a4b6fac5c8df028e3054b670108ba3d469bb6 /kernel/nsproxy.c
parent35afffaddbe8d310dc61659da0b1a337b0d0addc (diff)
downloadlinux-fa81cb19f5b708921d4c2ca7bd5ef38f80f8d2c9.tar.gz
linux-fa81cb19f5b708921d4c2ca7bd5ef38f80f8d2c9.tar.bz2
linux-fa81cb19f5b708921d4c2ca7bd5ef38f80f8d2c9.zip
netfilter: nft_counter: Use u64_stats_t for statistic.
commit 4a1d3acd6ea86075e77fcc1188c3fc372833ba73 upstream. 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> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/nsproxy.c')
0 files changed, 0 insertions, 0 deletions