[vz7.39] scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN.

Submitted by Roman Kagan on Dec. 19, 2017, 1:02 p.m.

Details

Message ID 20171219130225.781-1-rkagan@virtuozzo.com
State New
Series "scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN."
Headers show

Commit Message

Roman Kagan Dec. 19, 2017, 1:02 p.m.
From: "Richard W.M. Jones" <rjones@redhat.com>

If using indirect descriptors, you can make the total_sg as large as you
want.  If not, BUG is too serious because the function later returns
-ENOSPC.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 44ed8089e991a60d614abe0ee4b9057a28b364e4)
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
VZ-Bug: PSBM-79523
---
 drivers/virtio/virtio_ring.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index d77a91f39d55..5903139aede2 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -275,7 +275,6 @@  static inline int virtqueue_add(struct virtqueue *_vq,
 	}
 #endif
 
-	BUG_ON(total_sg > vq->vring.num);
 	BUG_ON(total_sg == 0);
 
 	head = vq->free_head;
@@ -284,8 +283,10 @@  static inline int virtqueue_add(struct virtqueue *_vq,
 	 * buffers, then go indirect. FIXME: tune this threshold */
 	if (vq->indirect && total_sg > 1 && vq->vq.num_free)
 		desc = alloc_indirect(_vq, total_sg, gfp);
-	else
+	else {
 		desc = NULL;
+		WARN_ON_ONCE(total_sg > vq->vring.num && !vq->indirect);
+	}
 
 	if (desc) {
 		/* Use a single buffer which doesn't continue */

Comments

Denis V. Lunev Dec. 19, 2017, 1:21 p.m.
On 12/19/2017 04:02 PM, Roman Kagan wrote:
> From: "Richard W.M. Jones" <rjones@redhat.com>
>
> If using indirect descriptors, you can make the total_sg as large as you
> want.  If not, BUG is too serious because the function later returns
> -ENOSPC.
>
> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> (cherry picked from commit 44ed8089e991a60d614abe0ee4b9057a28b364e4)
> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
> VZ-Bug: PSBM-79523
> ---
>  drivers/virtio/virtio_ring.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index d77a91f39d55..5903139aede2 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -275,7 +275,6 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>  	}
>  #endif
>  
> -	BUG_ON(total_sg > vq->vring.num);
>  	BUG_ON(total_sg == 0);
>  
>  	head = vq->free_head;
> @@ -284,8 +283,10 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>  	 * buffers, then go indirect. FIXME: tune this threshold */
>  	if (vq->indirect && total_sg > 1 && vq->vq.num_free)
>  		desc = alloc_indirect(_vq, total_sg, gfp);
> -	else
> +	else {
>  		desc = NULL;
> +		WARN_ON_ONCE(total_sg > vq->vring.num && !vq->indirect);
> +	}
>  
>  	if (desc) {
>  		/* Use a single buffer which doesn't continue */
Kostya, can you pls schedule a build?
QA wanted this very much.

Den
Denis V. Lunev Dec. 19, 2017, 2:26 p.m.
On 12/19/2017 04:02 PM, Roman Kagan wrote:
> From: "Richard W.M. Jones" <rjones@redhat.com>
>
> If using indirect descriptors, you can make the total_sg as large as you
> want.  If not, BUG is too serious because the function later returns
> -ENOSPC.
>
> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> (cherry picked from commit 44ed8089e991a60d614abe0ee4b9057a28b364e4)
> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
> VZ-Bug: PSBM-79523
> ---
>  drivers/virtio/virtio_ring.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index d77a91f39d55..5903139aede2 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -275,7 +275,6 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>  	}
>  #endif
>  
> -	BUG_ON(total_sg > vq->vring.num);
>  	BUG_ON(total_sg == 0);
>  
>  	head = vq->free_head;
> @@ -284,8 +283,10 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>  	 * buffers, then go indirect. FIXME: tune this threshold */
>  	if (vq->indirect && total_sg > 1 && vq->vq.num_free)
>  		desc = alloc_indirect(_vq, total_sg, gfp);
> -	else
> +	else {
>  		desc = NULL;
> +		WARN_ON_ONCE(total_sg > vq->vring.num && !vq->indirect);
> +	}
>  
>  	if (desc) {
>  		/* Use a single buffer which doesn't continue */
this is 120% not enough. vq->indirect is not enabled for
virtblock/virt-scsi.
Thus we should turn that on in guest (the feature is advertized) and
only after that we will see true performance improvement.

Den
Denis V. Lunev Dec. 19, 2017, 2:55 p.m.
On 12/19/2017 05:26 PM, Denis V. Lunev wrote:
> On 12/19/2017 04:02 PM, Roman Kagan wrote:
>> From: "Richard W.M. Jones" <rjones@redhat.com>
>>
>> If using indirect descriptors, you can make the total_sg as large as you
>> want.  If not, BUG is too serious because the function later returns
>> -ENOSPC.
>>
>> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
>> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
>> (cherry picked from commit 44ed8089e991a60d614abe0ee4b9057a28b364e4)
>> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
>> VZ-Bug: PSBM-79523
>> ---
>>  drivers/virtio/virtio_ring.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
>> index d77a91f39d55..5903139aede2 100644
>> --- a/drivers/virtio/virtio_ring.c
>> +++ b/drivers/virtio/virtio_ring.c
>> @@ -275,7 +275,6 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>>  	}
>>  #endif
>>  
>> -	BUG_ON(total_sg > vq->vring.num);
>>  	BUG_ON(total_sg == 0);
>>  
>>  	head = vq->free_head;
>> @@ -284,8 +283,10 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>>  	 * buffers, then go indirect. FIXME: tune this threshold */
>>  	if (vq->indirect && total_sg > 1 && vq->vq.num_free)
>>  		desc = alloc_indirect(_vq, total_sg, gfp);
>> -	else
>> +	else {
>>  		desc = NULL;
>> +		WARN_ON_ONCE(total_sg > vq->vring.num && !vq->indirect);
>> +	}
>>  
>>  	if (desc) {
>>  		/* Use a single buffer which doesn't continue */
> this is 120% not enough. vq->indirect is not enabled for
> virtblock/virt-scsi.
> Thus we should turn that on in guest (the feature is advertized) and
> only after that we will see true performance improvement.
>
> Den
pls disregard this. I have misinterpreted mainstream sources.

Den