: Staging: hv: Use native wait primitives
Subsystems (2)
PATCH 2/3 : Staging: hv: Use native wait primitives
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the osd_wait_primitive where the condition was cleared potentially after the condition was signalled.
--- drivers/staging/hv/channel.c | 58 +++++++++----------- drivers/staging/hv/channel_mgmt.c | 46 +++++++--------- drivers/staging/hv/channel_mgmt.h | 4 +- drivers/staging/hv/connection.c | 28 +++++++--- drivers/staging/hv/netvsc.c | 102 ++++++++++++++++++----------------- drivers/staging/hv/netvsc.h | 3 +- drivers/staging/hv/rndis_filter.c | 38 +++++++++---- drivers/staging/hv/storvsc.c | 98 ++++++++++++++++++++-------------- drivers/staging/hv/vmbus_private.h | 3 +- 9 files changed, 208 insertions(+), 172 deletions(-)
drivers/staging/hv/channel.c +26 -32
@@ -19,6 +19,8 @@* Hank Janssen <[email protected]> */ #include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/wait.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/module.h>
@@ -243,11 +245,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, goto errorout; } - openInfo->waitevent =osd_waitevent_create (); -if (!openInfo->waitevent) { - err = -ENOMEM ; - goto errorout; - } +init_waitqueue_head (&openInfo->waitevent); openMsg = (struct vmbus_channel_open_channel *)openInfo->msg; openMsg->header.msgtype =CHANNELMSG_OPENCHANNEL ;
@@ -280,8 +278,15 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, goto Cleanup; } -/* FIXME: Need to time-out here */ -osd_waitevent_wait (openInfo->waitevent); + openInfo->wait_condition =0 ; +wait_event_timeout (openInfo->waitevent, + openInfo->wait_condition, +msecs_to_jiffies (1000 )); +if (openInfo->wait_condition ==0 ) { + err = -ETIMEDOUT ; + goto errorout; + } +if (openInfo->response.open_result.status ==0 )DPRINT_INFO (VMBUS ,"channel <%p> open success!!" , newchannel);
@@ -294,7 +299,6 @@ Cleanup:list_del (&openInfo->msglistentry);spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags); -kfree (openInfo->waitevent);kfree (openInfo);return 0 ;
@@ -509,11 +513,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,if (ret)return ret; - msginfo->waitevent =osd_waitevent_create (); -if (!msginfo->waitevent) { - ret = -ENOMEM ; - goto Cleanup; - } +init_waitqueue_head (&msginfo->waitevent); gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg; gpadlmsg->header.msgtype =CHANNELMSG_GPADL_HEADER ;
@@ -533,6 +533,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,DPRINT_DBG (VMBUS ,"Sending GPADL Header - len %zd" , msginfo->msgsize -sizeof (*msginfo)); + msginfo->wait_condition =0 ; ret =vmbus_post_msg (gpadlmsg, msginfo->msgsize -sizeof (*msginfo));if (ret !=0 ) {
@@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, } } -osd_waitevent_wait (msginfo->waitevent); +wait_event_timeout (msginfo->waitevent, + msginfo->wait_condition, +msecs_to_jiffies (1000 )); +BUG_ON (msginfo->wait_condition ==0 ); +/* At this point, we received the gpadl created msg */ DPRINT_DBG(VMBUS, "Received GPADL created "
@@ -582,7 +587,6 @@ Cleanup:list_del (&msginfo->msglistentry);spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags); -kfree (msginfo->waitevent);kfree (msginfo);return ret; }
@@ -605,11 +609,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)if (!info)return -ENOMEM ; - info->waitevent =osd_waitevent_create (); -if (!info->waitevent) { -kfree (info); -return -ENOMEM ; - } +init_waitqueue_head (&info->waitevent); msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
@@ -621,22 +621,20 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)list_add_tail (&info->msglistentry, &vmbus_connection.chn_msg_list);spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags); - + info->wait_condition =0 ; ret =vmbus_post_msg (msg,sizeof (struct vmbus_channel_gpadl_teardown )); -if (ret !=0 ) { -/* TODO: */ -/* something... */ - } -osd_waitevent_wait (info->waitevent); +BUG_ON (ret !=0 ); +wait_event_timeout (info->waitevent, + info->wait_condition,msecs_to_jiffies (1000 )); +BUG_ON (info->wait_condition ==0 );/* Received a torndown response */ spin_lock_irqsave (&vmbus_connection.channelmsg_lock, flags);list_del (&info->msglistentry);spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags); -kfree (info->waitevent);kfree (info);return ret; }
@@ -664,18 +662,14 @@ void vmbus_close(struct vmbus_channel *channel)if (!info)return ; -/* info->waitEvent = osd_waitevent_create(); */ msg = (struct vmbus_channel_close_channel *)info->msg; msg->header.msgtype =CHANNELMSG_CLOSECHANNEL ; msg->child_relid = channel->offermsg.child_relid; ret =vmbus_post_msg (msg,sizeof (struct vmbus_channel_close_channel )); -if (ret !=0 ) { -/* TODO: */ -/* something... */ - } +BUG_ON (ret !=0 );/* Tear down the gpadl for the channel's ring buffer */ if (channel->ringbuffer_gpadlhandle) vmbus_teardown_gpadl(channel,
drivers/staging/hv/channel_mgmt.c +21 -25
99 lines not on this page · raw message
drivers/staging/hv/channel_mgmt.h +2 -2
@@ -289,8 +289,8 @@ struct vmbus_channel_msginfo {struct list_head submsglist;/* Synchronize the request/response if needed */ -struct osd_waitevent *waitevent; - +int wait_condition; +wait_queue_head_t waitevent;union {struct vmbus_channel_version_supported version_supported;struct vmbus_channel_open_result open_result;
drivers/staging/hv/connection.c +20 -8
@@ -21,6 +21,8 @@* */ #include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/wait.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/vmalloc.h>
@@ -97,11 +99,7 @@ int vmbus_connect(void) goto Cleanup; } - msginfo->waitevent =osd_waitevent_create (); -if (!msginfo->waitevent) { - ret = -ENOMEM ; - goto Cleanup; - } +init_waitqueue_head (&msginfo->waitevent); msg = (struct vmbus_channel_initiate_contact *)msginfo->msg;
@@ -131,14 +129,30 @@ int vmbus_connect(void) ret =vmbus_post_msg (msg,sizeof (struct vmbus_channel_initiate_contact ));if (ret !=0 ) { +spin_lock_irqsave (&vmbus_connection.channelmsg_lock, flags);list_del (&msginfo->msglistentry); +spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, + flags); goto Cleanup; }/* Wait for the connection response */ -osd_waitevent_wait (msginfo->waitevent); + msginfo->wait_condition =0 ; +wait_event_timeout (msginfo->waitevent, msginfo->wait_condition, +msecs_to_jiffies (1000 )); +if (msginfo->wait_condition ==0 ) { +spin_lock_irqsave (&vmbus_connection.channelmsg_lock, + flags); +list_del (&msginfo->msglistentry); +spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, + flags); + ret = -ETIMEDOUT ; + goto Cleanup; + } +spin_lock_irqsave (&vmbus_connection.channelmsg_lock, flags);list_del (&msginfo->msglistentry); +spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags);/* Check if successful */ if (msginfo->response.version_response.version_supported) {
@@ -153,7 +167,6 @@ int vmbus_connect(void) goto Cleanup; } -kfree (msginfo->waitevent);kfree (msginfo);return 0 ;
@@ -174,7 +187,6 @@ Cleanup: }if (msginfo) { -kfree (msginfo->waitevent);kfree (msginfo); }
drivers/staging/hv/netvsc.c +52 -50
288 lines not on this page · raw message
drivers/staging/hv/netvsc.h +2 -1
@@ -318,7 +318,8 @@ struct netvsc_device {struct nvsp_1_receive_buffer_section *recv_section;/* Used for NetVSP initialization protocol */ -struct osd_waitevent *channel_init_event; +int wait_condition; +wait_queue_head_t channel_init_wait;struct nvsp_message channel_init_pkt;struct nvsp_message revoke_packet;
drivers/staging/hv/rndis_filter.c +26 -12
@@ -19,6 +19,8 @@* Hank Janssen <[email protected]> */ #include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/wait.h> #include <linux/highmem.h> #include <linux/slab.h> #include <linux/io.h>
@@ -57,7 +59,8 @@ struct rndis_device {struct rndis_request {struct list_head list_ent; -struct osd_waitevent *waitevent; +int wait_condition; +wait_queue_head_t wait_event;/* * FIXME: We assumed a fixed size response here. If we do ever need to
@@ -129,11 +132,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,if (!request)return NULL ; - request->waitevent =osd_waitevent_create (); -if (!request->waitevent) { -kfree (request); -return NULL ; - } +init_waitqueue_head (&request->wait_event); rndis_msg = &request->request_msg; rndis_msg->ndis_msg_type = msg_type;
@@ -164,7 +163,6 @@ static void put_rndis_request(struct rndis_device *dev,list_del (&req->list_ent);spin_unlock_irqrestore (&dev->request_lock, flags); -kfree (req->waitevent);kfree (req); }
@@ -321,7 +319,8 @@ static void rndis_filter_receive_response(struct rndis_device *dev, } } -osd_waitevent_set (request->waitevent); + request->wait_condition =1 ; +wake_up (&request->wait_event); }else { DPRINT_ERR(NETVSC, "no rndis request found for this response " "(id 0x%x res type 0x%x)",
@@ -503,11 +502,17 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, query->info_buflen =0 ; query->dev_vc_handle =0 ; + request->wait_condition =0 ; ret =rndis_filter_send_request (dev, request);if (ret !=0 ) goto Cleanup; -osd_waitevent_wait (request->waitevent); +wait_event_timeout (request->wait_event, request->wait_condition, +msecs_to_jiffies (1000 )); +if (request->wait_condition ==0 ) { + ret = -ETIMEDOUT ; + goto Cleanup; + }/* Copy the response back */ query_complete = &request->response_msg.msg.query_complete;
@@ -578,12 +583,14 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,memcpy ((void *)(unsigned long )set +sizeof (struct rndis_set_request ), &new_filter,sizeof (u32)); + request->wait_condition =0 ; ret =rndis_filter_send_request (dev, request);if (ret !=0 ) goto Cleanup; - ret =osd_waitevent_waitex (request->waitevent,2000 /*2sec*/ ); -if (!ret) { +wait_event_timeout (request->wait_event, request->wait_condition, +msecs_to_jiffies (2000 )); +if (request->wait_condition ==0 ) { ret =-1 ;DPRINT_ERR (NETVSC ,"timeout before we got a set response..." );/*
@@ -669,13 +676,20 @@ static int rndis_filter_init_device(struct rndis_device *dev) dev->state =RNDIS_DEV_INITIALIZING ; + request->wait_condition =0 ; ret =rndis_filter_send_request (dev, request);if (ret !=0 ) { dev->state =RNDIS_DEV_UNINITIALIZED ; goto Cleanup; } -osd_waitevent_wait (request->waitevent); + +wait_event_timeout (request->wait_event, request->wait_condition, +msecs_to_jiffies (1000 )); +if (request->wait_condition ==0 ) { + ret = -ETIMEDOUT ; + goto Cleanup; + } init_complete = &request->response_msg.msg.init_complete; status = init_complete->status;
drivers/staging/hv/storvsc.c +57 -41
243 lines not on this page · raw message
drivers/staging/hv/vmbus_private.h +2 -1
@@ -91,7 +91,8 @@ struct vmbus_msginfo {struct list_head msglist_entry;/* Synchronize the request/response if needed */ -struct osd_waitevent *wait_event; +int wait_condition; +wait_queue_head_t wait_event;/* The message itself */ unsigned char msg[0 ];
Signature · 1 line
1.5.5.6
Quoted 5 lines · K. Y. Srinivasan
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the
osd_wait_primitivewhere the condition was cleared potentially after the condition was signalled.
...
drivers/staging/hv/channel.c int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, · line 573
Quoted 9 lines
drivers/staging/hv/channel.c +4
-1@@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, } } -osd_waitevent_wait (msginfo->waitevent); +wait_event_timeout (msginfo->waitevent, + msginfo->wait_condition, +msecs_to_jiffies (1000 )); +BUG_ON (msginfo->wait_condition ==0 );
The added BUG_ONs all over the code look scary. These shouldn't be BUG_ONs at all. You should maybe warn and bail out, but not kill the whole machine.
And looking at the code, more appropriate would be completion instead of wait events.
And msecs_to_jiffies(1000) == HZ.
Quoted 11 lines
drivers/staging/hv/channel_mgmt.c +2
-1@@ -689,7 +693,8 @@ static void vmbus_ongpadl_torndown(memcpy (&msginfo->response.gpadl_torndown, gpadl_torndown,sizeof (struct vmbus_channel_gpadl_torndown )); -osd_waitevent_set (msginfo->waitevent); + msginfo->wait_condition =1 ; +wake_up (&msginfo->waitevent);break ; } }
drivers/staging/hv/channel_mgmt.c static void vmbus_onversion_response( · line 742
Quoted 9 lines
drivers/staging/hv/channel_mgmt.c +2
-1@@ -730,7 +735,8 @@ static void vmbus_onversion_response(memcpy (&msginfo->response.version_response, version_response,sizeof (struct vmbus_channel_version_response )); -osd_waitevent_set (msginfo->waitevent); + msginfo->wait_condition =1 ; +wake_up (&msginfo->waitevent); } }spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags);
regards,
Signature · 1 line
js
Quoted 20 lines
-----Original Message-----
From: Jiri Slaby [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 4:21 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 5 lines · K. Y. Srinivasan
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the
osd_wait_primitivewhere the condition was cleared potentially after the condition was signalled....
Review int vmbus_establish_gpadl(struct vmbus_channel
Quoted 1 line
(quoted diff) +0
-0@@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct vmbus_channel*channel, void *kbuffer,
Quoted 1 line
Quoted 11 lines
drivers/staging/hv/channel.c int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, · line 573
Quoted 7 lines
drivers/staging/hv/channel.c +4
-1} } -osd_waitevent_wait (msginfo->waitevent); +wait_event_timeout (msginfo->waitevent, + msginfo->wait_condition, +msecs_to_jiffies (1000 )); +BUG_ON (msginfo->wait_condition ==0 );The added
BUG_ONsall over the code look scary. These shouldn't beBUG_ONsat all. You should maybe warn and bail out, but not kill the whole machine.
This is Linux code running as a guest on a Windows host; and so the guest cannot tolerate a failure of the host. In the cases where I have chosen to BUG_ON, there is no reasonable recovery possible when the host is non-functional (as determined by a non-responsive host).
Quoted 5 lines
And looking at the code, more appropriate would be completion instead of wait events.
And
msecs_to_jiffies(1000)== HZ.
Agreed. In this first round of cleanup, I chose to keep the primitives as they were in osd.c. Greg, if it is ok with you, I will send you a patch that fixes these issues on top of the patches I have already sent.
Regards,
K. Y
Quoted 26 lines
drivers/staging/hv/channel_mgmt.c static void vmbus_ongpadl_torndown( · line 695
Quoted 5 lines
drivers/staging/hv/channel_mgmt.c +0
-0@@ -689,7 +693,8 @@ static void vmbus_ongpadl_torndown( memcpy(&msginfo->response.gpadl_torndown, gpadl_torndown, sizeof(struct
vmbus_channel_gpadl_torndown));Quoted 7 lines
drivers/staging/hv/channel_mgmt.c +2
-1-osd_waitevent_set (msginfo->waitevent); + msginfo->wait_condition =1 ; +wake_up (&msginfo->waitevent);break ; } }drivers/staging/hv/channel_mgmt.c static void vmbus_onversion_response( · line 742
Quoted 9 lines
drivers/staging/hv/channel_mgmt.c +2
-1@@ -730,7 +735,8 @@ static void vmbus_onversion_response(memcpy (&msginfo->response.version_response, version_response,sizeof (struct vmbus_channel_version_response )); -osd_waitevent_set (msginfo->waitevent); + msginfo->wait_condition =1 ; +wake_up (&msginfo->waitevent); } }spin_unlock_irqrestore (&vmbus_connection.channelmsg_lock, flags);regards,
--
js
Quoted 32 lines · KY Srinivasan
Quoted 20 lines
-----Original Message-----
From: Jiri Slaby [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 4:21 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 5 lines · K. Y. Srinivasan
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the
osd_wait_primitivewhere the condition was cleared potentially after the condition was signalled....
Review int vmbus_establish_gpadl(struct vmbus_channel
Quoted 1 line
(quoted diff) +0
-0@@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct vmbus_channel*channel, void *kbuffer,
Quoted 1 line
Quoted 11 lines
drivers/staging/hv/channel.c int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, · line 573
Quoted 7 lines
drivers/staging/hv/channel.c +4
-1} } -osd_waitevent_wait (msginfo->waitevent); +wait_event_timeout (msginfo->waitevent, + msginfo->wait_condition, +msecs_to_jiffies (1000 )); +BUG_ON (msginfo->wait_condition ==0 );The added
BUG_ONsall over the code look scary. These shouldn't beBUG_ONsat all. You should maybe warn and bail out, but not kill the whole machine.
Quoted 4 lines
This is Linux code running as a guest on a Windows host; and so the guest cannot tolerate a failure of the host. In the cases where I have chosen to
BUG_ON, there is no reasonable recovery possible when the host is non-functional (as determined by a non-responsive host).
If you have a non-responsive host, wouldn't that imply that this guest code wouldn't run at all? :)
Having BUG_ON() in drivers is not a good idea either way. Please remove these in future patches.
Quoted 9 lines
Quoted 4 lines
And looking at the code, more appropriate would be completion instead of wait events.
And
msecs_to_jiffies(1000)== HZ.Agreed. In this first round of cleanup, I chose to keep the primitives as they were in
osd.c. Greg, if it is ok with you, I will send you a patch that fixes these issues on top of the patches I have already sent.
Yes, that is fine.
thanks,
greg k-h
Quoted 45 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 9:03 AM
To: KY Srinivasan
Cc: Jiri Slaby; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 32 lines · KY Srinivasan
Quoted 20 lines
-----Original Message-----
From: Jiri Slaby [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 4:21 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 5 lines · K. Y. Srinivasan
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the
osd_wait_primitivewhere the condition was cleared potentially after the condition was signalled....
Review int vmbus_establish_gpadl(struct vmbus_channel
Quoted 1 line
(quoted diff) +0
-0@@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct vmbus_channel*channel, void *kbuffer,
Quoted 1 line
Quoted 11 lines
drivers/staging/hv/channel.c int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, · line 573
Quoted 7 lines
drivers/staging/hv/channel.c +4
-1} } -osd_waitevent_wait (msginfo->waitevent); +wait_event_timeout (msginfo->waitevent, + msginfo->wait_condition, +msecs_to_jiffies (1000 )); +BUG_ON (msginfo->wait_condition ==0 );The added
BUG_ONsall over the code look scary. These shouldn't beBUG_ONsat all. You should maybe warn and bail out, but not kill the whole machine.Quoted 1 line
This is Linux code running as a guest on a Windows host; and so the guest
cannot
Quoted 8 lines
Quoted 1 line
tolerate a failure of the host. In the cases where I have chosen to
BUG_ON,there
Quoted 1 line
is no reasonable recovery possible when the host is non-functional (as
determined
Quoted 1 line
by a non-responsive host).
If you have a non-responsive host, wouldn't that imply that this guest code wouldn't run at all? :)
The fact that on a particular transaction the host has not responded within an expected time interval does not necessarily mean that the guest code would not be running. There may be issues on the host side that may be either transient or permanent that may cause problems like this. Keep in mind, HyperV is a type 1 hypervisor that would schedule all VMs including the host and so, guest would get scheduled.
Quoted 3 lines
Having
BUG_ON()in drivers is not a good idea either way. Please remove these in future patches.
In situations where there is not a reasonable rollback strategy (for instance in one of the cases, we are granting access to the guest physical pages to the host) we really have only 2 options:
1) Wait until the host responds. This wait could potentially be unbounded and in fact this was the way the code was to begin with. One of the reviewers had suggested that unbounded wait was to be corrected.
2) Wait for a specific period and if the host does not respond within a reasonable period, kill the guest since there is no recovery possible.
I chose option 2, as part of addressing some of the prior review comments. If the consensus now is to go back to option 1, I am fine with that; I will send you a patch to rectify this.
Regards,
K. Y
Quoted 16 lines
Quoted 10 lines
Quoted 5 lines
And looking at the code, more appropriate would be completion instead of wait events.
And
msecs_to_jiffies(1000)== HZ.Agreed. In this first round of cleanup, I chose to keep the primitives as they were in
osd.c. Greg, if it is ok with you, I will send you a patch that fixes these issues on top of the patches I have already sent.Yes, that is fine.
thanks,
greg k-h
Quoted 68 lines · KY Srinivasan
Quoted 45 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 9:03 AM
To: KY Srinivasan
Cc: Jiri Slaby; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 32 lines · KY Srinivasan
Quoted 20 lines
-----Original Message-----
From: Jiri Slaby [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 4:21 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 5 lines · K. Y. Srinivasan
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the
osd_wait_primitivewhere the condition was cleared potentially after the condition was signalled....
Review int vmbus_establish_gpadl(struct vmbus_channel
Quoted 1 line
(quoted diff) +0
-0@@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct vmbus_channel*channel, void *kbuffer,
Quoted 1 line
Quoted 11 lines
drivers/staging/hv/channel.c int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, · line 573
Quoted 7 lines
drivers/staging/hv/channel.c +4
-1} } -osd_waitevent_wait (msginfo->waitevent); +wait_event_timeout (msginfo->waitevent, + msginfo->wait_condition, +msecs_to_jiffies (1000 )); +BUG_ON (msginfo->wait_condition ==0 );The added
BUG_ONsall over the code look scary. These shouldn't beBUG_ONsat all. You should maybe warn and bail out, but not kill the whole machine.Quoted 1 line
This is Linux code running as a guest on a Windows host; and so the guest
cannot
Quoted 8 lines
Quoted 1 line
tolerate a failure of the host. In the cases where I have chosen to
BUG_ON,there
Quoted 1 line
is no reasonable recovery possible when the host is non-functional (as
determined
Quoted 1 line
by a non-responsive host).
If you have a non-responsive host, wouldn't that imply that this guest code wouldn't run at all? :)
The fact that on a particular transaction the host has not responded within an expected time interval does not necessarily mean that the guest code would not be running. There may be issues on the host side that may be either transient or permanent that may cause problems like this. Keep in mind, HyperV is a type 1 hypervisor that would schedule all VMs including the host and so, guest would get scheduled.
Quoted 3 lines
Having
BUG_ON()in drivers is not a good idea either way. Please remove these in future patches.In situations where there is not a reasonable rollback strategy (for instance in one of the cases, we are granting access to the guest physical pages to the host) we really have only 2 options:
Quoted 6 lines
1) Wait until the host responds. This wait could potentially be unbounded and in fact this was the way the code was to begin with. One of the reviewers had suggested that unbounded wait was to be corrected.
2) Wait for a specific period and if the host does not respond within a reasonable period, kill the guest since there is no recovery possible.
Killing the guest is a very serious thing, causing all sorts of possible problems with it, right?
Quoted 2 lines
I chose option 2, as part of addressing some of the prior review comments. If the consensus now is to go back to option 1, I am fine with that;
Unbounded waits aren't ok either, you need some sort of timeout.
But, as this is a bit preferable to dieing, I suggest doing this, and comment the heck out of it to explain all of this for anyone who reads it.
thanks,
greg k-h
Quoted 91 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 11:30 AM
To: KY Srinivasan
Cc: Jiri Slaby; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 21 lines · KY Srinivasan
Quoted 21 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 9:03 AM
To: KY Srinivasan
Cc: Jiri Slaby; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 10 lines · KY Srinivasan
Quoted 10 lines
-----Original Message-----
From: Jiri Slaby [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 4:21 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3]: Staging: hv: Use native wait primitivesQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · K. Y. Srinivasan
Quoted 5 lines
In preperation for getting rid of the osd layer; change the code to use native wait interfaces. As part of this, fixed the buggy implementation in the
osd_wait_primitivewhere the condition was cleared potentially after the condition was signalled....
Review int vmbus_establish_gpadl(struct
Quoted 1 line
(quoted diff) +0
-0@@ -566,7 +567,11 @@ int vmbus_establish_gpadl(struct
vmbus_channelQuoted 18 lines
Quoted 18 lines
Quoted 14 lines
Quoted 13 lines
*channel, void *kbuffer,
drivers/staging/hv/channel.c int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, · line 573
Quoted 8 lines
drivers/staging/hv/channel.c +4
-1} } -osd_waitevent_wait (msginfo->waitevent); +wait_event_timeout (msginfo->waitevent, + msginfo->wait_condition, +msecs_to_jiffies (1000 )); +BUG_ON (msginfo->wait_condition ==0 );The added
BUG_ONsall over the code look scary. These shouldn't beBUG_ONsat all. You should maybe warn and bail out, but not kill the whole machine.Quoted 1 line
This is Linux code running as a guest on a Windows host; and so the guest
cannot
Quoted 1 line
tolerate a failure of the host. In the cases where I have chosen to
BUG_ON,there
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
is no reasonable recovery possible when the host is non-functional (as
determined
Quoted 1 line
by a non-responsive host).
If you have a non-responsive host, wouldn't that imply that this guest code wouldn't run at all? :)
The fact that on a particular transaction the host has not responded within an
expected
Quoted 1 line
time interval does not necessarily mean that the guest code would not be
running. There may be
Quoted 1 line
issues on the host side that may be either transient or permanent that may
cause problems like
Quoted 1 line
this. Keep in mind, HyperV is a type 1 hypervisor that would schedule all VMs
including the host
Quoted 10 lines
and so, guest would get scheduled.
Quoted 3 lines
Having
BUG_ON()in drivers is not a good idea either way. Please remove these in future patches.In situations where there is not a reasonable rollback strategy (for instance in one of the cases, we are granting access to the guest physical pages to the host) we really have only 2 options:
Quoted 6 lines
1) Wait until the host responds. This wait could potentially be unbounded and in fact this was the way the code was to begin with. One of the reviewers had suggested that unbounded wait was to be corrected.
2) Wait for a specific period and if the host does not respond within a reasonable period, kill the guest since there is no recovery possible.
Quoted 2 lines
Killing the guest is a very serious thing, causing all sorts of possible problems with it, right?
If there was a reasonable rollback strategy, I would not be killing the guest.
Quoted 9 lines
Quoted 3 lines
I chose option 2, as part of addressing some of the prior review comments. If the consensus now is to go back to option 1, I am fine with that;
Unbounded waits aren't ok either, you need some sort of timeout.
But, as this is a bit preferable to dieing, I suggest doing this, and comment the heck out of it to explain all of this for anyone who reads it.
If I understand you correctly, you would be prefer to have unbounded waiting with comments justifying why we cannot have timeouts. I will roll out a patch once the tree stabilizes.
Regards,
K. Y
Quoted 4 lines
thanks,
greg k-h
Quoted 4 lines · KY Srinivasan
If I understand you correctly, you would be prefer to have unbounded waiting with comments justifying why we cannot have timeouts. I will roll out a patch once the tree stabilizes.
Just make sure to add a comment explaining why the wait is unbounded.
Signature · 1 line
Dmitry