From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753144AbdHJQ6L (ORCPT ); Thu, 10 Aug 2017 12:58:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35166 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752807AbdHJQ6K (ORCPT ); Thu, 10 Aug 2017 12:58:10 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C45F45C9D5 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH v2 2/2] virtio: virtio_scsi: Set can_queue to the length of the virtqueue. To: "Richard W.M. Jones" , jejb@linux.vnet.ibm.com Cc: martin.petersen@oracle.com, mst@redhat.com, jasowang@redhat.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, hch@lst.de References: <20170810165652.21515-1-rjones@redhat.com> <20170810165652.21515-3-rjones@redhat.com> From: Paolo Bonzini Message-ID: Date: Thu, 10 Aug 2017 18:58:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170810165652.21515-3-rjones@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 10 Aug 2017 16:58:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/08/2017 18:56, Richard W.M. Jones wrote: > Since switching to blk-mq as the default in commit 5c279bd9e406 > ("scsi: default to scsi-mq"), virtio-scsi LUNs consume about 10x as > much kernel memory. > > qemu currently allocates a fixed 128 entry virtqueue. can_queue > currently is set to 1024. But with indirect descriptors, each command > in the queue takes 1 virtqueue entry, so the number of commands which > can be queued is equal to the length of the virtqueue. > > Note I intend to send a patch to qemu to allow the virtqueue size to > be configured from the qemu command line. > > Thanks Paolo Bonzini, Christoph Hellwig. > > Signed-off-by: Richard W.M. Jones > --- > drivers/scsi/virtio_scsi.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c > index 9be211d68b15..7c28e8d4955a 100644 > --- a/drivers/scsi/virtio_scsi.c > +++ b/drivers/scsi/virtio_scsi.c > @@ -818,7 +818,6 @@ static struct scsi_host_template virtscsi_host_template_single = { > .eh_timed_out = virtscsi_eh_timed_out, > .slave_alloc = virtscsi_device_alloc, > > - .can_queue = 1024, > .dma_boundary = UINT_MAX, > .use_clustering = ENABLE_CLUSTERING, > .target_alloc = virtscsi_target_alloc, > @@ -839,7 +838,6 @@ static struct scsi_host_template virtscsi_host_template_multi = { > .eh_timed_out = virtscsi_eh_timed_out, > .slave_alloc = virtscsi_device_alloc, > > - .can_queue = 1024, > .dma_boundary = UINT_MAX, > .use_clustering = ENABLE_CLUSTERING, > .target_alloc = virtscsi_target_alloc, > @@ -972,6 +970,8 @@ static int virtscsi_probe(struct virtio_device *vdev) > if (err) > goto virtscsi_init_failed; > > + shost->can_queue = virtqueue_get_vring_size(vscsi->req_vqs[0].vq); > + > cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1; > shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue); > shost->max_sectors = virtscsi_config_get(vdev, max_sectors) ?: 0xFFFF; > Acked-by: Paolo Bonzini