Re: [PATCH v2] hv_netvsc: Add per-cpu ethtool stats for netvsc

From: Stephen Hemminger
Date: Wed Jun 13 2018 - 18:19:01 EST

On Wed, 13 Jun 2018 22:03:34 +0000
Yidong Ren <Yidong.Ren@xxxxxxxxxxxxx> wrote:

> > From: devel <driverdev-devel-bounces@xxxxxxxxxxxxxxxxxxxxxx> 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.