From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v2] hv_netvsc: Add per-cpu ethtool stats for netvsc Date: Wed, 13 Jun 2018 15:18:54 -0700 Message-ID: <20180613151854.25be8b33@xeon-e3> References: <20180613193608.444-1-yidren@linuxonhyperv.com> <20180613144813.708f26bf@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Yidong Ren , Stephen Hemminger , "netdev@vger.kernel.org" , Haiyang Zhang , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "David S. Miller" To: Yidong Ren Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Wed, 13 Jun 2018 22:03:34 +0000 Yidong Ren wrote: > > From: devel On Behalf > > Of Stephen Hemminger > > > +/* statistics per queue (rx/tx packets/bytes) */ #define > > > +NETVSC_PCPU_STATS_LEN (num_present_cpus() * > > ARRAY_SIZE(pcpu_stats)) > > > > Even though Hyper-V/Azure does not support hot plug cpu's it might be > > better to num_cpu_possible to avoid any possible future surprises. > > That will create a very long output (num_cpu_possible = 128 on my machine) for ethtool, > While doesn't provide additional info. > num_present_cpus() would cause problem only if someone removed cpu > between netvsc_get_sset_count() and netvsc_get_strings() and netvsc_get_ethtool_stats(). > > An alternative way could be: Check all stats, and only output if not zero. > This need to be done in two pass. First pass to get the correct count, second pass to print the number. > Is there an elegant way to do this? Ok, but there is a race between getting names and getting statistics. If a cpu was added/removed then statistics would not match.