Skip to contentSkip to conversation

Drivers: hv: hv_fcopy: fix a race condition for SMP guest

PATCH In review Dexuan Cui 2 participants 2 messages Jul 16, 2014 Hyper-V/Azure core and drivers

lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH 1/1 Drivers: hv: hv_fcopy: fix a race condition for SMP guest

We should schedule the 5s "timer work" before starting the data transfer, otherwise, the data transfer code may finish so fast on another virtual cpu that when the code(fcopy_write()) trying to cancel the 5s "timer work" can occasionally fail because the "timer work" may haven't been scheduled yet and as a result the fcopy process will be aborted wrongly by fcopy_work_func() in 5s.

Thank Liz Zhang <[email protected]> for the initial investigation on the bug.

This addresses https://bugzilla.redhat.com/show_bug.cgi?id=1118123

---
 drivers/hv/hv_fcopy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_fcopy.c +1 -1
index eaaa3d8..23b2ce2 100644
@@ -246,8 +246,8 @@ void hv_fcopy_onchannelcallback(void *context)
 		/*
 		 * Send the information to the user-level daemon.
 		 */
-		fcopy_send_data();
 		schedule_delayed_work(&fcopy_work, 5*HZ);
+		fcopy_send_data();
 		return;
 	}
 	icmsghdr->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 21 lines

-----Original Message-----
From: Dexuan Cui [mailto:[email protected]]
Sent: Wednesday, July 16, 2014 12:01 AM
To: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]
Cc: KY Srinivasan; Haiyang Zhang
Subject: [PATCH] Drivers: hv: hv_fcopy: fix a race condition for SMP guest

We should schedule the 5s "timer work" before starting the data transfer, otherwise, the data transfer code may finish so fast on another virtual cpu that when the code(fcopy_write()) trying to cancel the 5s "timer work" can occasionally fail because the "timer work" may haven't been scheduled yet and as a result the fcopy process will be aborted wrongly by fcopy_work_func() in 5s.

Thank Liz Zhang <[email protected]> for the initial investigation on the bug.

Quoted 7 lines

This addresses https://bugzilla.redhat.com/show_bug.cgi?id=1118123

Thanks Dexuan.

K. Y

Quoted 21 lines
---
 drivers/hv/hv_fcopy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_fcopy.c index renamed from drivers/hv/hv_fcopy.c +0 -0

eaaa3d8..23b2ce2 100644

drivers/hv/hv_fcopy.c +1 -1
@@ -246,8 +246,8 @@ void hv_fcopy_onchannelcallback(void *context)
 		/*
 		 * Send the information to the user-level daemon.
 		 */
-		fcopy_send_data();
 		schedule_delayed_work(&fcopy_work, 5*HZ);
+		fcopy_send_data();
 		return;
 	}
 	icmsghdr->icflags = ICMSGHDRFLAG_TRANSACTION |

ICMSGHDRFLAG_RESPONSE;
--
1.9.1