Skip to content

Commit 1d15f6d

Browse files
committed
ice: fix stats being updated by way too large values
jira NONE_AUTOMATION Rebuild_History Non-Buildable kernel-4.18.0-553.54.1.el8_10 commit-author Przemek Kitszel <[email protected]> commit 257310e Simplify stats accumulation logic to fix the case where we don't take previous stat value into account, we should always respect it. Main netdev stats of our PF (Tx/Rx packets/bytes) were reported orders of magnitude too big during OpenStack reconfiguration events, possibly other reconfiguration cases too. The regression was reported to be between 6.1 and 6.2, so I was almost certain that on of the two "preserve stats over reset" commits were the culprit. While reading the code, it was found that in some cases we will increase the stats by arbitrarily large number (thanks to ignoring "-prev" part of condition, after zeroing it). Note that this fixes also the case where we were around limits of u64, but that was not the regression reported. Full disclosure: I remember suggesting this particular piece of code to Ben a few years ago, so blame on me. Fixes: 2fd5e43 ("ice: Accumulate HW and Netdev statistics over reset") Reported-by: Nebojsa Stevanovic <[email protected]> Link: https://lore.kernel.org/intel-wired-lan/VI1PR02MB439744DEDAA7B59B9A2833FE912EA@VI1PR02MB4397.eurprd02.prod.outlook.com Reported-by: Christian Rohmann <[email protected]> Link: https://lore.kernel.org/intel-wired-lan/[email protected] Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]> (cherry picked from commit 257310e) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 7cca5c1 commit 1d15f6d

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6767,6 +6767,7 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi)
67676767
{
67686768
struct rtnl_link_stats64 *net_stats, *stats_prev;
67696769
struct rtnl_link_stats64 *vsi_stats;
6770+
struct ice_pf *pf = vsi->back;
67706771
u64 pkts, bytes;
67716772
int i;
67726773

@@ -6812,21 +6813,18 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi)
68126813
net_stats = &vsi->net_stats;
68136814
stats_prev = &vsi->net_stats_prev;
68146815

6815-
/* clear prev counters after reset */
6816-
if (vsi_stats->tx_packets < stats_prev->tx_packets ||
6817-
vsi_stats->rx_packets < stats_prev->rx_packets) {
6818-
stats_prev->tx_packets = 0;
6819-
stats_prev->tx_bytes = 0;
6820-
stats_prev->rx_packets = 0;
6821-
stats_prev->rx_bytes = 0;
6816+
/* Update netdev counters, but keep in mind that values could start at
6817+
* random value after PF reset. And as we increase the reported stat by
6818+
* diff of Prev-Cur, we need to be sure that Prev is valid. If it's not,
6819+
* let's skip this round.
6820+
*/
6821+
if (likely(pf->stat_prev_loaded)) {
6822+
net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets;
6823+
net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes;
6824+
net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets;
6825+
net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes;
68226826
}
68236827

6824-
/* update netdev counters */
6825-
net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets;
6826-
net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes;
6827-
net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets;
6828-
net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes;
6829-
68306828
stats_prev->tx_packets = vsi_stats->tx_packets;
68316829
stats_prev->tx_bytes = vsi_stats->tx_bytes;
68326830
stats_prev->rx_packets = vsi_stats->rx_packets;

0 commit comments

Comments
 (0)