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=-8.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,T_DKIMWL_WL_HIGH,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 A63ECC04AB1 for ; Thu, 9 May 2019 18:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6ECE8217F5 for ; Thu, 9 May 2019 18:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557427744; bh=E+ykIYYUrQjojjmCEIaMF/p9FlFHiedvAriHI6DW6HI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Tx4Lo3J1uBkZXSu0MHLfun+iMNHcpoO4XavtYH+F6bnbiarYUPryQKcUhwV3tvh06 YhfrI7fl2023ZZX0+7vAM8x9z73P6Y6/sTZ9SJLzUgey2ScyqJtllinDz4oF5NX/uO HJjxsmHK4BuhzTDZkD9c0B25+XBCUUViyXdHIrOI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728160AbfEIStD (ORCPT ); Thu, 9 May 2019 14:49:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:42232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728140AbfEIStA (ORCPT ); Thu, 9 May 2019 14:49:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73B932182B; Thu, 9 May 2019 18:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557427739; bh=E+ykIYYUrQjojjmCEIaMF/p9FlFHiedvAriHI6DW6HI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GQJSbCsasN05gfyyZeoiGxI+Xq20x9dGu6jr0lz7dHXQLmEqpZX/PvKIBNFc5pZiN PGlGPSrCl1oSlceUwWCunUUlPa54FRHtfB4RhNn8b3tNT5Y7OTNomRx67apCmSSDlm er9q6ZGENKh1XpXZ5BnfmWlVBI8GojzjVQI/mpiQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Hajnoczi , Dongli Zhang , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 45/66] virtio-blk: limit number of hw queues by nr_cpu_ids Date: Thu, 9 May 2019 20:42:20 +0200 Message-Id: <20190509181306.582804242@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190509181301.719249738@linuxfoundation.org> References: <20190509181301.719249738@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 23752dc99b008..dd64f586679e1 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -446,6 +446,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.20.1