RE: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()
> -Original Message- > From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > Sent: Monday, October 31, 2016 3:05 AM > To: KY Srinivasan > Cc: de...@linuxdriverproject.org; Van De Ven, Arjan > ; linux-ker...@vger.kernel.org; Haiyang Zhang > > Subject: Re: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in > vmbus_post_msg() > > KY Srinivasan writes: > > >> -Original Message- > >> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > >> Sent: Wednesday, October 26, 2016 4:12 AM > >> To: de...@linuxdriverproject.org > >> Cc: linux-ker...@vger.kernel.org; KY Srinivasan ; > >> Haiyang Zhang > >> Subject: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in > >> vmbus_post_msg() > >> > >> DoS protection conditions were altered in WS2016 and now it's easy to get > >> -EAGAIN returned from vmbus_post_msg() (e.g. when we try changing > MTU > >> on a > >> netvsc device in a loop). All vmbus_post_msg() callers don't retry the > >> operation and we usually end up with a non-functional device or crash. > >> > >> While host's DoS protection conditions are unknown to me my tests show > >> that > >> it can take up to 46 attempts to send a message after changing udelay() to > >> mdelay() and caping msec at '256', this means we can wait up to 10 > seconds > >> before the message is sent so we need to use msleep() instead. Almost all > >> vmbus_post_msg() callers are ready to sleep but there is one special case: > >> vmbus_initiate_unload() which can be called from interrupt/NMI context > >> and > >> we can't sleep there. I'm also not sure about the lonely > >> vmbus_send_tl_connect_request() which has no in-tree users but its > >> external > >> users are most likely waiting for the host to reply so sleeping there is > >> also appropriate. > > > > Vitaly, > > > > One of the reasons why the delay was in microseconds was to make sure > that the boot time > > was not adversely affected by the delay we had in setting up the channel. > The change to microsecond > > delay and other changes in this code reduced the time it took to initialize > netvsc from > > 200 milliseconds to about 12 milliseconds. This is important for us as we > > look > at achieving sub-second > > boot times. > > The situation you are trying to address are test cases where you are hitting > the host with > > requests that triggers hosts DOS prevention code. Perhaps we could have a > hybrid approach: we > > retain microsecond wait until we hit a threshold and then we use > millisecond delays. This way, the normal boot > > path is still fast while we can handle some of the other cases where the > > host > DOS prevention code kicks in. > > > > Ok, > > I actually tested boot time with my patch and didn't see a difference > (so I guess our first attempt to send messages usually succeeds) but if > we're concearned about less-than-a-second boot time we'd rather keep the > microseonds delay for first several attempts. I'll do v2. Thank you. K. Y > > Thanks, > > > -- > Vitaly ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()
> Ok, > > I actually tested boot time with my patch and didn't see a difference > (so I guess our first attempt to send messages usually succeeds) but if > we're concearned about less-than-a-second boot time we'd rather keep the > microseonds delay for first several attempts. I'll do v2. of course we care about less-than-a-second boot time.. it's a virtual machine.. there's no reason the kernel should ever take more than 100 msec total (including all drivers) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()
KY Srinivasan writes: >> -Original Message- >> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] >> Sent: Wednesday, October 26, 2016 4:12 AM >> To: de...@linuxdriverproject.org >> Cc: linux-ker...@vger.kernel.org; KY Srinivasan ; >> Haiyang Zhang >> Subject: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in >> vmbus_post_msg() >> >> DoS protection conditions were altered in WS2016 and now it's easy to get >> -EAGAIN returned from vmbus_post_msg() (e.g. when we try changing MTU >> on a >> netvsc device in a loop). All vmbus_post_msg() callers don't retry the >> operation and we usually end up with a non-functional device or crash. >> >> While host's DoS protection conditions are unknown to me my tests show >> that >> it can take up to 46 attempts to send a message after changing udelay() to >> mdelay() and caping msec at '256', this means we can wait up to 10 seconds >> before the message is sent so we need to use msleep() instead. Almost all >> vmbus_post_msg() callers are ready to sleep but there is one special case: >> vmbus_initiate_unload() which can be called from interrupt/NMI context >> and >> we can't sleep there. I'm also not sure about the lonely >> vmbus_send_tl_connect_request() which has no in-tree users but its >> external >> users are most likely waiting for the host to reply so sleeping there is >> also appropriate. > > Vitaly, > > One of the reasons why the delay was in microseconds was to make sure that > the boot time > was not adversely affected by the delay we had in setting up the channel. The > change to microsecond > delay and other changes in this code reduced the time it took to initialize > netvsc from > 200 milliseconds to about 12 milliseconds. This is important for us as we > look at achieving sub-second > boot times. > The situation you are trying to address are test cases where you are hitting > the host with > requests that triggers hosts DOS prevention code. Perhaps we could have a > hybrid approach: we > retain microsecond wait until we hit a threshold and then we use millisecond > delays. This way, the normal boot > path is still fast while we can handle some of the other cases where the host > DOS prevention code kicks in. > Ok, I actually tested boot time with my patch and didn't see a difference (so I guess our first attempt to send messages usually succeeds) but if we're concearned about less-than-a-second boot time we'd rather keep the microseonds delay for first several attempts. I'll do v2. Thanks, -- Vitaly ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()
> -Original Message- > From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > Sent: Wednesday, October 26, 2016 4:12 AM > To: de...@linuxdriverproject.org > Cc: linux-ker...@vger.kernel.org; KY Srinivasan ; > Haiyang Zhang > Subject: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in > vmbus_post_msg() > > DoS protection conditions were altered in WS2016 and now it's easy to get > -EAGAIN returned from vmbus_post_msg() (e.g. when we try changing MTU > on a > netvsc device in a loop). All vmbus_post_msg() callers don't retry the > operation and we usually end up with a non-functional device or crash. > > While host's DoS protection conditions are unknown to me my tests show > that > it can take up to 46 attempts to send a message after changing udelay() to > mdelay() and caping msec at '256', this means we can wait up to 10 seconds > before the message is sent so we need to use msleep() instead. Almost all > vmbus_post_msg() callers are ready to sleep but there is one special case: > vmbus_initiate_unload() which can be called from interrupt/NMI context > and > we can't sleep there. I'm also not sure about the lonely > vmbus_send_tl_connect_request() which has no in-tree users but its > external > users are most likely waiting for the host to reply so sleeping there is > also appropriate. Vitaly, One of the reasons why the delay was in microseconds was to make sure that the boot time was not adversely affected by the delay we had in setting up the channel. The change to microsecond delay and other changes in this code reduced the time it took to initialize netvsc from 200 milliseconds to about 12 milliseconds. This is important for us as we look at achieving sub-second boot times. The situation you are trying to address are test cases where you are hitting the host with requests that triggers hosts DOS prevention code. Perhaps we could have a hybrid approach: we retain microsecond wait until we hit a threshold and then we use millisecond delays. This way, the normal boot path is still fast while we can handle some of the other cases where the host DOS prevention code kicks in. Regards, K. Y > > Signed-off-by: Vitaly Kuznetsov > --- > drivers/hv/channel.c | 17 + > drivers/hv/channel_mgmt.c | 10 ++ > drivers/hv/connection.c | 19 --- > drivers/hv/hyperv_vmbus.h | 2 +- > 4 files changed, 28 insertions(+), 20 deletions(-) > > diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c > index 16f91c8..28ca66e 100644 > --- a/drivers/hv/channel.c > +++ b/drivers/hv/channel.c > @@ -180,7 +180,7 @@ int vmbus_open(struct vmbus_channel > *newchannel, u32 send_ringbuffer_size, > spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, > flags); > > ret = vmbus_post_msg(open_msg, > -sizeof(struct vmbus_channel_open_channel)); > + sizeof(struct vmbus_channel_open_channel), > true); > > if (ret != 0) { > err = ret; > @@ -232,7 +232,7 @@ int vmbus_send_tl_connect_request(const uuid_le > *shv_guest_servie_id, > conn_msg.guest_endpoint_id = *shv_guest_servie_id; > conn_msg.host_service_id = *shv_host_servie_id; > > - return vmbus_post_msg(&conn_msg, sizeof(conn_msg)); > + return vmbus_post_msg(&conn_msg, sizeof(conn_msg), true); > } > EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request); > > @@ -418,7 +418,7 @@ int vmbus_establish_gpadl(struct vmbus_channel > *channel, void *kbuffer, > spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, > flags); > > ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize - > -sizeof(*msginfo)); > + sizeof(*msginfo), true); > if (ret != 0) > goto cleanup; > > @@ -432,8 +432,8 @@ int vmbus_establish_gpadl(struct vmbus_channel > *channel, void *kbuffer, > gpadl_body->gpadl = next_gpadl_handle; > > ret = vmbus_post_msg(gpadl_body, > - submsginfo->msgsize - > - sizeof(*submsginfo)); > + submsginfo->msgsize - > sizeof(*submsginfo), > + true); > if (ret != 0) > goto cleanup; > > @@ -484,8 +484,8 @@ 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); > - ret = vmbus_post_msg(msg, > -sizeof(struct vmbus_channel_gpadl_teardown)); > + ret = vmbus_post_msg(msg, sizeof(struct > vmbus_channel_gpadl_teardown), > + true); > > if (ret) > goto post_msg_err; > @@ -556,7 +556,8 @@ static int vmbus_close_internal(struct vmbus_channel > *channel) > msg->header.msgty
RE: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()
> -Original Message- > From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > Sent: Wednesday, October 26, 2016 7:12 AM > To: de...@linuxdriverproject.org > Cc: linux-ker...@vger.kernel.org; KY Srinivasan ; > Haiyang Zhang > Subject: [PATCH] Drivers: hv: vmbus: Raise retry/wait limits in > vmbus_post_msg() > > DoS protection conditions were altered in WS2016 and now it's easy to > get > -EAGAIN returned from vmbus_post_msg() (e.g. when we try changing MTU on > a > netvsc device in a loop). All vmbus_post_msg() callers don't retry the > operation and we usually end up with a non-functional device or crash. > > While host's DoS protection conditions are unknown to me my tests show > that > it can take up to 46 attempts to send a message after changing udelay() > to > mdelay() and caping msec at '256', this means we can wait up to 10 > seconds > before the message is sent so we need to use msleep() instead. Almost > all > vmbus_post_msg() callers are ready to sleep but there is one special > case: > vmbus_initiate_unload() which can be called from interrupt/NMI context > and > we can't sleep there. I'm also not sure about the lonely > vmbus_send_tl_connect_request() which has no in-tree users but its > external > users are most likely waiting for the host to reply so sleeping there is > also appropriate. > > Signed-off-by: Vitaly Kuznetsov > --- > drivers/hv/channel.c | 17 + > drivers/hv/channel_mgmt.c | 10 ++ > drivers/hv/connection.c | 19 --- > drivers/hv/hyperv_vmbus.h | 2 +- > 4 files changed, 28 insertions(+), 20 deletions(-) > > diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c > index 16f91c8..28ca66e 100644 > --- a/drivers/hv/channel.c > +++ b/drivers/hv/channel.c > @@ -180,7 +180,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 > send_ringbuffer_size, > spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); > > ret = vmbus_post_msg(open_msg, > -sizeof(struct vmbus_channel_open_channel)); > + sizeof(struct vmbus_channel_open_channel), true); > > if (ret != 0) { > err = ret; > @@ -232,7 +232,7 @@ int vmbus_send_tl_connect_request(const uuid_le > *shv_guest_servie_id, > conn_msg.guest_endpoint_id = *shv_guest_servie_id; > conn_msg.host_service_id = *shv_host_servie_id; > > - return vmbus_post_msg(&conn_msg, sizeof(conn_msg)); > + return vmbus_post_msg(&conn_msg, sizeof(conn_msg), true); > } > EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request); > > @@ -418,7 +418,7 @@ int vmbus_establish_gpadl(struct vmbus_channel > *channel, void *kbuffer, > spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); > > ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize - > -sizeof(*msginfo)); > + sizeof(*msginfo), true); > if (ret != 0) > goto cleanup; > > @@ -432,8 +432,8 @@ int vmbus_establish_gpadl(struct vmbus_channel > *channel, void *kbuffer, > gpadl_body->gpadl = next_gpadl_handle; > > ret = vmbus_post_msg(gpadl_body, > - submsginfo->msgsize - > - sizeof(*submsginfo)); > + submsginfo->msgsize - sizeof(*submsginfo), > + true); > if (ret != 0) > goto cleanup; > > @@ -484,8 +484,8 @@ 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); > - ret = vmbus_post_msg(msg, > -sizeof(struct vmbus_channel_gpadl_teardown)); > + ret = vmbus_post_msg(msg, sizeof(struct > vmbus_channel_gpadl_teardown), > + true); > > if (ret) > goto post_msg_err; > @@ -556,7 +556,8 @@ static int vmbus_close_internal(struct vmbus_channel > *channel) > msg->header.msgtype = CHANNELMSG_CLOSECHANNEL; > msg->child_relid = channel->offermsg.child_relid; > > - ret = vmbus_post_msg(msg, sizeof(struct > vmbus_channel_close_channel)); > + ret = vmbus_post_msg(msg, sizeof(struct > vmbus_channel_close_channel), > + true); > > if (ret) { > pr_err("Close failed: close post msg return is %d\n", ret); > diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c > index 96a85cd..160d92e 100644 > --- a/drivers/hv/channel_mgmt.c > +++ b/drivers/hv/channel_mgmt.c > @@ -321,7 +321,8 @@ static void vmbus_release_relid(u32 relid) > memset(&msg, 0, sizeof(struct vmbus_channel_relid_released)); > msg.child_relid = relid; > msg.header.msgtype = CHANNELMSG_RELID_RELEASED; > - vmbus_post_msg(&msg, sizeof(struct vmbus_chann