From: Rusty Russell <rusty@rustcorp.com.au>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
anton@samba.org, KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Mike Travis <travis@sgi.com>
Cc: anton@samba.org
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Mike Travis <travis@sgi.com>
Subject: [PATCH 4/5] cpumask: remove struct cpumask definition when CONFIG_CPUMASK_OFFSTACK=y
Date: Fri, 25 Jun 2010 22:34:45 +0930 [thread overview]
Message-ID: <201006252234.46031.rusty@rustcorp.com.au> (raw)
We're about to change CONFIG_CPUMASK_OFFSTACK so it only allocate
nr_cpu_ids bits for all cpumasks. We need to make sure that when
CONFIG_CPUMASK_OFFSTACK is set:
1) Noone uses the old bitmap ops, which use NR_CPUS bits (use cpumask_*)
2) Noone uses assignment of struct cpumask (use cpumask_copy)
3) Noone passes a struct cpumask (pass a pointer)
4) Noone declares them on the stack (use cpumask_var_t)
So we finally remove the definition of struct cpumask when
CONFIG_CPUMASK_OFFSTACK=y. This means that these usages will hit a compile
error the moment that config option is turned on.
Note that it also means you can't declare a static cpumask. You
should avoid this anyway (use cpumask_var_t), but there's a
deliberately-ugly workaround for special cases, using DECLARE_BITMAP()
and to_cpumask().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: anton@samba.org
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Mike Travis <travis@sgi.com>
---
include/linux/cpumask.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -10,7 +10,15 @@
#include <linux/threads.h>
#include <linux/bitmap.h>
+#ifdef CONFIG_CPUMASK_OFFSTACK
+/*
+ * This is never declared, so you can't accidentally create one (see
+ * cpumask_var_t) or copy them by assignment (see cpumask_copy).
+ */
+struct cpumask;
+#else
typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
+#endif /* CONFIG_CPUMASK_OFFSTACK */
/**
* cpumask_bits - get the bits in a cpumask
@@ -19,7 +28,14 @@ typedef struct cpumask { DECLARE_BITMAP(
* You should only assume nr_cpu_ids bits of this mask are valid. This is
* a macro so it's const-correct.
*/
+#ifdef CONFIG_CPUMASK_OFFSTACK
+static inline unsigned long *cpumask_bits(const struct cpumask *mask)
+{
+ return (unsigned long *)mask;
+}
+#else
#define cpumask_bits(maskp) ((maskp)->bits)
+#endif
#if NR_CPUS == 1
#define nr_cpu_ids 1
reply other threads:[~2010-06-25 13:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201006252234.46031.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=anton@samba.org \
--cc=arnd@arndb.de \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=travis@sgi.com \
/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