diff mbox

blk-mq: code clean-up by adding an API to clear set->mq_map

Message ID 20180702132704.3nwi4y6ex6fn5z67@linux-x5ow.site (mailing list archive)
State New, archived
Headers show

Commit Message

Johannes Thumshirn July 2, 2018, 1:27 p.m. UTC
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:

Comments

Minwoo Im July 2, 2018, 1:34 p.m. UTC | #1
On Mon, 2018-07-02 at 15:27 +0200, Johannes Thumshirn wrote:
> 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

Johannes,

I was wondering you did mean 'inline' or not because the function in the
previous mail only with 'static' without 'inline' keyword :)
That's why I asked it one more time to figure out what you really mean.

I really appreciate your kindly directives.

I'll make it up for v2 patch.

Thanks, really.

	Minwoo Im
Johannes Thumshirn July 2, 2018, 1:41 p.m. UTC | #2
On Mon, Jul 02, 2018 at 10:34:19PM +0900, Minwoo Im wrote:
> I was wondering you did mean 'inline' or not because the function in the
> previous mail only with 'static' without 'inline' keyword :)
> That's why I asked it one more time to figure out what you really mean.

Ah sorry. I'm juggling too much things in parallel currently. Sorry
for that.

   Johannes
diff mbox

Patch

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;