Since day one __gnet_stats_copy_basic() always assigned the value to the
bstats argument overwriting the previous value.
Based on review there are five users of that function as of today:
- est_fetch_counters(), ___gnet_stats_copy_basic()
memsets() bstats to zero, single invocation.
- mq_dump(), mqprio_dump(), mqprio_dump_class_stats()
memsets() bstats to zero, multiple invocation but does not use the
function due to !qdisc_is_percpu_stats().
It will probably simplify in percpu stats case if the value would be
added and not just stored.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
net/core/gen_stats.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index e491b083b3485..e12e544a7ab0f 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -143,6 +143,8 @@ __gnet_stats_copy_basic(const seqcount_t *running,
struct gnet_stats_basic_packed *b)
{
unsigned int seq;
+ __u64 bytes = 0;
+ __u64 packets = 0;
if (cpu) {
__gnet_stats_copy_basic_cpu(bstats, cpu);@@ -151,9 +153,12 @@ __gnet_stats_copy_basic(const seqcount_t *running,
do {
if (running)
seq = read_seqcount_begin(running);
- bstats->bytes = b->bytes;
- bstats->packets = b->packets;
+ bytes = b->bytes;
+ packets = b->packets;
} while (running && read_seqcount_retry(running, seq));
+
+ bstats->bytes += bytes;
+ bstats->packets += packets;
}
EXPORT_SYMBOL(__gnet_stats_copy_basic);
--
2.33.0