Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755157AbdGVX6B convert rfc822-to-8bit (ORCPT ); Sat, 22 Jul 2017 19:58:01 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:32171 "EHLO lhrrgout.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751957AbdGVX57 (ORCPT ); Sat, 22 Jul 2017 19:57:59 -0400 From: Salil Mehta To: Stephen Hemminger CC: "davem@davemloft.net" , "Zhuangyuzeng (Yisen)" , huangdaode , "lipeng (Y)" , "mehta.salil.lnk@gmail.com" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Linuxarm Subject: RE: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC Thread-Topic: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC Thread-Index: AQHS5Jpli12+D/2e6EyB3JqMZRm9UqIsPCCAgDSG3PA= Date: Sat, 22 Jul 2017 23:57:46 +0000 Message-ID: References: <20170613231035.494020-1-salil.mehta@huawei.com> <20170613231035.494020-2-salil.mehta@huawei.com> <20170619084801.7920e30d@xeon-e3> In-Reply-To: <20170619084801.7920e30d@xeon-e3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.47.95.3] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5973E683.0008,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=169.254.1.170, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 871f0cdadc4ad60b5e9bd48570e16633 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1630 Lines: 52 Hi Stephen, > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Monday, June 19, 2017 4:48 PM > To: Salil Mehta > Cc: davem@davemloft.net; Zhuangyuzeng (Yisen); huangdaode; lipeng (Y); > mehta.salil.lnk@gmail.com; netdev@vger.kernel.org; linux- > kernel@vger.kernel.org; Linuxarm > Subject: Re: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 > Ethernet Driver for hip08 SoC > > On Wed, 14 Jun 2017 00:10:28 +0100 > Salil Mehta wrote: > > > +hns3_nic_get_stats64(struct net_device *ndev, struct > rtnl_link_stats64 *stats) > > +{ > > + struct hns3_nic_priv *priv = netdev_priv(ndev); > > + int queue_num = priv->ae_handle->kinfo.num_tqps; > > + u64 tx_bytes = 0; > > + u64 rx_bytes = 0; > > + u64 tx_pkts = 0; > > + u64 rx_pkts = 0; > > + int idx = 0; > unnecessary initialization > > > + > > + for (idx = 0; idx < queue_num; idx++) { > > + tx_bytes += priv->ring_data[idx].ring->stats.tx_bytes; > > + tx_pkts += priv->ring_data[idx].ring->stats.tx_pkts; > > + rx_bytes += > > + priv->ring_data[idx + queue_num].ring- > >stats.rx_bytes; > > + rx_pkts += priv->ring_data[idx + queue_num].ring- > >stats.rx_pkts; > > + } > > + > > Since rx_bytes and other statistics are 64 bit values. You need to use > something to ensure that updates to these values are atomic on 32 bit > platforms. The most common way to handle this is with the > u64_stats_sync > mechanism which is a nop on 64 bit architectures, and uses a seqcount > to do updates on 32 bit CPU's. Sure good point. This has changed in the V4 patch. Thanks for guiding. Salil > >