diff options
author | Ahmed S. Darwish <a.darwish@linutronix.de> | 2021-10-16 10:49:08 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-10-18 12:54:41 +0100 |
commit | f56940daa5a74fb20b5f5487535549949f2d8d0c (patch) | |
tree | f50ec19fb2903f670b8f6ed33c89be3bb8694503 /net/core/gen_stats.c | |
parent | 67c9e6270f3013e4d86ec57c4e7f27459f2a0652 (diff) | |
download | linux-f56940daa5a74fb20b5f5487535549949f2d8d0c.tar.gz linux-f56940daa5a74fb20b5f5487535549949f2d8d0c.tar.bz2 linux-f56940daa5a74fb20b5f5487535549949f2d8d0c.zip |
net: sched: Use _bstats_update/set() instead of raw writes
The Qdisc::running sequence counter, used to protect Qdisc::bstats reads
from parallel writes, is in the process of being removed. Qdisc::bstats
read/writes will synchronize using an internal u64_stats sync point
instead.
Modify all bstats writes to use _bstats_update(). This ensures that
the internal u64_stats sync point is always acquired and released as
appropriate.
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
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.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c index f2e12fe7112b..69576972a25f 100644 --- a/net/core/gen_stats.c +++ b/net/core/gen_stats.c @@ -126,6 +126,7 @@ EXPORT_SYMBOL(gnet_stats_basic_packed_init); static void gnet_stats_add_basic_cpu(struct gnet_stats_basic_packed *bstats, struct gnet_stats_basic_cpu __percpu *cpu) { + u64 t_bytes = 0, t_packets = 0; int i; for_each_possible_cpu(i) { @@ -139,9 +140,10 @@ static void gnet_stats_add_basic_cpu(struct gnet_stats_basic_packed *bstats, packets = bcpu->bstats.packets; } while (u64_stats_fetch_retry_irq(&bcpu->syncp, start)); - bstats->bytes += bytes; - bstats->packets += packets; + t_bytes += bytes; + t_packets += packets; } + _bstats_update(bstats, t_bytes, t_packets); } void gnet_stats_add_basic(const seqcount_t *running, @@ -164,8 +166,7 @@ void gnet_stats_add_basic(const seqcount_t *running, packets = b->packets; } while (running && read_seqcount_retry(running, seq)); - bstats->bytes += bytes; - bstats->packets += packets; + _bstats_update(bstats, bytes, packets); } EXPORT_SYMBOL(gnet_stats_add_basic); |