public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Xiong Zhou <jencce.kernel@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Andreas Herrmann <aherrmann@suse.com>
Subject: Re: 4.5.0+ panic when setup loop device
Date: Thu, 17 Mar 2016 11:26:20 -0700	[thread overview]
Message-ID: <56EAF6CC.7070108@kernel.dk> (raw)
In-Reply-To: <56EADE5F.7000601@kernel.dk>

[-- Attachment #1: Type: text/plain, Size: 972 bytes --]

On 03/17/2016 09:42 AM, Jens Axboe wrote:
> On 03/17/2016 05:01 AM, Thomas Gleixner wrote:
>> On Thu, 17 Mar 2016, Peter Zijlstra wrote:
>>> On Thu, Mar 17, 2016 at 12:39:46PM +0100, Thomas Gleixner wrote:
>>>> But we have to clarify and document whether holes in
>>>> cpu_possible_mask are not
>>>> allowed at all or if code like the above is simply broken.
>>>
>>> So the general rule is that cpumasks can have holes, and exempting one
>>> just muddles the water.
>>>
>>> Therefore I'd call the code just plain broken.
>>
>> Agreed.
>>
>> That macro is not really helping the readability of the code at all. So a
>> simple for_each_possible_cpu() loop would have avoided that wreckage.
>
> Does the attached work? The rest of blk-mq should deal with holes just
> fine, we found some of those issues on sparc. Not sure why this one
> slipped through the cracks.

This might be better, we need to start at -1 to not miss the first 
one... Still untested.

-- 
Jens Axboe


[-- Attachment #2: blk-mq-discontig-v2.patch --]
[-- Type: text/x-patch, Size: 1497 bytes --]

diff --git a/block/blk-mq.h b/block/blk-mq.h
index eaede8e45c9c..ce68ceda652c 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -118,4 +118,22 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx)
 	return hctx->nr_ctx && hctx->tags;
 }
 
+static inline struct blk_mq_ctx *next_ctx(struct request_queue *q, int *i)
+{
+	do {
+		(*i)++;
+		if (*i < q->nr_queues) {
+			if (cpu_possible(*i))
+				return per_cpu_ptr(q->queue_ctx, *i);
+			continue;
+		}
+		break;
+	} while (1);
+
+	return NULL;
+}
+
+#define queue_for_each_ctx(q, ctx, i)					\
+	for ((i) = -1; (ctx = next_ctx((q), &(i))) != NULL;)
+
 #endif
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 7fc9296b5742..a8756cd00767 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -261,22 +261,8 @@ static inline void *blk_mq_rq_to_pdu(struct request *rq)
 	for ((i) = 0; (i) < (q)->nr_hw_queues &&			\
 	     ({ hctx = (q)->queue_hw_ctx[i]; 1; }); (i)++)
 
-#define queue_for_each_ctx(q, ctx, i)					\
-	for ((i) = 0; (i) < (q)->nr_queues &&				\
-	     ({ ctx = per_cpu_ptr((q)->queue_ctx, (i)); 1; }); (i)++)
-
 #define hctx_for_each_ctx(hctx, ctx, i)					\
 	for ((i) = 0; (i) < (hctx)->nr_ctx &&				\
 	     ({ ctx = (hctx)->ctxs[(i)]; 1; }); (i)++)
 
-#define blk_ctx_sum(q, sum)						\
-({									\
-	struct blk_mq_ctx *__x;						\
-	unsigned int __ret = 0, __i;					\
-									\
-	queue_for_each_ctx((q), __x, __i)				\
-		__ret += sum;						\
-	__ret;								\
-})
-
 #endif

  reply	other threads:[~2016-03-17 18:26 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16  6:48 4.5.0+ panic when setup loop device Xiong Zhou
2016-03-16 15:26 ` Thomas Gleixner
2016-03-17  1:56   ` Xiong Zhou
2016-03-17  9:52     ` Peter Zijlstra
2016-03-17  9:56       ` Peter Zijlstra
2016-03-17 10:21       ` Thomas Gleixner
2016-03-17 10:26         ` Peter Zijlstra
2016-03-17 11:39           ` Thomas Gleixner
2016-03-17 11:51             ` Peter Zijlstra
2016-03-17 11:57               ` Borislav Petkov
2016-03-17 12:01               ` Thomas Gleixner
2016-03-17 16:42                 ` Jens Axboe
2016-03-17 18:26                   ` Jens Axboe [this message]
2016-03-17 20:20                     ` Thomas Gleixner
2016-03-17 20:23                       ` Jens Axboe
2016-03-17 20:30                         ` Thomas Gleixner
2016-03-17 20:41                           ` Jens Axboe
2016-03-18  2:31             ` Xiong Zhou
2016-03-18  4:11       ` Mike Galbraith
2016-03-18  7:51         ` Peter Zijlstra
2016-03-18 10:15         ` Peter Zijlstra
2016-03-18 12:39           ` Mike Galbraith
2016-03-18 13:32             ` Peter Zijlstra
2016-03-18 14:07               ` Mike Galbraith
2016-03-18 11:55         ` Thomas Gleixner
2016-03-18 12:39           ` Mike Galbraith
2016-03-19  9:31           ` [tip:x86/urgent] x86/topology: Use total_cpus not nr_cpu_ids for logical packages tip-bot for Thomas Gleixner
2016-03-29  8:48       ` [tip:x86/urgent] x86/topology: Fix AMD core count tip-bot for Peter Zijlstra
  -- strict thread matches above, loose matches on Subject: below --
2016-03-18 15:03 [PATCH 0/3] x86 topology fixes Peter Zijlstra
2016-03-18 15:03 ` [PATCH 1/3] x86/topology: Fix logical pkg mapping Peter Zijlstra
2016-03-19  9:30   ` [tip:x86/urgent] x86/topology: Fix logical package mapping tip-bot for Peter Zijlstra
2016-03-18 15:03 ` [PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra
2016-03-18 16:41   ` Borislav Petkov
2016-03-21  3:07     ` Huang Rui
2016-03-21  3:46       ` Huang Rui
2016-03-21  8:26         ` Borislav Petkov
2016-03-21  9:18           ` Huang Rui
2016-03-21  8:56         ` Thomas Gleixner
2016-03-21  8:21       ` Peter Zijlstra
2016-03-21  9:46         ` Huang Rui
2016-03-21 13:57           ` Borislav Petkov
2016-03-22  8:10             ` Sherry Hurwitz
2016-03-22 11:22               ` Borislav Petkov
2016-03-21  8:23       ` Borislav Petkov
2016-03-21 10:05         ` Huang Rui
2016-03-21 10:23           ` Borislav Petkov
2016-03-19  9:24   ` Thomas Gleixner
2016-03-19 15:56     ` Borislav Petkov
2016-03-20 10:39     ` Peter Zijlstra
2016-03-20 11:04       ` Borislav Petkov
2016-03-20 12:32         ` Peter Zijlstra
2016-03-20 12:46           ` Peter Zijlstra
2016-03-20 13:09             ` Borislav Petkov
2016-03-20 17:08               ` Peter Zijlstra
2016-03-20 18:46                 ` Borislav Petkov
2016-03-29  8:49             ` [tip:x86/urgent] perf/x86/amd: Cleanup Fam10h NB event constraints tip-bot for Peter Zijlstra
2016-03-22  7:56   ` [PATCH 2/3] x86/topology: Fix AMD core count Huang Rui
2016-03-18 15:03 ` [PATCH 3/3] x86/topology: Fix Intel HT disable Peter Zijlstra
2016-03-19  9:31   ` [tip:x86/urgent] " tip-bot for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56EAF6CC.7070108@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=aherrmann@suse.com \
    --cc=bp@alien8.de \
    --cc=jencce.kernel@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox