Skip to contentSkip to conversation

hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

PATCH Superseded Dexuan Cui 4 participants 8 messages Jan 29, 2015 – Feb 1, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH 2/3 hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe hv_utils" in a Linux guest.

Without the patch, the driver can occasionally fail to load.

CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
arch/x86/include/uapi/asm/hyperv.h +1 -0
index 90c458e..b9daffb 100644
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +9 -0
index c4acd1c..8bd05f3 100644
@@ -440,6 +440,15 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently or the host is under low resource
+			 * conditions: let's wait 1 more second before
+			 * retrying the hypercall.
+			 */
+			msleep(1000);
+			break;
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;
 		case -ENOMEM:
Signature · 1 line
1.9.1
#1 lore raw
Quoted 18 lines · Dexuan Cui

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe hv_utils" in a Linux guest.

Without the patch, the driver can occasionally fail to load.

CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
arch/x86/include/uapi/asm/hyperv.h +0 -0
index 90c458e..b9daffb 100644

arch/x86/include/uapi/asm/hyperv.h line 229

Quoted 5 lines
arch/x86/include/uapi/asm/hyperv.h +1 -0
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19

The gap beween 4 and 18 tells me there are other codes here ;-) Are they all 'permanent failures'?

Quoted 9 lines
arch/x86/include/uapi/asm/hyperv.h +0 -0
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +0 -0
index c4acd1c..8bd05f3 100644
@@ -440,6 +440,15 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 451

Quoted 10 lines
drivers/hv/connection.c +9 -0
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently or the host is under low resource
+			 * conditions: let's wait 1 more second before
+			 * retrying the hypercall.
+			 */
+			msleep(1000);
+			break;

In case it is our last try (No. 10) we will return '18' from the function. I suggest we set ret = -ENOMEM here as well.

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 453

Quoted 2 lines
drivers/hv/connection.c +0 -0
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;

Or should we treat these two equally? There is a smaller (100ms) sleep between tries already, we can consider changing it instead.

Quoted 1 line
drivers/hv/connection.c +0 -0
 		case -ENOMEM:
Signature · 1 line
  Vitaly
author maintainer
#2 lore raw
Quoted 27 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, January 29, 2015 21:31 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 6 lines · Dexuan Cui

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe hv_utils" in a Linux guest.

Without the patch, the driver can occasionally fail to load.

Review

Quoted 8 lines
CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
(quoted diff) +0 -0

b/arch/x86/include/uapi/asm/hyperv.h

Quoted 12 lines

arch/x86/include/uapi/asm/hyperv.h line 229

Quoted 9 lines

index 90c458e..b9daffb 100644

arch/x86/include/uapi/asm/hyperv.h +1 -0
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19

The gap beween 4 and 18 tells me there are other codes here ;-) Are they all 'permanent failures'?

It looks we only need to care about these error codes here.

BTW, you can get all the hypercall error codes in the top level functional spec:
http://blogs.msdn.com/b/virtual_pc_guy/archive/2014/02/17/updated-hypervisor-top-level-functional-specification.aspx
For this hypercall (0x005c), see "14.9.7 HvPostMessage".

Quoted 9 lines
Quoted 9 lines
arch/x86/include/uapi/asm/hyperv.h +0 -0
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +0 -0
index c4acd1c..8bd05f3 100644
@@ -440,6 +440,15 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
Quoted 13 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 451

Quoted 10 lines
drivers/hv/connection.c +9 -0
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently or the host is under low resource
+			 * conditions: let's wait 1 more second before
+			 * retrying the hypercall.
+			 */
+			msleep(1000);
+			break;

In case it is our last try (No. 10) we will return '18' from the function. I suggest we set ret = -ENOMEM here as well.

Thanks for the suggestion!

I think it would be better to add this to the case HV_STATUS_INVALID_CONNECTION_ID:
ret = -EAGAIN;
?

Quoted 10 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 453

Quoted 2 lines
drivers/hv/connection.c +0 -0
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;

Or should we treat these two equally? There is a smaller (100ms) sleep between tries already, we can consider changing it instead.

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 454

Quoted 1 line
drivers/hv/connection.c +0 -0
 		case -ENOMEM:

--
Vitaly

In my experiments, in the HV_STATUS_INVALID_CONNECTION_ID case, waiting 100ms is not enough sometimes, so I'd like to wait more time. I agree with you both cases can wait 1000ms. I'll update my patch.

BTW, the " case -ENOMEM:" is not reachable(the hypervisor itself doesn't return -ENOMEM), I think. I can remove it.

Thanks,
-- Dexuan

#3 lore raw
Quoted 39 lines · Dexuan Cui
Quoted 27 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, January 29, 2015 21:31 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 6 lines · Dexuan Cui

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe hv_utils" in a Linux guest.

Without the patch, the driver can occasionally fail to load.

Review

Quoted 8 lines
CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
(quoted diff) +0 -0

b/arch/x86/include/uapi/asm/hyperv.h

Quoted 12 lines

arch/x86/include/uapi/asm/hyperv.h line 229

Quoted 9 lines

index 90c458e..b9daffb 100644

arch/x86/include/uapi/asm/hyperv.h +1 -0
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19

The gap beween 4 and 18 tells me there are other codes here ;-) Are they all 'permanent failures'?

Quoted 5 lines

It looks we only need to care about these error codes here.

BTW, you can get all the hypercall error codes in the top level functional spec:
http://blogs.msdn.com/b/virtual_pc_guy/archive/2014/02/17/updated-hypervisor-top-level-functional-specification.aspx
For this hypercall (0x005c), see "14.9.7 HvPostMessage".

Thanks, interesting!

Btw, HV_STATUS_INSUFFICIENT_MEMORY looks suspicious, looks like we can hit it as well...

I suggest we split all failures here in 2 classes:
1) permanent
2) worth retrying

and treat them accordingly (no big changes, just maybe group them within hv_post_message() together as it is the only place where these codes are being used).

Quoted 23 lines
Quoted 10 lines
Quoted 10 lines
arch/x86/include/uapi/asm/hyperv.h +0 -0
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +0 -0
index c4acd1c..8bd05f3 100644
@@ -440,6 +440,15 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
Quoted 13 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 451

Quoted 10 lines
drivers/hv/connection.c +9 -0
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently or the host is under low resource
+			 * conditions: let's wait 1 more second before
+			 * retrying the hypercall.
+			 */
+			msleep(1000);
+			break;

In case it is our last try (No. 10) we will return '18' from the function. I suggest we set ret = -ENOMEM here as well.

Quoted 6 lines

Thanks for the suggestion!

I think it would be better to add this to the case HV_STATUS_INVALID_CONNECTION_ID:
ret = -EAGAIN;
?

Yes, like fallthrough

Quoted 9 lines
Quoted 9 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 453

Quoted 3 lines
drivers/hv/connection.c +0 -0
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;

Or should we treat these two equally? There is a smaller (100ms) sleep between tries already, we can consider changing it instead.

Quoted 1 line
drivers/hv/connection.c +0 -0
 		case -ENOMEM:
Quoted 8 lines
Quoted 2 lines

--
Vitaly

In my experiments, in the HV_STATUS_INVALID_CONNECTION_ID case, waiting 100ms is not enough sometimes, so I'd like to wait more time. I agree with you both cases can wait 1000ms. I'll update my patch.

BTW, the " case -ENOMEM:" is not reachable(the hypervisor itself doesn't return -ENOMEM), I think. I can remove it.

hv_post_message() can return -EMSGSIZE or do_hypercall() return value (which becomes u16 in hv_post_message()). So yes, I agree, -ENOMEM is not possible.

Quoted 3 lines

Thanks,
-- Dexuan

Signature · 1 line
  Vitaly
author maintainer
#4 lore raw
Quoted 64 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Saturday, January 31, 2015 1:29 AM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 10 lines · Dexuan Cui
Quoted 10 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, January 29, 2015 21:31 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines · Dexuan Cui

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe

hv_utils"

Quoted 25 lines
Quoted 13 lines
Quoted 4 lines

in a Linux guest.

Without the patch, the driver can occasionally fail to load.

Review

Quoted 8 lines
CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
(quoted diff) +0 -0

b/arch/x86/include/uapi/asm/hyperv.h

Quoted 12 lines

arch/x86/include/uapi/asm/hyperv.h line 229

Quoted 9 lines

index 90c458e..b9daffb 100644

arch/x86/include/uapi/asm/hyperv.h +1 -0
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19

The gap beween 4 and 18 tells me there are other codes here ;-) Are they all 'permanent failures'?

Quoted 4 lines

It looks we only need to care about these error codes here.

BTW, you can get all the hypercall error codes in the top level functional spec:
http://blogs.msdn.com/b/virtual_pc_guy/archive/2014/02/17/updated-

hypervisor-top-level-functional-specification.aspx

Quoted 1 line

For this hypercall (0x005c), see "14.9.7 HvPostMessage".

Thanks, interesting!

Btw, HV_STATUS_INSUFFICIENT_MEMORY looks suspicious, looks like we can hit it as well...

Quoted 7 lines

I suggest we split all failures here in 2 classes:
1) permanent
2) worth retrying

and treat them accordingly (no big changes, just maybe group them within hv_post_message() together as it is the only place where these codes are being used).

Thanks for the suggestion, Vitaly!
I'll send out v2.

-- Dexuan

Quoted 60 lines
Quoted 23 lines
Quoted 10 lines
Quoted 10 lines
arch/x86/include/uapi/asm/hyperv.h +0 -0
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +0 -0
index c4acd1c..8bd05f3 100644
@@ -440,6 +440,15 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
Quoted 13 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 451

Quoted 10 lines
drivers/hv/connection.c +9 -0
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently or the host is under low resource
+			 * conditions: let's wait 1 more second before
+			 * retrying the hypercall.
+			 */
+			msleep(1000);
+			break;

In case it is our last try (No. 10) we will return '18' from the function. I suggest we set ret = -ENOMEM here as well.

Quoted 6 lines

Thanks for the suggestion!

I think it would be better to add this to the case HV_STATUS_INVALID_CONNECTION_ID:
ret = -EAGAIN;
?

Yes, like fallthrough

Quoted 9 lines
Quoted 9 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 453

Quoted 3 lines
drivers/hv/connection.c +0 -0
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;

Or should we treat these two equally? There is a smaller (100ms) sleep between tries already, we can consider changing it instead.

Quoted 1 line
drivers/hv/connection.c +0 -0
 		case -ENOMEM:
Quoted 8 lines
Quoted 2 lines

--
Vitaly

In my experiments, in the HV_STATUS_INVALID_CONNECTION_ID case, waiting 100ms is not enough sometimes, so I'd like to wait more time. I agree with you both cases can wait 1000ms. I'll update my patch.

BTW, the " case -ENOMEM:" is not reachable(the hypervisor itself doesn't return -ENOMEM), I think. I can remove it.

hv_post_message() can return -EMSGSIZE or do_hypercall() return value (which becomes u16 in hv_post_message()). So yes, I agree, -ENOMEM is not possible.

Quoted 3 lines

Thanks,
-- Dexuan

--
Vitaly

#5 lore raw
Quoted 84 lines

-----Original Message-----
From: Dexuan Cui
Sent: Saturday, January 31, 2015 7:38 PM
To: Vitaly Kuznetsov
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: RE: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 23 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Saturday, January 31, 2015 1:29 AM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 11 lines · Dexuan Cui
Quoted 11 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, January 29, 2015 21:31 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 34 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines · Dexuan Cui

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe

hv_utils"

Quoted 28 lines
Quoted 13 lines
Quoted 4 lines

in a Linux guest.

Without the patch, the driver can occasionally fail to load.

Review

Quoted 8 lines
CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
(quoted diff) +0 -0

b/arch/x86/include/uapi/asm/hyperv.h

Quoted 12 lines

arch/x86/include/uapi/asm/hyperv.h line 229

Quoted 9 lines

index 90c458e..b9daffb 100644

arch/x86/include/uapi/asm/hyperv.h +1 -0
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19

The gap beween 4 and 18 tells me there are other codes here ;-) Are they all 'permanent failures'?

It looks we only need to care about these error codes here.

BTW, you can get all the hypercall error codes in the top level functional

spec:

Quoted 7 lines
Quoted 1 line

http://blogs.msdn.com/b/virtual_pc_guy/archive/2014/02/17/updated-

hypervisor-top-level-functional-specification.aspx

Quoted 1 line

For this hypercall (0x005c), see "14.9.7 HvPostMessage".

Thanks, interesting!

Btw, HV_STATUS_INSUFFICIENT_MEMORY looks suspicious, looks like we

can

Quoted 6 lines

hit it as well...

I suggest we split all failures here in 2 classes:
1) permanent
2) worth retrying

Quoted 6 lines
Quoted 4 lines

and treat them accordingly (no big changes, just maybe group them within
hv_post_message() together as it is the only place where these codes are being used).

Thanks for the suggestion, Vitaly!
I'll send out v2.

Thanks Dexuan.

K. Y

#6 lore raw
In reply to Dexuan Cui
Quoted 30 lines · Dexuan Cui

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe hv_utils" in a Linux guest.

Without the patch, the driver can occasionally fail to load.

CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
arch/x86/include/uapi/asm/hyperv.h +1 -0
index 90c458e..b9daffb 100644
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +0 -0
index c4acd1c..8bd05f3 100644

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 449

Quoted 10 lines
drivers/hv/connection.c +7 -0
@@ -440,6 +440,15 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently or the host is under low resource
+			 * conditions: let's wait 1 more second before
+			 * retrying the hypercall.
+			 */

The name HV_STATUS_INVALID_CONNECTION_ID is really confusing in this case. Since it does not show any meaning of lacking resources.

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 453

Quoted 4 lines
drivers/hv/connection.c +2 -0
+			msleep(1000);
+			break;
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;

I thought host should return this error value when lacking resources?

Quoted 10 lines
drivers/hv/connection.c +0 -0
 		case -ENOMEM:
Signature · 7 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#7 lore raw
Quoted 47 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Friday, January 30, 2015 10:47 AM
To: Dexuan Cui
Cc: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; KY Srinivasan; Haiyang Zhang
Subject: Re: [PATCH 2/3] hv: vmbus_post_msg: retry the hypercall on HV_STATUS_INVALID_CONNECTION_ID

Quoted 34 lines · Dexuan Cui

I got the hypercall error code on Hyper-V 2008 R2 when keeping running "rmmod hv_netvsc; modprobe hv_netvsc; rmmod hv_utils; modprobe hv_utils"
in a Linux guest.

Without the patch, the driver can occasionally fail to load.

CC "K. Y. Srinivasan" <[email protected]>
---
 arch/x86/include/uapi/asm/hyperv.h | 1 +
 drivers/hv/connection.c            | 9 +++++++++
 2 files changed, 10 insertions(+)
arch/x86/include/uapi/asm/hyperv.h +1 -0
index 90c458e..b9daffb 100644
@@ -225,6 +225,7 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INVALID_CONNECTION_ID		18
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 typedef struct _HV_REFERENCE_TSC_PAGE {
drivers/hv/connection.c +0 -0
index c4acd1c..8bd05f3 100644
@@ -440,6 +440,15 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 		ret = hv_post_message(conn_id, 1, buffer, buflen);
 
Quoted 11 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 449

Quoted 8 lines
drivers/hv/connection.c +7 -0
 		switch (ret) {
+		case HV_STATUS_INVALID_CONNECTION_ID:
+			/*
+			 * We could get this if we send messages too
+			 * frequently or the host is under low resource
+			 * conditions: let's wait 1 more second before
+			 * retrying the hypercall.
+			 */

The name HV_STATUS_INVALID_CONNECTION_ID is really confusing in this case. Since it does not show any meaning of lacking resources.

The description about the 'low host resource condition' might be not accurate. I'll remove this part.

Quoted 6 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen) · line 453

Quoted 4 lines
drivers/hv/connection.c +2 -0
+			msleep(1000);
+			break;
 		case HV_STATUS_INSUFFICIENT_BUFFERS:
 			ret = -ENOMEM;

I thought host should return this error value when lacking resources?

This should be correct.

Quoted 3 lines

drivers/hv/connection.c int vmbus_post_msg(void *buffer, size_t buflen)

Quoted 3 lines
drivers/hv/connection.c +0 -1
 		case -ENOMEM:
--

Thanks,
-- Dexuan ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�