From patchwork Mon Jul 2 13:27:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 10501349 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 48B2D60362 for ; Mon, 2 Jul 2018 13:27:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A297328A21 for ; Mon, 2 Jul 2018 13:27:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94CC028A29; Mon, 2 Jul 2018 13:27:07 +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=-7.9 required=2.0 tests=BAYES_00, 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 3111828A21 for ; Mon, 2 Jul 2018 13:27:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751761AbeGBN1G (ORCPT ); Mon, 2 Jul 2018 09:27:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:43878 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751279AbeGBN1G (ORCPT ); Mon, 2 Jul 2018 09:27:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 29270AD2A; Mon, 2 Jul 2018 13:27:05 +0000 (UTC) Date: Mon, 2 Jul 2018 15:27:04 +0200 From: Johannes Thumshirn To: Minwoo Im Cc: linux-block@vger.kernel.org, Jens Axboe Subject: Re: [PATCH] blk-mq: code clean-up by adding an API to clear set->mq_map Message-ID: <20180702132704.3nwi4y6ex6fn5z67@linux-x5ow.site> References: <1530375699-20461-1-git-send-email-minwoo.im.dev@gmail.com> <20180702081539.z5rj6wfh6v4zz6bv@linux-x5ow.site> <1530536157.13674.4.camel@gmail.com> <20180702130227.gjpblurxccjqechl@linux-x5ow.site> <1530537603.13674.8.camel@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1530537603.13674.8.camel@gmail.com> User-Agent: NeoMutt/20170912 (1.9.0) 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 On Mon, Jul 02, 2018 at 10:20:03PM +0900, Minwoo Im wrote: [...] > > You could still evaluate if it isn't worth to make it: > > +static void blk_mq_clear_mq_map(struct blk_mq_tag_set *set) > > +{ > > + int cpu; > > + > > + for_each_possible_cpu(cpu) > > + set->mq_map[cpu] = 0; > > +} > > > > and put it into 'include/linux/blk-mq.h'. > > Do you mean this whole bunch of function should be moved into blk-mq.h with > 'inline' format? yes > I have already added this function prototype to blk-mq.h without 'static' to > make blk-mq-pci.c to use it. The function itself is pretty small and you use it in two different files, so I'd make it an inline function in blk-mq.h, like this: diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c index e233996bb76f..ccb9d7e9adbd 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 95919268564b..664c3817545b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2687,7 +2687,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: @@ -2702,8 +2701,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 e3147eb74222..a8ac78faa2fc 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;