From: Stephen Hemminger <stephen@networkplumber.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Stephen Hemminger <sthemmin@microsoft.com>
Subject: [PATCH net-next 09/15] netvsc: optimize netvsc_send_pkt
Date: Wed, 3 May 2017 16:01:11 -0700 [thread overview]
Message-ID: <20170503230117.20070-10-sthemmin@microsoft.com> (raw)
In-Reply-To: <20170503230117.20070-1-sthemmin@microsoft.com>
Hand optimize netvsc_send_pkt by adding likely/unlikely.
Also don't print pointer in warning message, instead dump info.
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/net/hyperv/netvsc.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 59ca5fd6797d..d9bd1a2db4db 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -751,9 +751,9 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
return msg_size;
}
-static inline int netvsc_send_pkt(
+static int netvsc_send_pkt(
struct hv_device *device,
- struct hv_netvsc_packet *packet,
+ const struct hv_netvsc_packet *packet,
struct netvsc_device *net_device,
struct hv_page_buffer **pb,
struct sk_buff *skb)
@@ -766,7 +766,6 @@ static inline int netvsc_send_pkt(
struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx);
u64 req_id;
int ret;
- struct hv_page_buffer *pgbuf;
u32 ring_avail = hv_ringbuf_avail_percent(out_channel);
nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
@@ -788,10 +787,12 @@ static inline int netvsc_send_pkt(
req_id = (ulong)skb;
- if (out_channel->rescind)
+ if (unlikely(out_channel->rescind))
return -ENODEV;
if (packet->page_buf_cnt) {
+ struct hv_page_buffer *pgbuf;
+
pgbuf = packet->cp_partial ? (*pb) +
packet->rmsg_pgcnt : (*pb);
ret = vmbus_sendpacket_pagebuffer_ctl(out_channel,
@@ -809,20 +810,23 @@ static inline int netvsc_send_pkt(
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
}
- if (ret == 0) {
- atomic_inc_return(&nvchan->queue_sends);
+ if (likely(ret == 0)) {
+ atomic_inc(&nvchan->queue_sends);
if (ring_avail < RING_AVAIL_PERCENT_LOWATER)
netif_tx_stop_queue(txq);
- } else if (ret == -EAGAIN) {
+ } else if (likely(ret == -EAGAIN)) {
netif_tx_stop_queue(txq);
if (atomic_read(&nvchan->queue_sends) < 1) {
netif_tx_wake_queue(txq);
ret = -ENOSPC;
}
} else {
- netdev_err(ndev, "Unable to send packet %p ret %d\n",
- packet, ret);
+ if (net_ratelimit())
+ netdev_warn(ndev,
+ "Unable to send packet qid %u index %d len %u (%d)\n",
+ packet->q_idx, packet->send_buf_index,
+ packet->total_data_buflen, ret);
}
return ret;
--
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 ` Stephen Hemminger [this message]
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 ` [PATCH 15/15] netvsc: use vzalloc_node for receive completion data Stephen Hemminger
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-10-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).