From patchwork Mon Jul 2 13:45:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 10501421 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 9BB2B60325 for ; Mon, 2 Jul 2018 13:46:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D741287A5 for ; Mon, 2 Jul 2018 13:46:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01B2E28869; Mon, 2 Jul 2018 13:46:43 +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 9CDD5287A5 for ; Mon, 2 Jul 2018 13:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752167AbeGBNqn (ORCPT ); Mon, 2 Jul 2018 09:46:43 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:43757 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeGBNqm (ORCPT ); Mon, 2 Jul 2018 09:46:42 -0400 Received: by mail-pl0-f68.google.com with SMTP id c41-v6so7987627plj.10 for ; Mon, 02 Jul 2018 06:46:42 -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=+Xq79MUHBhfeJOO1W2YXI7SMPc6/em7heWbp21DmGks=; b=swUNT53tpq3rKugwRs3oA1iukpI8K/cKewZ3wGp0pkQ82D1pHU69DkF6gaGMjgv9cV OmwFlGLvg/VlNCn7sQjXe1i/FxGf6Lj6fSo2sPQdEGe9j/K4CmE7u8JkgTFtS3rSxiTR 2k+Y8il1K8IAHxqbD+avGEGT7ZCjIGw7vNjOzAnm2Bf0FViQPHlZLCc53W9xZ0lH8gBz 5XRmouXh6daC9Q2oa03/dCuBPJ1IkPq3NsXmGE6DT9S/sGJalpdkhC2hKaDTRxxWaCu8 U26BcEGktzBcPVxGBXSFvMk5ScMz6TVCBtScLtSq5VczGtHwOS7gAIJu62oGavxF0S25 w0BQ== 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=+Xq79MUHBhfeJOO1W2YXI7SMPc6/em7heWbp21DmGks=; b=RgxU7KD/fVnYd3TydaPBSKD0FZp0qudUT+gxGzoIii0hpAOd94D8MtPMCHRxw/wN0y RfYd4hPaZ7zurM5nqHPkqu5MPp6Ym6eGuQsGE99i1QmwXduRhaAJaTQq/rdhmh3+lkA4 G8vZQbRi/AwqipLoDRxnDVHgID93cGzDnVo4weymvGNFEP1nUbSbrXtjRXGMK/Yu0BZw FsrDzw84JLjIwomNWnXwgisnkepK2byaAylcAs6rQmea/3wZzouWBiRkw/wS3uG58vuy pI4mfnLl3jJPY0ZU+w0WETVJUVQq5psMWJV2vKjw1I+lScRGEmjyPZfqifT3bJmJjiGH tR7w== X-Gm-Message-State: APt69E3lqzpCLwpQhaVB4BLKcvfirhrktkmgYRcm9CrHF7TuSU+8kxit 2uKPiO3ZwUumlyqCthmcF4EaZw== X-Google-Smtp-Source: ADUXVKL1QY7M7gVicqWbzwkJ7f9LfN86Zwva3tiEA7a50D5mZaY3q4x02HNxznnR59WPsqlEVBwniQ== X-Received: by 2002:a17:902:264:: with SMTP id 91-v6mr25339388plc.341.1530539201447; Mon, 02 Jul 2018 06:46:41 -0700 (PDT) Received: from localhost.localdomain ([1.237.242.62]) by smtp.gmail.com with ESMTPSA id r4-v6sm7434100pfj.53.2018.07.02.06.46.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jul 2018 06:46:40 -0700 (PDT) From: Minwoo Im To: linux-block@vger.kernel.org Cc: Jens Axboe , Johannes Thumshirn , Minwoo Im Subject: [PATCH V2] blk-mq: code clean-up by adding an API to clear set->mq_map Date: Mon, 2 Jul 2018 22:45:50 +0900 Message-Id: <1530539150-9591-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 Reviewed-by: Johannes Thumshirn --- block/blk-mq-pci.c | 3 +-- block/blk-mq.c | 4 +--- include/linux/blk-mq.h | 8 ++++++++ 3 files changed, 10 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..c6bab3f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2675,7 +2675,6 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) 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 +2689,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..a8ac78f 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -237,6 +237,14 @@ enum { u32 blk_mq_unique_tag(struct request *rq); +static inline void blk_mq_clear_mq_map(struct blk_mq_tag_set *set) +{ + int cpu; + + for_each_possible_cpu(cpu) + set->mq_map[cpu] = 0; +} + static inline u16 blk_mq_unique_tag_to_hwq(u32 unique_tag) { return unique_tag >> BLK_MQ_UNIQUE_TAG_BITS;