* [PATCH net-next] bonding: refine bond_fold_stats() wrap detection
@ 2017-03-29 17:45 Eric Dumazet
2017-03-30 19:41 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2017-03-29 17:45 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Andy Gospodarek, Jay Vosburgh, Veaceslav Falico
From: Eric Dumazet <edumazet@google.com>
Some device drivers reset their stats at down/up events, possibly
fooling bonding stats, since they operate with relative deltas.
It is nearly not possible to fix drivers, since some of them compute the
tx/rx counters based on per rx/tx queue stats, and the queues can be
reconfigured (ethtool -L) between the down/up sequence.
Lets avoid accumulating 'negative' values that render bonding stats
useless.
It is better to lose small deltas, assuming the bonding stats are
fetched at a reasonable frequency.
Fixes: 5f0c5f73e5ef ("bonding: make global bonding stats more reliable")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
drivers/net/bonding/bond_main.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6cea964ab70ad101a13cfd1a9fbabb51e95b2bbf..27359dab78a1d750c520c3a02e5914ea138b093b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3332,12 +3332,17 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res,
for (i = 0; i < sizeof(*_res) / sizeof(u64); i++) {
u64 nv = new[i];
u64 ov = old[i];
+ s64 delta = nv - ov;
/* detects if this particular field is 32bit only */
if (((nv | ov) >> 32) == 0)
- res[i] += (u32)nv - (u32)ov;
- else
- res[i] += nv - ov;
+ delta = (s64)(s32)((u32)nv - (u32)ov);
+
+ /* filter anomalies, some drivers reset their stats
+ * at down/up events.
+ */
+ if (delta > 0)
+ res[i] += delta;
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] bonding: refine bond_fold_stats() wrap detection
2017-03-29 17:45 [PATCH net-next] bonding: refine bond_fold_stats() wrap detection Eric Dumazet
@ 2017-03-30 19:41 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-03-30 19:41 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, gospo, j.vosburgh, vfalico
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 29 Mar 2017 10:45:44 -0700
> From: Eric Dumazet <edumazet@google.com>
>
> Some device drivers reset their stats at down/up events, possibly
> fooling bonding stats, since they operate with relative deltas.
>
> It is nearly not possible to fix drivers, since some of them compute the
> tx/rx counters based on per rx/tx queue stats, and the queues can be
> reconfigured (ethtool -L) between the down/up sequence.
>
> Lets avoid accumulating 'negative' values that render bonding stats
> useless.
>
> It is better to lose small deltas, assuming the bonding stats are
> fetched at a reasonable frequency.
>
> Fixes: 5f0c5f73e5ef ("bonding: make global bonding stats more reliable")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-30 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-29 17:45 [PATCH net-next] bonding: refine bond_fold_stats() wrap detection Eric Dumazet
2017-03-30 19:41 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).