[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4c853799-44e0-ff33-3555-41982d601ebb@gmail.com>
Date: Wed, 13 Jun 2018 13:57:33 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Yidong Ren <yidren@...uxonhyperv.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
"David S. Miller" <davem@...emloft.net>,
devel@...uxdriverproject.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Yidong Ren <yidren@...rosoft.com>
Subject: Re: [PATCH v2] hv_netvsc: Add per-cpu ethtool stats for netvsc
On 06/13/2018 12:36 PM, Yidong Ren wrote:
> From: Yidong Ren <yidren@...rosoft.com>
>
> This patch implements following ethtool stats fields for netvsc:
> cpu<n>_tx/rx_packets/bytes
> cpu<n>_vf_tx/rx_packets/bytes
...
>
> + pcpu_sum = alloc_percpu(struct netvsc_ethtool_pcpu_stats);
> + netvsc_get_pcpu_stats(dev, pcpu_sum);
> + for_each_present_cpu(cpu) {
> + struct netvsc_ethtool_pcpu_stats *this_sum =
> + per_cpu_ptr(pcpu_sum, cpu);
> + for (j = 0; j < ARRAY_SIZE(pcpu_stats); j++)
> + data[i++] = *(u64 *)((void *)this_sum
> + + pcpu_stats[j].offset);
> + }
> + free_percpu(pcpu_sum);
>
Using alloc_percpu() / free_percpu() for a short section of code makes no sense.
You actually want to allocate memory local to this cpu, possibly in one chunk,
not spread all over the places.
kvmalloc(nr_cpu_ids * sizeof(struct netvsc_ethtool_pcpu_stats)) should be really better,
since it would most of the time be satisfied by a single kmalloc()
Powered by blists - more mailing lists