Skip to content

Commit

Permalink
vmbus: add prefetch to ring buffer iterator
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Hemminger authored and Greg Kroah-Hartman committed Jul 17, 2017
1 parent 03bad71 commit 15e1674
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/hv/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 15e1674

Please sign in to comment.