vmbus: add prefetch to ring buffer iterator
authorStephen Hemminger <stephen@networkplumber.org>
Sun, 25 Jun 2017 19:30:29 +0000 (12:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jul 2017 15:16:05 +0000 (17:16 +0200)
When iterating over incoming ring elements from the host, prefetch
the next descriptor so that it is cache hot.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/ring_buffer.c

index 741daa6..12eb8ca 100644 (file)
@@ -357,11 +357,16 @@ static u32 hv_pkt_iter_avail(const struct hv_ring_buffer_info *rbi)
 struct vmpacket_descriptor *hv_pkt_iter_first(struct vmbus_channel *channel)
 {
        struct hv_ring_buffer_info *rbi = &channel->inbound;
+       struct vmpacket_descriptor *desc;
 
        if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
                return NULL;
 
-       return hv_get_ring_buffer(rbi) + rbi->priv_read_index;
+       desc = hv_get_ring_buffer(rbi) + rbi->priv_read_index;
+       if (desc)
+               prefetch((char *)desc + (desc->len8 << 3));
+
+       return desc;
 }
 EXPORT_SYMBOL_GPL(hv_pkt_iter_first);