public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	"linux-kernel@vger.kernel.org List"
	<linux-kernel@vger.kernel.org>, Dave Jones <davej@redhat.com>,
	mingo@kernel.org, "Liu, Chuansheng" <chuansheng.liu@intel.com>,
	vapier@gentoo.org, rusty@rustcorp.com.au
Subject: Re: sched: WARNING: at include/linux/cpumask.h:108 select_fallback_rq+0x241/0x280()
Date: Sat, 14 Apr 2012 20:12:19 +0200	[thread overview]
Message-ID: <1334427139.2528.110.camel@twins> (raw)
In-Reply-To: <CA+1xoqe6UL36=F2mg8cYJsyW9_kxjmdX-H=khdKmbhg+mEpbmw@mail.gmail.com>

On Sat, 2012-04-14 at 13:40 +0200, Sasha Levin wrote:
> On Sat, Apr 14, 2012 at 11:17 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Sat, 2012-03-31 at 13:22 +0530, Srivatsa S. Bhat wrote:
> >>
> >> One of the perils of using macros instead of true function calls :-(
> >>
> > You can do type checking in macros too, its not pretty, but there's
> > several such things already, see min()/max() for example.
> 
> Would it make sense to somehow standardize type checking in kernel
> macros? Possibly a set of wrappers that would make type checking easy
> to get into new and existing macros?


I had a quick go with the below and that doesn't quite work for no
obvious reasons as of yet.. Also, that call out to cpumask_next() should
already do type validation for us, so still no clue why my earlier code
compiled at all.

---
 include/linux/cpumask.h |    1 +
 include/linux/kernel.h  |   10 ++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index a2c819d..aec8355 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -201,6 +201,7 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
  * After the loop, cpu is >= nr_cpu_ids.
  */
 #define for_each_cpu(cpu, mask)				\
+	match_type(const struct cpumask *, (mask));	\
 	for ((cpu) = -1;				\
 		(cpu) = cpumask_next((cpu), (mask)),	\
 		(cpu) < nr_cpu_ids;)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 645231c..bcb7da3 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -549,6 +549,16 @@ ftrace_vprintk(const char *fmt, va_list ap)
 static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 #endif /* CONFIG_TRACING */
 
+#define match_type_type(t1, t2)			\
+do {						\
+	t1 uninitialized_var(____t1);		\
+	t2 uninitialized_var(____t2);		\
+	(void) (&____t1 == &____t2);		\
+} while (0)
+
+#define match_type(t, v)			\
+	match_type_type(t, typeof(v))
+
 /*
  * min()/max()/clamp() macros that also do
  * strict type-checking.. See the


  reply	other threads:[~2012-04-14 18:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CA+1xoqcf6qJOouKXGEHsjWSBJdA7qtMnuVopq+hoHS+TX8fvSg@mail.gmail.com>
2012-03-29 20:32 ` sched: WARNING: at include/linux/cpumask.h:108 select_fallback_rq+0x241/0x280() Sasha Levin
2012-03-30 14:10   ` Srivatsa S. Bhat
2012-03-30 14:45     ` Peter Zijlstra
2012-03-31  7:52       ` Srivatsa S. Bhat
2012-04-14  9:17         ` Peter Zijlstra
2012-04-14 11:40           ` Sasha Levin
2012-04-14 18:12             ` Peter Zijlstra [this message]
2012-04-14 18:37               ` Sasha Levin
2012-03-30 15:00     ` Sasha Levin
2012-03-31  9:46     ` [tip:sched/urgent] sched: Fix incorrect usage of for_each_cpu_mask () in select_fallback_rq() tip-bot for Srivatsa S. Bhat

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=1334427139.2528.110.camel@twins \
    --to=peterz@infradead.org \
    --cc=chuansheng.liu@intel.com \
    --cc=davej@redhat.com \
    --cc=levinsasha928@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=vapier@gentoo.org \
    /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