[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86802c440808261008t1b66d6bpe93974be5988acab@mail.gmail.com>
Date: Tue, 26 Aug 2008 10:08:22 -0700
From: "Yinghai Lu" <yhlu.kernel@...il.com>
To: "Linus Torvalds" <torvalds@...ux-foundation.org>
Cc: "Ingo Molnar" <mingo@...e.hu>,
"David Miller" <davem@...emloft.net>, Alan.Brunelle@...com,
travis@....com, tglx@...utronix.de, rjw@...k.pl,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
kernel-testers@...r.kernel.org,
"Andrew Morton" <akpm@...ux-foundation.org>, arjan@...ux.intel.com,
rusty@...tcorp.com.au
Subject: Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
On Tue, Aug 26, 2008 at 9:51 AM, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
>
> On Tue, 26 Aug 2008, Yinghai Lu wrote:
>>
>> wonder if could use "unsigned long *" directly.
>
> I would actually suggest something like this:
>
> - we continue to have a magic "cpumask_t".
>
> - we do different cases for big and small NR_CPUS:
>
> #if NR_CPUS <= BITS_PER_LONG
>
> /*
> * Make it an array - that way passing it as an argument will
> * always pass it as a pointer!
> */
> typedef unsigned long cpumask_t[1];
>
> static inline void create_cpumask(cpumask_t *p)
> {
> *p = 0;
> }
> static inline void free_cpumask(cpumask_t *p)
> {
> }
>
> #else
>
> typedef unsigned long *cpumask_t;
>
> static inline void create_cpumask(cpumask_t *p)
> {
> *p = kcalloc(..);
> }
>
> static inline void free_cpumask(cpumask_t *p)
> {
> kfree(*p);
> }
>
> #endif
>
> and now after you do this, you can just do something like
>
> cpumask_t mycpu;
>
> create_cpumask(&mycpu);
> ..
> free_cpumask(&mycpu);
>
> and in between, you can use 'cpumask' as a pointer, because even when it
> is an array directly allocated on the stack, the array can always
> degenerate into a pointer by C type rules!
>
that is good for local variables.
for global variables, need to allocate them in some point. may need one
int cpumask_size;
cpumask_t online_cpu_map;
DEFINE_DYN_ARRAY(online_cpu_map, sizeof(unsigned long), cpumask_size,
PAGE_SIZE, NULL);
or something like that.
YH
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists