From patchwork Mon Jul 2 14:46:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 10501641 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 EDBF56028F for ; Mon, 2 Jul 2018 14:47:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE29F28A26 for ; Mon, 2 Jul 2018 14:47:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D285128AB9; Mon, 2 Jul 2018 14:47:34 +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 7D14228A26 for ; Mon, 2 Jul 2018 14:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752431AbeGBOrc (ORCPT ); Mon, 2 Jul 2018 10:47:32 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36478 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752309AbeGBOrb (ORCPT ); Mon, 2 Jul 2018 10:47:31 -0400 Received: by mail-pf0-f195.google.com with SMTP id u16-v6so7629244pfh.3 for ; Mon, 02 Jul 2018 07:47:30 -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=UFP+52Y4Qne3VLVryXMiftpwdhoNnchA+x5iLVgj/gA=; b=azTXsnsj0OIE4kSPWO4CX0Tfh1foIHTEckWE055Usj9t3cTOstHhSidQB3rHXeLgiW z6/1obKlYZWOknmFY/eQQf33L7EPVUgAGR7P9GLM69IkfM77IItYxRV1dBv8mAb3Fe10 i7U9dhrmWIZPvdz+/P1khkq5dAprWpUZJLP1JUF5vEJHXZOTx3prha4FewdEdjdJvrke RDIhMxhPw/DNdEHXr0H9+Ngo7yZQtEMTOeYPMxBh+xx3yJvZ3R3nRstUkNtPhYYubtdb f4xjYjA0UzLoV7OrbTPnJW+ey1I1vm5/QGClAwHvQvCf26B+5DOXl6VKtqfnegvXIzPj w28A== 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=UFP+52Y4Qne3VLVryXMiftpwdhoNnchA+x5iLVgj/gA=; b=F8oP3K8bMLTdxyTR9JNDSjcWTpCQZyQWh8ivmLakqndI0KinyumaZ3gx4B2SvT7oLp POu9/+e9OYGpLEmu8Y1ZnxBfcGITxpqeaxFofRWFm4zrmHuxH1A3bW11rU4Y2dDs1Nxh lPGtJYpr4V+8C6+XbQdTte8Cgy/3WxkjtqJ/JqgD09O0PMZnfGyxF0sXgdlsdNT0y+Kq Y8HCyeo9UNV+FE+EEjUPtKMKaeOFg6zNIhRT+FQpwrpNJHGAnTf67BQSOIXksAoxnISD tj4fFOeo5CeqDfnHr9aXwdAEwIMa+AL3dupoaQrkH1ki+5vydOjM7zpNWrYgvEETHyqW GPfw== X-Gm-Message-State: APt69E058sg0VTMLqVe1eSlQcNcTiG2o27iwyysCe82zPrE4paho8zBX Q+2glHqOQh/RXX9APqXeLu1VYg== X-Google-Smtp-Source: AAOMgpdEGXhV6eSxJLVO6sWg7Qfjhza6cMHbtGMoYMAZ2w4SXYJkDclfyvtVvb3C+Qruuidiv00DYw== X-Received: by 2002:a63:c252:: with SMTP id l18-v6mr18976429pgg.76.1530542850048; Mon, 02 Jul 2018 07:47:30 -0700 (PDT) Received: from localhost.localdomain ([1.237.242.62]) by smtp.gmail.com with ESMTPSA id y2-v6sm37654646pfk.82.2018.07.02.07.47.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jul 2018 07:47:28 -0700 (PDT) From: Minwoo Im To: linux-block@vger.kernel.org Cc: Jens Axboe , Johannes Thumshirn , Minwoo Im Subject: [PATCH V3] blk-mq: code clean-up by adding an API to clear set->mq_map Date: Mon, 2 Jul 2018 23:46:43 +0900 Message-Id: <1530542803-25212-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 | 5 +++-- block/blk-mq.c | 4 +--- block/blk-mq.h | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c index e233996..db644ec 100644 --- a/block/blk-mq-pci.c +++ b/block/blk-mq-pci.c @@ -17,6 +17,8 @@ #include #include +#include "blk-mq.h" + /** * blk_mq_pci_map_queues - provide a default queue mapping for PCI device * @set: tagset to provide the mapping for @@ -48,8 +50,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/block/blk-mq.h b/block/blk-mq.h index 89231e4..1fefa11 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -203,4 +203,12 @@ static inline void blk_mq_put_driver_tag(struct request *rq) __blk_mq_put_driver_tag(hctx, 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; +} + #endif