summaryrefslogtreecommitdiffstats
path: root/net/core/gen_stats.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2021-10-16 10:49:02 +0200
committerDavid S. Miller <davem@davemloft.net>2021-10-18 13:54:40 +0200
commitfbf307c89eb08c51da4dd039f68c19afbcf5949d (patch)
tree8959dbffc0540940976953e50a2b3421b7f8fe5a /net/core/gen_stats.c
parentnet: make use of helper netif_is_bridge_master() (diff)
downloadlinux-fbf307c89eb08c51da4dd039f68c19afbcf5949d.tar.xz
linux-fbf307c89eb08c51da4dd039f68c19afbcf5949d.zip
gen_stats: Add instead Set the value in __gnet_stats_copy_basic().
__gnet_stats_copy_basic() always assigns the value to the bstats argument overwriting the previous value. The later added per-CPU version always accumulated the values in the returning gnet_stats_basic_packed argument. 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(). Add the values in __gnet_stats_copy_basic() instead overwriting. Rename the function to gnet_stats_add_basic() to make it more obvious. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/gen_stats.c')
-rw-r--r--net/core/gen_stats.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index e491b083b348..25d7c0989b83 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -114,9 +114,8 @@ gnet_stats_start_copy(struct sk_buff *skb, int type, spinlock_t *lock,
}
EXPORT_SYMBOL(gnet_stats_start_copy);
-static void
-__gnet_stats_copy_basic_cpu(struct gnet_stats_basic_packed *bstats,
- struct gnet_stats_basic_cpu __percpu *cpu)
+static void gnet_stats_add_basic_cpu(struct gnet_stats_basic_packed *bstats,
+ struct gnet_stats_basic_cpu __percpu *cpu)
{
int i;
@@ -136,26 +135,30 @@ __gnet_stats_copy_basic_cpu(struct gnet_stats_basic_packed *bstats,
}
}
-void
-__gnet_stats_copy_basic(const seqcount_t *running,
- struct gnet_stats_basic_packed *bstats,
- struct gnet_stats_basic_cpu __percpu *cpu,
- struct gnet_stats_basic_packed *b)
+void gnet_stats_add_basic(const seqcount_t *running,
+ struct gnet_stats_basic_packed *bstats,
+ struct gnet_stats_basic_cpu __percpu *cpu,
+ struct gnet_stats_basic_packed *b)
{
unsigned int seq;
+ u64 bytes = 0;
+ u64 packets = 0;
if (cpu) {
- __gnet_stats_copy_basic_cpu(bstats, cpu);
+ gnet_stats_add_basic_cpu(bstats, cpu);
return;
}
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);
+EXPORT_SYMBOL(gnet_stats_add_basic);
static int
___gnet_stats_copy_basic(const seqcount_t *running,
@@ -166,7 +169,7 @@ ___gnet_stats_copy_basic(const seqcount_t *running,
{
struct gnet_stats_basic_packed bstats = {0};
- __gnet_stats_copy_basic(running, &bstats, cpu, b);
+ gnet_stats_add_basic(running, &bstats, cpu, b);
if (d->compat_tc_stats && type == TCA_STATS_BASIC) {
d->tc_stats.bytes = bstats.bytes;