diff mbox series

[azure:x,v3,1/4] Revert "UBUNTU: SAUCE: vmbus: fix performance regression"

Message ID 1520437128-18010-2-git-send-email-marcelo.cerri@canonical.com
State New
Headers show
Series [azure:x,v3,1/4] Revert "UBUNTU: SAUCE: vmbus: fix performance regression" | expand

Commit Message

Marcelo Henrique Cerri March 7, 2018, 3:38 p.m. UTC
BugLink: http://bugs.launchpad.net/bugs/1748662

This reverts commit 9ea3e22cb96dcca0d12213c12b503253ceb0e798.

Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 drivers/hv/ring_buffer.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index dbc76554f9f9..8214042757cb 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -407,10 +407,10 @@  EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
 void hv_pkt_iter_close(struct vmbus_channel *channel)
 {
 	struct hv_ring_buffer_info *rbi = &channel->inbound;
-	u32 cached_write_sz, cur_write_sz, pending_sz;
+	u32 orig_write_sz;
 
 	/* Available space before read_index update */
-	cached_write_sz = hv_get_bytes_to_write(rbi);
+	orig_write_sz = hv_get_bytes_to_write(rbi);
 
 	/*
 	 * Make sure all reads are done before we update the read index since
@@ -422,6 +422,10 @@  void hv_pkt_iter_close(struct vmbus_channel *channel)
 	/* Update the position where ring buffer has been read from */
 	rbi->ring_buffer->read_index = rbi->priv_read_index;
 
+	/* If more data is available then no need to signal */
+	if (hv_get_bytes_to_read(rbi))
+		return;
+
 	/*
 	 * If the reading of the pend_sz were to be reordered and read
 	 * before we commit the new read index.
@@ -431,22 +435,18 @@  void hv_pkt_iter_close(struct vmbus_channel *channel)
 	virt_wmb();
 
 	if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) {
-		pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
-
-		/* If the other end is not blocked on write don't bother. */
-		if (pending_sz == 0)
-			return;
-
-		/* If pending write will not fit, don't give false hope. */
-		cur_write_sz = hv_get_bytes_to_write(rbi);
-		if (cur_write_sz < pending_sz)
-			return;
+		u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
 
 		/*
 		 * If there was space before we began iteration, then
-		 * host was not blocked.
+		 * host was not blocked. Also handles the case where
+		 * pending_sz is zero because host has nothing pending.
 		 */
-		if (cached_write_sz >= pending_sz)
+		if (orig_write_sz > pending_sz)
+			return;
+
+		/* If pending write will not fit, don't give false hope. */
+		if (hv_get_bytes_to_write(rbi) < pending_sz)
 			return;
 	}