Received: by 10.213.65.68 with SMTP id h4csp4643imn; Mon, 19 Mar 2018 17:33:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELuGq6gUhvT3oW+bf+0IGscoJg7dYSSthLjKUVoydONkppr4mWfVR4+fSxwvlYo5dwr/Vz6x X-Received: by 10.99.175.8 with SMTP id w8mr10331992pge.390.1521506017432; Mon, 19 Mar 2018 17:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521506017; cv=none; d=google.com; s=arc-20160816; b=j+1ETfxAiR+cVwWa8Pf/9W8UbG6jbRtEKGbOeaPEQJqjeVd9Mlyr+yRf+4cUml6Xme AZQBiplCZTZIV0ph/eSPXNVb54f/pKMDHiN6UhHr4fmTBwFPXWO96QLAMKRBhlZlzoTR xiUY9+tsWOgoJEinK9uMaQYrHyK6c/7MB4eL3sE9Dv4qYM/g2mC5AhP2FXYu7z99Cz0c b9/M24jIIBumYzzI3+21vcXO3K+jK91kkg2AmeOYHOic9d3Ih4lXFJCfX22EnYCwlEoj xT+L09q+Ec7+uqVJXJ/3s0HR0AGztgaTxrWRaMYxOURbkwKx41TGUnlBWh8nH7HVylz3 k19A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=z3ocbS9Kvlmoo1vbNEVeCpcSZ3WVCkF2pzkyG3IaFT0=; b=lKvp+VSEXiqLm2kc92VvP56OGZ2U0GHwgPvKyFnbK0l9IL05KOX01mn8srB1PVucC5 UUafX2kd/OOKexD4VyGHgGpeikEuV8k8+m5e4O1IHUXL5T3zwlSKFuSAYQUDDVZAta88 eVFueDzWOcnISnB7lleWE2dlRNjBWFHb+RwX9lnTyoKI8l8LDVZLgvT4rTCpIC6+MzXM 8zVa6QORz7NVZCoiMZXBDUyztoFkn+FBJIXohww2betmLDd6g8zEAKqC3ihyhidXLZHq pIcFdqNBBehXlBLkPTlGoSb+FFvx61jOjSHXP8O9awoEAljgUalJPvOxKjsAXs7JzE0u 7Cmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si336537pfk.42.2018.03.19.17.33.22; Mon, 19 Mar 2018 17:33:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030750AbeCSSPL (ORCPT + 99 others); Mon, 19 Mar 2018 14:15:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44434 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030693AbeCSSPB (ORCPT ); Mon, 19 Mar 2018 14:15:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C5741F88; Mon, 19 Mar 2018 18:15:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 040/134] bonding: refine bond_fold_stats() wrap detection Date: Mon, 19 Mar 2018 19:05:23 +0100 Message-Id: <20180319171855.117165172@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 142c6594acbcc32391af9c15f8cd65c6c177698f ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/bonding/bond_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3276,12 +3276,17 @@ static void bond_fold_stats(struct rtnl_ 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; } }