Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2285574imc; Tue, 12 Mar 2019 10:35:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqycumzm2Q/F6DHqU4oxCRZCm8JF9Ec7qFHR10ld3K7ECSy0SzRT7pA+NClTwfauMOEba8zS X-Received: by 2002:a17:902:ba8d:: with SMTP id k13mr41266276pls.15.1552412132959; Tue, 12 Mar 2019 10:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552412132; cv=none; d=google.com; s=arc-20160816; b=dXUDTN56q8aRMa2kJuRYIvZkyFLDaCoOyc0cACmLFg18X5G6SM1pHg9HB2f4/uU0TY G7arwcPySHAvKx813fQInMUUyVzqGlAU9Q6nQNivPJBKUHxFvvLIL3z3N4XZ42oX68Pp XEAUU7of+CfxI+RVSAomxLfA0N3CgKS3fUUTGGQSunSVRBYbpa3GoFvBD/t103vsR+Gt aOQ/qRzRJV5WbeJ4Iu37UlebqDa53LYwKz0e70yP6wlvge0mQiqhzalm1r3TWWMq5JQo 7JsLotmd3GBl7Yz7tml6mTvY31JT07GIz/2QDGA7bQIViKhyMsiahp8LerGhqOQmufnP AXuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=wpYN8HlWX9uWzdD4s1lo4wAhRjHe7XlqllQ9s6evMYk=; b=HjTZ7c1DUL9PU8nuiALjB1UgCyPcUEaeH/Qh538VNrohGFT546TdhTWOdPlaFz0UHS uv97eRRU1SuqoHJif9mF7mE+hjVE6hhi8C28B3wZ9fGg93SoX15RJ0Zi+l/N4YbIaUeI LlgEKuT4yqkw3E4OI1j4KXyezjpgf/Ai9GEMLX1yjh5hMwE++f98AOorkx6pe6/KsM0N LciMvlh8sxq+rWppl46Uc4KlNhUlrGZ7vYmBpkepVkdhbmZwjTi72vgv/m3PB3JwNcag 2oSSPcYT4u3wIbLiAd3mC9BIKp/tyZZuO4365CGUYsGN64WtfMP3e4bw432VsqJ113HY jkhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si7732319pgs.557.2019.03.12.10.35.17; Tue, 12 Mar 2019 10:35:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729764AbfCLRd6 (ORCPT + 99 others); Tue, 12 Mar 2019 13:33:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49464 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729587AbfCLRd4 (ORCPT ); Tue, 12 Mar 2019 13:33:56 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E70281DF1; Tue, 12 Mar 2019 17:33:56 +0000 (UTC) Received: from gondolin (dhcp-192-213.str.redhat.com [10.33.192.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67E084C3; Tue, 12 Mar 2019 17:33:53 +0000 (UTC) Date: Tue, 12 Mar 2019 18:33:51 +0100 From: Cornelia Huck To: Dongli Zhang Cc: , , axboe@kernel.dk, linux-kernel@vger.kernel.org, mst@redhat.com Subject: Re: virtio-blk: should num_vqs be limited by num_possible_cpus()? Message-ID: <20190312183351.74764f4f.cohuck@redhat.com> In-Reply-To: References: Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 12 Mar 2019 17:33:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Mar 2019 10:22:46 -0700 (PDT) Dongli Zhang wrote: > I observed that there is one msix vector for config and one shared vector > for all queues in below qemu cmdline, when the num-queues for virtio-blk > is more than the number of possible cpus: > > qemu: "-smp 4" while "-device virtio-blk-pci,drive=drive-0,id=virtblk0,num-queues=6" > > # cat /proc/interrupts > CPU0 CPU1 CPU2 CPU3 > ... ... > 24: 0 0 0 0 PCI-MSI 65536-edge virtio0-config > 25: 0 0 0 59 PCI-MSI 65537-edge virtio0-virtqueues > ... ... > > > However, when num-queues is the same as number of possible cpus: > > qemu: "-smp 4" while "-device virtio-blk-pci,drive=drive-0,id=virtblk0,num-queues=4" > > # cat /proc/interrupts > CPU0 CPU1 CPU2 CPU3 > ... ... > 24: 0 0 0 0 PCI-MSI 65536-edge virtio0-config > 25: 2 0 0 0 PCI-MSI 65537-edge virtio0-req.0 > 26: 0 35 0 0 PCI-MSI 65538-edge virtio0-req.1 > 27: 0 0 32 0 PCI-MSI 65539-edge virtio0-req.2 > 28: 0 0 0 0 PCI-MSI 65540-edge virtio0-req.3 > ... ... > > In above case, there is one msix vector per queue. Please note that this is pci-specific... > > > This is because the max number of queues is not limited by the number of > possible cpus. > > By default, nvme (regardless about write_queues and poll_queues) and > xen-blkfront limit the number of queues with num_possible_cpus(). ...and these are probably pci-specific as well. > > > Is this by design on purpose, or can we fix with below? > > > diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c > index 4bc083b..df95ce3 100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -513,6 +513,8 @@ static int init_vq(struct virtio_blk *vblk) > if (err) > num_vqs = 1; > > + num_vqs = min(num_possible_cpus(), num_vqs); > + > vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL); > if (!vblk->vqs) > return -ENOMEM; virtio-blk, however, is not pci-specific. If we are using the ccw transport on s390, a completely different interrupt mechanism is in use ('floating' interrupts, which are not per-cpu). A check like that should therefore not go into the generic driver.