From: Stephen Hemminger <stephen@networkplumber.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Stephen Hemminger <sthemmin@microsoft.com>
Subject: [PATCH 15/15] netvsc: use vzalloc_node for receive completion data
Date: Wed, 3 May 2017 16:01:17 -0700 [thread overview]
Message-ID: <20170503230117.20070-16-sthemmin@microsoft.com> (raw)
In-Reply-To: <20170503230117.20070-1-sthemmin@microsoft.com>
Put the receive completion ring on the NUMA node of the CPU
assigned to the channel.
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/net/hyperv/hyperv_net.h | 3 +++
drivers/net/hyperv/netvsc.c | 30 +++++++++++++++++++++++-------
drivers/net/hyperv/rndis_filter.c | 8 ++++----
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index a4417100a040..779c77a1638b 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -668,6 +668,9 @@ static inline bool recv_complete_ring_empty(const struct multi_recv_comp *mrc)
return mrc->read == mrc->write;
}
+int netvsc_recv_comp_alloc(const struct vmbus_channel *chan,
+ struct multi_recv_comp *mrc, u32 recv_slots);
+
struct netvsc_stats {
u64 packets;
u64 bytes;
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2938f1a2b765..ee42aa56460c 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -61,19 +61,33 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf)
VM_PKT_DATA_INBAND, 0);
}
-static struct netvsc_device *alloc_net_device(u32 recvslot_max)
+int netvsc_recv_comp_alloc(const struct vmbus_channel *channel,
+ struct multi_recv_comp *mrc, u32 recv_slots)
+{
+ int node = cpu_to_node(channel->target_cpu);
+ size_t size = recv_slots * sizeof(struct recv_comp_data);
+
+ mrc->ring = vzalloc_node(size, node);
+ if (!mrc->ring)
+ mrc->ring = vzalloc(size);
+ if (!mrc->ring)
+ return -ENOMEM;
+
+ mrc->size = recv_slots;
+ return 0;
+}
+
+static struct netvsc_device *alloc_net_device(const struct vmbus_channel *chan,
+ u32 recvslot_max)
{
struct netvsc_device *net_device;
- struct multi_recv_comp *mrc;
net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
if (!net_device)
return NULL;
- mrc = &net_device->chan_table[0].mrc;
- mrc->size = recvslot_max;
- mrc->ring = vzalloc(recvslot_max * sizeof(struct recv_comp_data));
- if (!mrc->ring) {
+ if (netvsc_recv_comp_alloc(chan, &net_device->chan_table[0].mrc,
+ recvslot_max) != 0) {
kfree(net_device);
return NULL;
}
@@ -1246,7 +1260,9 @@ int netvsc_device_add(struct hv_device *device,
struct net_device *ndev = hv_get_drvdata(device);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
- net_device = alloc_net_device(device_info->recv_buf_size / ETH_DATA_LEN + 1);
+ net_device = alloc_net_device(device->channel,
+ device_info->recv_buf_size
+ / ETH_DATA_LEN + 1);
if (!net_device)
return -ENOMEM;
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 1b8ce9bc0ce7..da4992b26397 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -996,10 +996,10 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
return;
nvchan = nvscdev->chan_table + chn_index;
- nvchan->mrc.size = nvscdev->recv_buf_size / ETH_DATA_LEN + 1;
- nvchan->mrc.ring = vzalloc(nvchan->mrc.size
- * sizeof(struct recv_comp_data));
- if (!nvchan->mrc.ring)
+ ret = netvsc_recv_comp_alloc(new_sc,
+ &nvchan->mrc,
+ nvscdev->recv_buf_size / ETH_DATA_LEN + 1);
+ if (ret)
return;
/* Because the device uses NAPI, all the interrupt batching and
--
2.11.0
next prev parent reply other threads:[~2017-05-03 23:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 23:01 [PATCH net-next 00/15] netvsc: misc patches Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 01/15] vmbus: simplify hv_ringbuffer_read Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 02/15] vmbus: fix unnecessary signal events as result of NAPI Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 03/15] netvsc: make sure napi enabled before vmbus_open Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 04/15] netvsc: don't reacquire rtnl on device removal Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 05/15] netvsc: optimize avail percent calculation Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 06/15] netvsc: prefetch the first incoming ring element Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 07/15] netvsc: convert ring_size to unsigned Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 08/15] netvsc: allow overriding send/recv buffer size Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 09/15] netvsc: optimize netvsc_send_pkt Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 10/15] netvsc: replace modulus with mask for alignment Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 11/15] netvsc: reduce unnecessary memset Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 12/15] netvsc: size receive completion ring based on receive area Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 13/15] netvsc: convert open count from atomic to refcount Stephen Hemminger
2017-05-03 23:01 ` [PATCH net-next 14/15] netvsc: optimize receive completions Stephen Hemminger
2017-05-03 23:01 ` Stephen Hemminger [this message]
2017-05-03 23:35 ` [PATCH net-next 00/15] netvsc: misc patches David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170503230117.20070-16-sthemmin@microsoft.com \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=sthemmin@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).