[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090508190944.GB12130@elte.hu>
Date: Fri, 8 May 2009 21:09:44 +0200
From: Ingo Molnar <mingo@...e.hu>
To: Jeff Garzik <jeff@...zik.org>,
Rusty Russell <rusty@...tcorp.com.au>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Mike Travis <travis@....com>
Cc: LKML <linux-kernel@...r.kernel.org>, viro@...iv.linux.org.uk,
Andrew Morton <akpm@...ux-foundation.org>, roland@...hat.com
Subject: Re: [RFC PATCH 2/2] kernel/sched.c: VLA in middle of struct
* Jeff Garzik <jeff@...zik.org> wrote:
> The semantics for variable-length arrays __in the middle of structs__
> are quite muddy, and a case in sched.c presents an interesting case,
> as the preceding code comment indicates:
>
> /*
> * The cpus mask in sched_group and sched_domain hangs off
> the end. * FIXME: use cpumask_var_t or dynamic percpu alloc
> to avoid * wasting space for nr_cpu_ids < CONFIG_NR_CPUS. */
> struct static_sched_group {
> struct sched_group sg; DECLARE_BITMAP(cpus,
> CONFIG_NR_CPUS);
> };
>
> struct static_sched_domain {
> struct sched_domain sd; DECLARE_BITMAP(span,
> CONFIG_NR_CPUS);
> };
>
> Both sched_group and sched_domain have the following trailing struct
> member:
>
> unsigned long cpumask[];
>
> So this change is intended largely to spawn a discussion, because
> I'm not sure this VLA-in-middle-of-struct behavior is guaranteed to
> always behave as expected?
>
> Maybe a C expert can say whether cpumask[0] is better than cpumask[],
> or have other comments?
This bit of the code is a bit temporary, with a half-done cpumask
conversion ...
I'm not convinced at all that this code wants to be converted to
cpuvar_t. These are all either statically percpu or dynamically
allocated structures, so we wont allocate NR_CPUS of them. So i'd
lean towards embedding a full struct cpumask and that's it.
That cpumask[] should probably be cpumask[0], to document the
aliasing to ->span and ->cpus properly.
Rusty, what do you think?
Ingo
--
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