mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Travis <travis@sgi.com>
To: Ingo Molnar <mingo@elte.hu>, Andrew Morton <akpm@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Jack Steiner <steiner@sgi.com>,
	linux-kernel@vger.kernel.org, Paul Jackson <pj@sgi.com>,
	Bert Wesarg <bert.wesarg@googlemail.com>
Subject: [PATCH 7/8] cpumask: Provide a generic set of CPUMASK_ALLOC macros, FIXUP
Date: Fri, 18 Jul 2008 18:11:33 -0700	[thread overview]
Message-ID: <20080719011127.968788000@polaris-admin.engr.sgi.com> (raw)
In-Reply-To: <20080719011126.745278000@polaris-admin.engr.sgi.com>

[-- Attachment #1: fix-CPUMASK_ALLOC --]
[-- Type: text/plain, Size: 3204 bytes --]

  * Rename CPUMASK_VAR --> CPUMASK_PTR (and simplify)

  * Fix a semantic error in CPUMASK_ALLOC

  * Add a bit of commentry to cpumask.h

Based on linux-2.6.tip/master with the following commit:

    commit 77586c2bdad0798cb24e35de5a878e7c6b200574
    Author: Mike Travis <travis@sgi.com>  2008-07-15 14:14:37
    Committer: Ingo Molnar <mingo@elte.hu>  2008-07-18 13:03:00
    Parent: 77586c2bdad0798cb24e35de5a878e7c6b200574 (cpumask: Provide a generic set of CPUMASK_ALLOC macros)
    Child:  06f8d00e9eecb738c99b737ac38a585ea7583ad5 (cpumask: Optimize cpumask_of_cpu in lib/smp_processor_id.c, fix)
    Child:  32650cb6a8665a7635d025e52d9bf1905981ed11 (Merge branch 'cpus4096')
    Branches: -, devel, remotes/tip/cpus4096, remotes/tip/master, tip-latest

    cpumask: Provide a generic set of CPUMASK_ALLOC macros


Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Paul Jackson <pj@sgi.com>
Cc: Bert Wesarg <bert.wesarg@googlemail.com>
---
 include/linux/cpumask.h |   33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

--- linux-2.6.tip.orig/include/linux/cpumask.h
+++ linux-2.6.tip/include/linux/cpumask.h
@@ -75,16 +75,36 @@
  * CPU_MASK_NONE			Initializer - no bits set
  * unsigned long *cpus_addr(mask)	Array of unsigned long's in mask
  *
+ * CPUMASK_ALLOC kmalloc's a structure that is a composite of many cpumask_t
+ * variables, and CPUMASK_PTR provides pointers to each field.
+ *
+ * The structure should be defined something like this:
+ * struct my_cpumasks {
+ *	cpumask_t mask1;
+ *	cpumask_t mask2;
+ * };
+ *
+ * Usage is then:
+ *	CPUMASK_ALLOC(my_cpumasks);
+ *	CPUMASK_PTR(mask1, my_cpumasks);
+ *	CPUMASK_PTR(mask2, my_cpumasks);
+ *
+ *	--- DO NOT reference cpumask_t pointers until this check ---
+ *	if (my_cpumasks == NULL)
+ *		"kmalloc failed"...
+ *
+ * References are now pointers to the cpumask_t variables (*mask1, ...)
+ *
  *if NR_CPUS > BITS_PER_LONG
  *   CPUMASK_ALLOC(m)			Declares and allocates struct m *m =
- *					   (struct m *)kmalloc(sizeof(*m), ...)
- *   CPUMASK_FREE(m)			Macro for kfree(v)
+ *						kmalloc(sizeof(*m), GFP_KERNEL)
+ *   CPUMASK_FREE(m)			Macro for kfree(m)
  *else
  *   CPUMASK_ALLOC(m)			Declares struct m _m, *m = &_m
  *   CPUMASK_FREE(m)			Nop
  *endif
- *   CPUMASK_VAR(v, m)			Declares cpumask_t *v =
- *						m + offset(struct m, v)
+ *   CPUMASK_PTR(v, m)			Declares cpumask_t *v = &(m->v)
+ * ------------------------------------------------------------------------
  *
  * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
  * int cpumask_parse_user(ubuf, ulen, mask)	Parse ascii string as cpumask
@@ -326,11 +346,10 @@ extern cpumask_t cpu_mask_all;
 #define	CPUMASK_ALLOC(m)	struct m *m = kmalloc(sizeof(*m), GFP_KERNEL)
 #define	CPUMASK_FREE(m)		kfree(m)
 #else
-#define	CPUMASK_ALLOC(m)	struct allmasks _m, *m = &_m
+#define	CPUMASK_ALLOC(m)	struct m _m, *m = &_m
 #define	CPUMASK_FREE(m)
 #endif
-#define	CPUMASK_VAR(v, m) 	cpumask_t *v = (cpumask_t *)		\
-				((unsigned long)(m) + offsetof(struct m, v))
+#define	CPUMASK_PTR(v, m) 	cpumask_t *v = &(m->v)
 
 #define cpumask_scnprintf(buf, len, src) \
 			__cpumask_scnprintf((buf), (len), &(src), NR_CPUS)

-- 

  parent reply	other threads:[~2008-07-19  1:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-19  1:11 [PATCH 0/8] NR_CPUS: Various replacements for NR_CPUS Mike Travis
2008-07-19  1:11 ` [PATCH 1/8] NR_CPUS: Replace NR_CPUS in arch/x86/kernel/cpu/mcheck/mce_64.c Mike Travis
2008-07-19  1:11 ` [PATCH 2/8] NR_CPUS: Replace NR_CPUS in arch/x86/kernel/cpu/proc.c Mike Travis
2008-07-19  1:11 ` [PATCH 3/8] NR_CPUS: Replace NR_CPUS in arch/x86/kernel/genx2apic_uv_x.c Mike Travis
2008-07-19  1:11 ` [PATCH 4/8] NR_CPUS: Replace NR_CPUS in arch/x86/kernel/genapic_flat_64.c Mike Travis
2008-07-19  1:11 ` [PATCH 5/8] NR_CPUS: Replace per_cpu(..., smp_processor_id()) with __get_cpu_var Mike Travis
2008-07-19  1:11 ` [PATCH 6/8] NR_CPUS: Replace NR_CPUS in cpufreq userspace routines Mike Travis
2008-07-19  1:11 ` Mike Travis [this message]
2008-07-19  1:11 ` [PATCH 8/8] NR_CPUS: Replace NR_CPUS in speedstep-centrino.c Mike Travis
2008-07-20  8:23 ` [PATCH 0/8] NR_CPUS: Various replacements for NR_CPUS Ingo Molnar
2008-07-21 17:17   ` Mike Travis
2008-07-21 21:01     ` Mike Travis

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=20080719011127.968788000@polaris-admin.engr.sgi.com \
    --to=travis@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=bert.wesarg@googlemail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pj@sgi.com \
    --cc=steiner@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

all inboxes | Powered by JetHome®