public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Retry infinitely for hypercall
@ 2017-01-04 22:39 Long Li
  2017-01-04 20:50 ` Greg KH
  2017-01-04 21:47 ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Long Li @ 2017-01-04 22:39 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang; +Cc: devel, linux-kernel, Long Li

From: Long Li <longli@microsoft.com>

Hyper-v host guarantees that a hypercall will succeed. Retry infinitely to avoid returning transient failures to upper layer.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/hv/connection.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 6ce8b87..4bcb099 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -439,7 +439,6 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 {
 	union hv_connection_id conn_id;
 	int ret = 0;
-	int retries = 0;
 	u32 usec = 1;
 
 	conn_id.asu32 = 0;
@@ -447,10 +446,10 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 
 	/*
 	 * hv_post_message() can have transient failures because of
-	 * insufficient resources. Retry the operation a couple of
-	 * times before giving up.
+	 * insufficient resources. We retry infinitely on these failures
+	 * because host guarantees hypercall will eventually succeed.
 	 */
-	while (retries < 20) {
+	while (1) {
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
 		switch (ret) {
@@ -459,11 +458,11 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 			 * We could get this if we send messages too
 			 * frequently.
 			 */
-			ret = -EAGAIN;
-			break;
 		case HV_STATUS_INSUFFICIENT_MEMORY:
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
-			ret = -ENOMEM;
+			/*
+			 * Temporary failure out of resources
+			 */
 			break;
 		case HV_STATUS_SUCCESS:
 			return ret;
@@ -472,12 +471,12 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 			return -EINVAL;
 		}
 
-		retries++;
 		udelay(usec);
 		if (usec < 2048)
 			usec *= 2;
 	}
-	return ret;
+	/* Impossible to get here */
+	BUG_ON(1);
 }
 
 /*
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-04 22:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-04 22:39 [PATCH] Retry infinitely for hypercall Long Li
2017-01-04 20:50 ` Greg KH
2017-01-04 22:03   ` Long Li
2017-01-04 21:47 ` Dan Carpenter
2017-01-04 22:05   ` Long Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox