From patchwork Sat Jun 30 16:21:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 10498299 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 3029760230 for ; Sat, 30 Jun 2018 16:21:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DA62286BE for ; Sat, 30 Jun 2018 16:21:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 109EB28754; Sat, 30 Jun 2018 16:21:50 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 A6F94286BE for ; Sat, 30 Jun 2018 16:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751460AbeF3QVs (ORCPT ); Sat, 30 Jun 2018 12:21:48 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:39984 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751162AbeF3QVs (ORCPT ); Sat, 30 Jun 2018 12:21:48 -0400 Received: by mail-pl0-f65.google.com with SMTP id t6-v6so5920150plo.7 for ; Sat, 30 Jun 2018 09:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=iTvZe4mVVXgrHMKuh/DZhTdsRW46ppOzwwIJU4tsx0Q=; b=dAXYConX6A2sTzZpU8yJHIr/4BQzapdtmKkVyKk86euiVtraU+Uhoy0vyNvdhaAsWv m3kTqG58l8ifvebclTDt/f5FVgX6B/mHXngOxiJuKV6CSxN/6xtK926sre7Uhrl4H+uG M4uSHb4y+Kwr81e3js0Wr+r9ZNOzecFdgu855U2CofmBigwn2nPz4nFDK7+f+gc1RDZO OudxhSV/6L06hMpvuzOgY7VkUgYoUT4yMNjcB/yL+bs2pWTuuS/xlfrfSodpjvO0K6mg HLmCdyvSIJRZKDpCDl3Yn2pJa981LQFTkMWgU4ptQ4mPZ5VYx4hSSIo1xbnjSQqqMBWh vHbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=iTvZe4mVVXgrHMKuh/DZhTdsRW46ppOzwwIJU4tsx0Q=; b=g0HUWH7ir9rHlSgJ/ZDHDuhOf4nstNtFzyDEZmYXeocY5/emyZMSxynzVwEdrUsjXH U+mQzQbUgSuzFVV3ddRCjPfER3M8LZ25Y/7SnKvRxdygoE15me97BRSmlRjybs+uIXLt 1hhnW3nEr09NGfx7mQ+iTgxcCd/X/M+aiyqsJnPOwk+6p4u/E2u7eEe2B/lb6iLPi79m Teji+mD3EzLXeST7eewEvsOKYLR31B3vqI0WlKA0IK4wZpRPugmknf57oANszh5PwBzy iuwuFQuOFAxYzR1j4ZyfvkuzW3SlWWD/Zt8NnN8t0Cm+YBQwVaxqg1NonDo4gw0ZJBsh OCIQ== X-Gm-Message-State: APt69E0RoaixA9lfriiDTrbHAmMrgChDPiRHzI4bYlff1JIt8tWFV+ku oRFvRF7Sv+HenYMmkHcwykc/Vg== X-Google-Smtp-Source: ADUXVKJnRPDAAwQQvrHnPkioFBwgcGfPk0vMfgPXe1fauz9CpMjZ1PBs7/TzDjd80d3g8c/jVPgRmw== X-Received: by 2002:a17:902:112b:: with SMTP id d40-v6mr19694294pla.123.1530375707267; Sat, 30 Jun 2018 09:21:47 -0700 (PDT) Received: from localhost.localdomain ([1.237.242.62]) by smtp.gmail.com with ESMTPSA id r81-v6sm13524673pfb.104.2018.06.30.09.21.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Jun 2018 09:21:46 -0700 (PDT) From: Minwoo Im To: linux-block@vger.kernel.org Cc: Jens Axboe , Minwoo Im Subject: [PATCH] blk-mq: code clean-up by adding an API to clear set->mq_map Date: Sun, 1 Jul 2018 01:21:39 +0900 Message-Id: <1530375699-20461-1-git-send-email-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.7.4 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 set->mq_map is now currently cleared if something goes wrong when establishing a queue map in blk-mq-pci.c. It's also cleared before updating a queue map in blk_mq_update_queue_map(). This patch provides an API to clear set->mq_map to make it clear. Signed-off-by: Minwoo Im --- block/blk-mq-pci.c | 3 +-- block/blk-mq.c | 13 ++++++++++--- include/linux/blk-mq.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c index e233996..ccb9d7e 100644 --- a/block/blk-mq-pci.c +++ b/block/blk-mq-pci.c @@ -48,8 +48,7 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev, fallback: WARN_ON_ONCE(set->nr_hw_queues > 1); - for_each_possible_cpu(cpu) - set->mq_map[cpu] = 0; + blk_mq_clear_mq_map(set); return 0; } EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues); diff --git a/block/blk-mq.c b/block/blk-mq.c index b429d51..c5f9ee1 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2672,10 +2672,18 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) return 0; } +void blk_mq_clear_mq_map(struct blk_mq_tag_set *set) +{ + int cpu; + + for_each_possible_cpu(cpu) + set->mq_map[cpu] = 0; +} +EXPORT_SYMBOL(blk_mq_clear_mq_map); + static int blk_mq_update_queue_map(struct blk_mq_tag_set *set) { if (set->ops->map_queues) { - int cpu; /* * transport .map_queues is usually done in the following * way: @@ -2690,8 +2698,7 @@ static int blk_mq_update_queue_map(struct blk_mq_tag_set *set) * killing stale mapping since one CPU may not be mapped * to any hw queue. */ - for_each_possible_cpu(cpu) - set->mq_map[cpu] = 0; + blk_mq_clear_mq_map(set); return set->ops->map_queues(set); } else diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index e3147eb..18390dc 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -204,6 +204,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, int blk_mq_register_dev(struct device *, struct request_queue *); void blk_mq_unregister_dev(struct device *, struct request_queue *); +void blk_mq_clear_mq_map(struct blk_mq_tag_set *set); int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set); void blk_mq_free_tag_set(struct blk_mq_tag_set *set);