From patchwork Wed Jul 26 20:19:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9865777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0DAF4601A1 for ; Wed, 26 Jul 2017 20:19:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 027A7286C4 for ; Wed, 26 Jul 2017 20:19:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAEF1287B0; Wed, 26 Jul 2017 20:19:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 991AB286C4 for ; Wed, 26 Jul 2017 20:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750996AbdGZUTj (ORCPT ); Wed, 26 Jul 2017 16:19:39 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:55083 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbdGZUTi (ORCPT ); Wed, 26 Jul 2017 16:19:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RX1Q0V9WZMkyaDaQA1H3PsEgFJ1F7BXIPX0DqkgoC34=; b=Pq0TFf4ugFK0le8+V7yOsOe3y 6zR5zoMpHIxTUfmXKCYc+aGh+FXpBb+Bj2h6p0haqv53E67Ek8SrL7yx8afVoXvIyqm+ib2gbbMoQ XLQgc/uf6D14721Kh/hiVgUYVQcTqsAb/YldpeEI0o5FfcGNBm3QJzmlM7ZRxvO6h3Vfbhc3hUjZr olD7G1jCvHDIN67E6YEO9t1ULJ60tENyDqe1jLveFZ7C0KYoS234/6o+f6rr3/xx9E+yYiwGKFJkN ORtpViCSvY/8MJdOPkKDaGPCnkPbtYs+Ei3/72Tu28l2rBloBq5WRiBZfN33Q5i6QNDwQoxaJdJMv xQoakoARA==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1daSmO-0000rm-SC; Wed, 26 Jul 2017 20:19:37 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: shli@kernel.org, osandov@osandov.com, linux-block@vger.kernel.org Subject: [PATCH] blk-mq: provide an explicit n:1 mapping for single queue devices Date: Wed, 26 Jul 2017 22:19:34 +0200 Message-Id: <20170726201934.4940-1-hch@lst.de> X-Mailer: git-send-email 2.11.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This avoids having to deal with the nr_hw_queues = 1 case in the various queue mapping helpers by special casing it in the blk-mq core. Signed-off-by: Christoph Hellwig Reported-by: Shaohua Li --- block/blk-mq.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 041f7b7fa0d6..50d1f069d83b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2458,9 +2458,20 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) return 0; } +static int blk_mq_map_single_queue(struct blk_mq_tag_set *set) +{ + int cpu; + + for_each_possible_cpu(cpu) + set->mq_map[cpu] = 0; + return 0; +} + static int blk_mq_update_queue_map(struct blk_mq_tag_set *set) { - if (set->ops->map_queues) + if (set->nr_hw_queues == 1) + return blk_mq_map_single_queue(set); + else if (set->ops->map_queues) return set->ops->map_queues(set); else return blk_mq_map_queues(set);