All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen-blkfront: fix mq start/stop race
@ 2017-06-22  1:36 Junxiao Bi
  2017-06-23  4:58 ` Junxiao Bi
  2017-06-23 12:57 ` Roger Pau Monné
  0 siblings, 2 replies; 9+ messages in thread
From: Junxiao Bi @ 2017-06-22  1:36 UTC (permalink / raw)
  To: xen-devel

When ring buf full, hw queue will be stopped. While blkif interrupt consume
request and make free space in ring buf, hw queue will be started again.
But since start queue is protected by spin lock while stop not, that will
cause a race.

interrupt:                                      process:
blkif_interrupt()                               blkif_queue_rq()
 kick_pending_request_queues_locked()
  blk_mq_start_stopped_hw_queues()
   clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
                                                 blk_mq_stop_hw_queue(hctx)
   blk_mq_run_hw_queue(hctx, async)

If ring buf is made empty in this case, interrupt will never come, then the
hw queue will be stopped forever, all processes waiting for the pending io
in the queue will hung.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
---
 drivers/block/xen-blkfront.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 8bb160cd00e1..4767b82b2cf6 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -912,8 +912,8 @@ out_err:
 	return BLK_MQ_RQ_QUEUE_ERROR;
 
 out_busy:
-	spin_unlock_irqrestore(&rinfo->ring_lock, flags);
 	blk_mq_stop_hw_queue(hctx);
+	spin_unlock_irqrestore(&rinfo->ring_lock, flags);
 	return BLK_MQ_RQ_QUEUE_BUSY;
 }
 
-- 
1.7.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-06-22  1:36 [PATCH] xen-blkfront: fix mq start/stop race Junxiao Bi
@ 2017-06-23  4:58 ` Junxiao Bi
  2017-06-23 12:22   ` Boris Ostrovsky
  2017-06-23 12:57 ` Roger Pau Monné
  1 sibling, 1 reply; 9+ messages in thread
From: Junxiao Bi @ 2017-06-23  4:58 UTC (permalink / raw)
  To: xen-devel, Boris Ostrovsky, jgross

Hi Boris & Juergen,

Could you help review this patch? This is a race and will cause the io hung.

Thanks,
Junxiao.

On 06/22/2017 09:36 AM, Junxiao Bi wrote:
> When ring buf full, hw queue will be stopped. While blkif interrupt consume
> request and make free space in ring buf, hw queue will be started again.
> But since start queue is protected by spin lock while stop not, that will
> cause a race.
> 
> interrupt:                                      process:
> blkif_interrupt()                               blkif_queue_rq()
>  kick_pending_request_queues_locked()
>   blk_mq_start_stopped_hw_queues()
>    clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
>                                                  blk_mq_stop_hw_queue(hctx)
>    blk_mq_run_hw_queue(hctx, async)
> 
> If ring buf is made empty in this case, interrupt will never come, then the
> hw queue will be stopped forever, all processes waiting for the pending io
> in the queue will hung.
> 
> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
> ---
>  drivers/block/xen-blkfront.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index 8bb160cd00e1..4767b82b2cf6 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -912,8 +912,8 @@ out_err:
>  	return BLK_MQ_RQ_QUEUE_ERROR;
>  
>  out_busy:
> -	spin_unlock_irqrestore(&rinfo->ring_lock, flags);
>  	blk_mq_stop_hw_queue(hctx);
> +	spin_unlock_irqrestore(&rinfo->ring_lock, flags);
>  	return BLK_MQ_RQ_QUEUE_BUSY;
>  }
>  
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-06-23  4:58 ` Junxiao Bi
@ 2017-06-23 12:22   ` Boris Ostrovsky
  0 siblings, 0 replies; 9+ messages in thread
From: Boris Ostrovsky @ 2017-06-23 12:22 UTC (permalink / raw)
  To: Junxiao Bi, xen-devel, jgross; +Cc: Roger Pau Monné



On 06/23/2017 12:58 AM, Junxiao Bi wrote:
> Hi Boris & Juergen,
> 
> Could you help review this patch? This is a race and will cause the io hung.
> 
> Thanks,
> Junxiao.
> 
> On 06/22/2017 09:36 AM, Junxiao Bi wrote:
>> When ring buf full, hw queue will be stopped. While blkif interrupt consume
>> request and make free space in ring buf, hw queue will be started again.
>> But since start queue is protected by spin lock while stop not, that will
>> cause a race.
>>
>> interrupt:                                      process:
>> blkif_interrupt()                               blkif_queue_rq()
>>   kick_pending_request_queues_locked()
>>    blk_mq_start_stopped_hw_queues()
>>     clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
>>                                                   blk_mq_stop_hw_queue(hctx)
>>     blk_mq_run_hw_queue(hctx, async)
>>
>> If ring buf is made empty in this case, interrupt will never come, then the
>> hw queue will be stopped forever, all processes waiting for the pending io
>> in the queue will hung.
>>
>> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
>> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>


Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

but I think Roger (copied) needs to Ack it.

-boris


>> ---
>>   drivers/block/xen-blkfront.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>> index 8bb160cd00e1..4767b82b2cf6 100644
>> --- a/drivers/block/xen-blkfront.c
>> +++ b/drivers/block/xen-blkfront.c
>> @@ -912,8 +912,8 @@ out_err:
>>   	return BLK_MQ_RQ_QUEUE_ERROR;
>>   
>>   out_busy:
>> -	spin_unlock_irqrestore(&rinfo->ring_lock, flags);
>>   	blk_mq_stop_hw_queue(hctx);
>> +	spin_unlock_irqrestore(&rinfo->ring_lock, flags);
>>   	return BLK_MQ_RQ_QUEUE_BUSY;
>>   }
>>   
>>
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-06-22  1:36 [PATCH] xen-blkfront: fix mq start/stop race Junxiao Bi
  2017-06-23  4:58 ` Junxiao Bi
@ 2017-06-23 12:57 ` Roger Pau Monné
  2017-07-19  1:19   ` Junxiao Bi
  1 sibling, 1 reply; 9+ messages in thread
From: Roger Pau Monné @ 2017-06-23 12:57 UTC (permalink / raw)
  To: Junxiao Bi; +Cc: xen-devel

On Thu, Jun 22, 2017 at 09:36:52AM +0800, Junxiao Bi wrote:
> When ring buf full, hw queue will be stopped. While blkif interrupt consume
> request and make free space in ring buf, hw queue will be started again.
> But since start queue is protected by spin lock while stop not, that will
> cause a race.
>
> interrupt:                                      process:
> blkif_interrupt()                               blkif_queue_rq()
>  kick_pending_request_queues_locked()
>   blk_mq_start_stopped_hw_queues()
>    clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
>                                                  blk_mq_stop_hw_queue(hctx)
>    blk_mq_run_hw_queue(hctx, async)
> 
> If ring buf is made empty in this case, interrupt will never come, then the
> hw queue will be stopped forever, all processes waiting for the pending io
> in the queue will hung.
> 
> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-06-23 12:57 ` Roger Pau Monné
@ 2017-07-19  1:19   ` Junxiao Bi
  2017-07-19  7:37     ` Roger Pau Monné
  0 siblings, 1 reply; 9+ messages in thread
From: Junxiao Bi @ 2017-07-19  1:19 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: xen-devel

Hi Roger,

On 06/23/2017 08:57 PM, Roger Pau Monné wrote:
> On Thu, Jun 22, 2017 at 09:36:52AM +0800, Junxiao Bi wrote:
>> When ring buf full, hw queue will be stopped. While blkif interrupt consume
>> request and make free space in ring buf, hw queue will be started again.
>> But since start queue is protected by spin lock while stop not, that will
>> cause a race.
>>
>> interrupt:                                      process:
>> blkif_interrupt()                               blkif_queue_rq()
>>  kick_pending_request_queues_locked()
>>   blk_mq_start_stopped_hw_queues()
>>    clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
>>                                                  blk_mq_stop_hw_queue(hctx)
>>    blk_mq_run_hw_queue(hctx, async)
>>
>> If ring buf is made empty in this case, interrupt will never come, then the
>> hw queue will be stopped forever, all processes waiting for the pending io
>> in the queue will hung.
>>
>> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
>> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
> 
> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Looks patch not in mainline. Can you please help merge it?

Thanks,
Junxiao.
> 
> Thanks, Roger.
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-07-19  1:19   ` Junxiao Bi
@ 2017-07-19  7:37     ` Roger Pau Monné
  2017-07-19  7:51       ` Junxiao Bi
  0 siblings, 1 reply; 9+ messages in thread
From: Roger Pau Monné @ 2017-07-19  7:37 UTC (permalink / raw)
  To: Junxiao Bi; +Cc: Juergen Gross, xen-devel, Boris Ostrovsky

On Wed, Jul 19, 2017 at 09:19:49AM +0800, Junxiao Bi wrote:
> Hi Roger,
> 
> On 06/23/2017 08:57 PM, Roger Pau Monné wrote:
> > On Thu, Jun 22, 2017 at 09:36:52AM +0800, Junxiao Bi wrote:
> >> When ring buf full, hw queue will be stopped. While blkif interrupt consume
> >> request and make free space in ring buf, hw queue will be started again.
> >> But since start queue is protected by spin lock while stop not, that will
> >> cause a race.
> >>
> >> interrupt:                                      process:
> >> blkif_interrupt()                               blkif_queue_rq()
> >>  kick_pending_request_queues_locked()
> >>   blk_mq_start_stopped_hw_queues()
> >>    clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
> >>                                                  blk_mq_stop_hw_queue(hctx)
> >>    blk_mq_run_hw_queue(hctx, async)
> >>
> >> If ring buf is made empty in this case, interrupt will never come, then the
> >> hw queue will be stopped forever, all processes waiting for the pending io
> >> in the queue will hung.
> >>
> >> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
> >> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
> > 
> > Acked-by: Roger Pau Monné <roger.pau@citrix.com>
> Looks patch not in mainline. Can you please help merge it?

I'm afraid this needs to be done by Konrad or one of the Linux
maintainers, I don't have an account on kernel.org in order to send
pull requests to Jens.

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-07-19  7:37     ` Roger Pau Monné
@ 2017-07-19  7:51       ` Junxiao Bi
  2017-07-19 14:08         ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 9+ messages in thread
From: Junxiao Bi @ 2017-07-19  7:51 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: Juergen Gross, xen-devel, Boris Ostrovsky

Hi Konrad,

On 07/19/2017 03:37 PM, Roger Pau Monné wrote:
> On Wed, Jul 19, 2017 at 09:19:49AM +0800, Junxiao Bi wrote:
>> Hi Roger,
>>
>> On 06/23/2017 08:57 PM, Roger Pau Monné wrote:
>>> On Thu, Jun 22, 2017 at 09:36:52AM +0800, Junxiao Bi wrote:
>>>> When ring buf full, hw queue will be stopped. While blkif interrupt consume
>>>> request and make free space in ring buf, hw queue will be started again.
>>>> But since start queue is protected by spin lock while stop not, that will
>>>> cause a race.
>>>>
>>>> interrupt:                                      process:
>>>> blkif_interrupt()                               blkif_queue_rq()
>>>>  kick_pending_request_queues_locked()
>>>>   blk_mq_start_stopped_hw_queues()
>>>>    clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
>>>>                                                  blk_mq_stop_hw_queue(hctx)
>>>>    blk_mq_run_hw_queue(hctx, async)
>>>>
>>>> If ring buf is made empty in this case, interrupt will never come, then the
>>>> hw queue will be stopped forever, all processes waiting for the pending io
>>>> in the queue will hung.
>>>>
>>>> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
>>>> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
>>>
>>> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
>> Looks patch not in mainline. Can you please help merge it?
> 
> I'm afraid this needs to be done by Konrad or one of the Linux
> maintainers, I don't have an account on kernel.org in order to send
> pull requests to Jens.
Can you pls help merge it?

Thanks,
Junxiao.
> 
> Roger.
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-07-19  7:51       ` Junxiao Bi
@ 2017-07-19 14:08         ` Konrad Rzeszutek Wilk
  2017-07-20  1:29           ` Junxiao Bi
  0 siblings, 1 reply; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2017-07-19 14:08 UTC (permalink / raw)
  To: Junxiao Bi
  Cc: Juergen Gross, xen-devel, Boris Ostrovsky, Roger Pau Monné

On Wed, Jul 19, 2017 at 03:51:48PM +0800, Junxiao Bi wrote:
> Hi Konrad,
> 
> On 07/19/2017 03:37 PM, Roger Pau Monné wrote:
> > On Wed, Jul 19, 2017 at 09:19:49AM +0800, Junxiao Bi wrote:
> >> Hi Roger,
> >>
> >> On 06/23/2017 08:57 PM, Roger Pau Monné wrote:
> >>> On Thu, Jun 22, 2017 at 09:36:52AM +0800, Junxiao Bi wrote:
> >>>> When ring buf full, hw queue will be stopped. While blkif interrupt consume
> >>>> request and make free space in ring buf, hw queue will be started again.
> >>>> But since start queue is protected by spin lock while stop not, that will
> >>>> cause a race.
> >>>>
> >>>> interrupt:                                      process:
> >>>> blkif_interrupt()                               blkif_queue_rq()
> >>>>  kick_pending_request_queues_locked()
> >>>>   blk_mq_start_stopped_hw_queues()
> >>>>    clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
> >>>>                                                  blk_mq_stop_hw_queue(hctx)
> >>>>    blk_mq_run_hw_queue(hctx, async)
> >>>>
> >>>> If ring buf is made empty in this case, interrupt will never come, then the
> >>>> hw queue will be stopped forever, all processes waiting for the pending io
> >>>> in the queue will hung.
> >>>>
> >>>> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
> >>>> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
> >>>
> >>> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
> >> Looks patch not in mainline. Can you please help merge it?
> > 
> > I'm afraid this needs to be done by Konrad or one of the Linux
> > maintainers, I don't have an account on kernel.org in order to send
> > pull requests to Jens.
> Can you pls help merge it?

Could you kindly repost it with the updated tags _and_ against Linus's latest
branch?

I get:
[konrad@char linux]$ git am -s < /tmp/a
Applying: xen-blkfront: fix mq start/stop race
error: patch failed: drivers/block/xen-blkfront.c:912
error: drivers/block/xen-blkfront.c: patch does not apply
Patch failed at 0001 xen-blkfront: fix mq start/stop race
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


> 
> Thanks,
> Junxiao.
> > 
> > Roger.
> > 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen-blkfront: fix mq start/stop race
  2017-07-19 14:08         ` Konrad Rzeszutek Wilk
@ 2017-07-20  1:29           ` Junxiao Bi
  0 siblings, 0 replies; 9+ messages in thread
From: Junxiao Bi @ 2017-07-20  1:29 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Juergen Gross, xen-devel, Boris Ostrovsky, Roger Pau Monné

On 07/19/2017 10:08 PM, Konrad Rzeszutek Wilk wrote:
> On Wed, Jul 19, 2017 at 03:51:48PM +0800, Junxiao Bi wrote:
>> Hi Konrad,
>>
>> On 07/19/2017 03:37 PM, Roger Pau Monné wrote:
>>> On Wed, Jul 19, 2017 at 09:19:49AM +0800, Junxiao Bi wrote:
>>>> Hi Roger,
>>>>
>>>> On 06/23/2017 08:57 PM, Roger Pau Monné wrote:
>>>>> On Thu, Jun 22, 2017 at 09:36:52AM +0800, Junxiao Bi wrote:
>>>>>> When ring buf full, hw queue will be stopped. While blkif interrupt consume
>>>>>> request and make free space in ring buf, hw queue will be started again.
>>>>>> But since start queue is protected by spin lock while stop not, that will
>>>>>> cause a race.
>>>>>>
>>>>>> interrupt:                                      process:
>>>>>> blkif_interrupt()                               blkif_queue_rq()
>>>>>>  kick_pending_request_queues_locked()
>>>>>>   blk_mq_start_stopped_hw_queues()
>>>>>>    clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
>>>>>>                                                  blk_mq_stop_hw_queue(hctx)
>>>>>>    blk_mq_run_hw_queue(hctx, async)
>>>>>>
>>>>>> If ring buf is made empty in this case, interrupt will never come, then the
>>>>>> hw queue will be stopped forever, all processes waiting for the pending io
>>>>>> in the queue will hung.
>>>>>>
>>>>>> Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
>>>>>> Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
>>>>>
>>>>> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
>>>> Looks patch not in mainline. Can you please help merge it?
>>>
>>> I'm afraid this needs to be done by Konrad or one of the Linux
>>> maintainers, I don't have an account on kernel.org in order to send
>>> pull requests to Jens.
>> Can you pls help merge it?
> 
> Could you kindly repost it with the updated tags _and_ against Linus's latest
> branch?
Sure, v2 sent. Please check.

Thanks,
Junxiao.
> 
> I get:
> [konrad@char linux]$ git am -s < /tmp/a
> Applying: xen-blkfront: fix mq start/stop race
> error: patch failed: drivers/block/xen-blkfront.c:912
> error: drivers/block/xen-blkfront.c: patch does not apply
> Patch failed at 0001 xen-blkfront: fix mq start/stop race
> The copy of the patch that failed is found in: .git/rebase-apply/patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
> 
> 
>>
>> Thanks,
>> Junxiao.
>>>
>>> Roger.
>>>
>>


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-07-20  1:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-22  1:36 [PATCH] xen-blkfront: fix mq start/stop race Junxiao Bi
2017-06-23  4:58 ` Junxiao Bi
2017-06-23 12:22   ` Boris Ostrovsky
2017-06-23 12:57 ` Roger Pau Monné
2017-07-19  1:19   ` Junxiao Bi
2017-07-19  7:37     ` Roger Pau Monné
2017-07-19  7:51       ` Junxiao Bi
2017-07-19 14:08         ` Konrad Rzeszutek Wilk
2017-07-20  1:29           ` Junxiao Bi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.