From patchwork Wed Jun 8 19:48:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lin X-Patchwork-Id: 9165633 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 C617760890 for ; Wed, 8 Jun 2016 19:49:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6733282ED for ; Wed, 8 Jun 2016 19:49:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A55A627248; Wed, 8 Jun 2016 19:49:15 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 1F1EA28303 for ; Wed, 8 Jun 2016 19:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755470AbcFHTtH (ORCPT ); Wed, 8 Jun 2016 15:49:07 -0400 Received: from mail.kernel.org ([198.145.29.136]:60142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1425774AbcFHTtD (ORCPT ); Wed, 8 Jun 2016 15:49:03 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66A312034F; Wed, 8 Jun 2016 19:49:01 +0000 (UTC) Received: from localhost.localdomain (unknown [159.203.220.84]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A07B202FF; Wed, 8 Jun 2016 19:49:00 +0000 (UTC) From: Ming Lin To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Cc: Christoph Hellwig , Keith Busch , Jens Axboe , James Smart Subject: [PATCH 1/2] blk-mq: add a function to return number of hw queues mapped Date: Wed, 8 Jun 2016 15:48:11 -0400 Message-Id: <1465415292-9416-2-git-send-email-mlin@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465415292-9416-1-git-send-email-mlin@kernel.org> References: <1465415292-9416-1-git-send-email-mlin@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP 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 From: Ming Lin Signed-off-by: Ming Lin --- block/blk-mq.c | 15 +++++++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 16 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index b59d2ef..4c80046 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1888,6 +1888,21 @@ static void blk_mq_map_swqueue(struct request_queue *q, } } +/* The number of hw queues that are mapped by sw queues */ +int blk_mq_hctx_mapped(struct request_queue *q) +{ + struct blk_mq_hw_ctx *hctx; + unsigned int i; + int mapped = 0; + + queue_for_each_hw_ctx(q, hctx, i) + if (blk_mq_hw_queue_mapped(hctx)) + mapped++; + + return mapped; +} +EXPORT_SYMBOL_GPL(blk_mq_hctx_mapped); + static void queue_set_hctx_shared(struct request_queue *q, bool shared) { struct blk_mq_hw_ctx *hctx; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 9a5d581..7cc4d51 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -250,6 +250,7 @@ void blk_mq_freeze_queue_start(struct request_queue *q); int blk_mq_reinit_tagset(struct blk_mq_tag_set *set); void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues); +int blk_mq_hctx_mapped(struct request_queue *q); /* * Driver command data is immediately after the request. So subtract request