Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5169329img; Wed, 27 Mar 2019 03:34:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaovK+CRjc3NksSzUJzNSrewkWEdlpRn/RLDuKHsUM/blQLNoFfBcKQkNZODMK3U3PkIzk X-Received: by 2002:a63:d158:: with SMTP id c24mr33143031pgj.34.1553682845196; Wed, 27 Mar 2019 03:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553682845; cv=none; d=google.com; s=arc-20160816; b=tAp+u1OlARhRFzhoHw35jGxm4hFgugtsdQ7xcu/DWSgStO1r5E+WmlJit7b0DR7mIj dMhkZhCzblBnP7qq7soh388MzAlWqBmjp5kqAlun6j/LD/6DMl1UHp5ncwiJ/h3iXGVA cCvALx1Q4N5BRzj1TqvcH37dtkNKRo1AM52AWCraQ2upbvfFGT1skPkv2khPrvw18V0M gvvRXXVpJYV0RWljcJek8oSU6h9TUtqy15uhjEclubzqMFjIarIfzyu7dOrT+GvNVl6s s247Dsw9VssOyFwUDhALo4PjLWNSgtytmaiNsaGm65sW70TqeW2vvqVCxa6A3jeDTv1V 5ojg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=UanlgyRsn8KS0BUXw3f8IMZ2WLLwxWCJmFoxsbS/mKA=; b=vCq19I7uyfNjYf9YpDB1kIcumTcelDqOc/OTaTmFV8mqWnO3Blw2Y2hruJmD8tZq1w 6ve3xq7/ujtW8ZgAEcIvenkuYMBPT3S68MtPrJzN0EPAtbAPZ07MhazL5VaB1275uZOW DV6/jnj7+qglEyeZIt944v7opleSAUhKGn0rp8Ui0B6oEOl887HB6Gh6eonVIWURiViN /eQwqtMolrBzYES2TvTRQEStDfy5WpnG2A/B3b/mcKx63FBHHi2NZkvWGrja5zsQgbqb YbrbAdGlvqkmn2FcGeawpr+liLMtX3LvbXCpNA6sM2ddMlbuAJR7aHkEQNFN5iI7JaQ/ +Snw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=tl5WhkVm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si7524405pfa.59.2019.03.27.03.33.49; Wed, 27 Mar 2019 03:34:05 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=tl5WhkVm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732380AbfC0Kcs (ORCPT + 99 others); Wed, 27 Mar 2019 06:32:48 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47828 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbfC0Kcs (ORCPT ); Wed, 27 Mar 2019 06:32:48 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2RADY8c051601; Wed, 27 Mar 2019 10:32:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=UanlgyRsn8KS0BUXw3f8IMZ2WLLwxWCJmFoxsbS/mKA=; b=tl5WhkVmTNN1T8YdSs18dIfw/HcL919a8OhufD4fIc/Pvv22LkBjTInXLQj/4fF70p/c L7PZWmZEOZrJIf132i94bQy4+c6eNlvH96vlncDIEER9w9fNvufnv3UNGC9EsHLwLYg/ zpHzaP1XBTivhJuVip0Q0N5beD48glPXkMzmooPK7AaRJ6TUcEErxKQVecCAhrMopXET kpRXLrYt/TPy14tVxUWwwoHjcXuMdUMB3Ab+lCUpmHoIQdSR//1iXUfu5cwpZxxhTMrk a47/Z7kz4++1Vr+9UcS3o43cEaQmJqx7suCuwHvxS+iOkpl41NxAT+3OlmA+mn26lzCU mg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2re6djfr0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2019 10:32:42 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2RAWfG4019934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2019 10:32:41 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2RAWfFZ010483; Wed, 27 Mar 2019 10:32:41 GMT Received: from linux.cn.oracle.com (/10.182.69.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 27 Mar 2019 03:32:40 -0700 From: Dongli Zhang To: linux-scsi@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org Cc: mst@redhat.com, jasowang@redhat.com, axboe@kernel.dk, jejb@linux.ibm.com, martin.petersen@oracle.com, cohuck@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] virtio-blk: limit number of hw queues by nr_cpu_ids Date: Wed, 27 Mar 2019 18:36:34 +0800 Message-Id: <1553682995-5682-2-git-send-email-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553682995-5682-1-git-send-email-dongli.zhang@oracle.com> References: <1553682995-5682-1-git-send-email-dongli.zhang@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9207 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903270074 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When tag_set->nr_maps is 1, the block layer limits the number of hw queues by nr_cpu_ids. No matter how many hw queues are used by virtio-blk, as it has (tag_set->nr_maps == 1), it can use at most nr_cpu_ids hw queues. In addition, specifically for pci scenario, when the 'num-queues' specified by qemu is more than maxcpus, virtio-blk would not be able to allocate more than maxcpus vectors in order to have a vector for each queue. As a result, it falls back into MSI-X with one vector for config and one shared for queues. Considering above reasons, this patch limits the number of hw queues used by virtio-blk by nr_cpu_ids. Signed-off-by: Dongli Zhang --- drivers/block/virtio_blk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 4bc083b..b83cb45 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_t(unsigned int, nr_cpu_ids, num_vqs); + vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL); if (!vblk->vqs) return -ENOMEM; -- 2.7.4