From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C11D2C43219 for ; Sat, 27 Apr 2019 01:46:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89DCA208CB for ; Sat, 27 Apr 2019 01:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556329598; bh=A+7EVeSHcLg7JD438yl89GerQ3uZicddaXRsWTqPvyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dXeyMjOiOBchtBZBU0kMcOwDp3v3nCi6CTTTfcKPV/3WR7ExWw4y02f9xc4PNsrIB bKbdB5WL9gZn0HjPik16mFV2lybq2opHLej2g8kQKFuophh5hTjhtsVhXSyLLOT0ZE abVQcmfH619rPkFqX9EZfMWOhZckTgJ0jRR8ZwUA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728770AbfD0BnV (ORCPT ); Fri, 26 Apr 2019 21:43:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:47370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728726AbfD0BnL (ORCPT ); Fri, 26 Apr 2019 21:43:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6464B215EA; Sat, 27 Apr 2019 01:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556329391; bh=A+7EVeSHcLg7JD438yl89GerQ3uZicddaXRsWTqPvyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s+TvrQ84rZ7as6KH3Ht/zvMyUBJnmWRLu1llz5v2tMNkanX40H4fAlq372wslJXb+ nGDL2odpblANFiZLMyCgls/bqTan/Cehfb+aHRjbkwzoP2gtH/m+eUIKsRiDnMwrb0 MFGhJtq4yijhmeB+oj7mlfEnJUIe+eeUpsT0OM6w= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dongli Zhang , Jens Axboe , Sasha Levin , virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 26/32] virtio-blk: limit number of hw queues by nr_cpu_ids Date: Fri, 26 Apr 2019 21:42:17 -0400 Message-Id: <20190427014224.8274-26-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190427014224.8274-1-sashal@kernel.org> References: <20190427014224.8274-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dongli Zhang [ Upstream commit bf348f9b78d413e75bb079462751a1d86b6de36c ] 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. Reviewed-by: Stefan Hajnoczi Signed-off-by: Dongli Zhang Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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 68846897d213..8767401f75e0 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -437,6 +437,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.19.1