lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090510150954.GA21561@havoc.gtf.org>
Date:	Sun, 10 May 2009 11:09:54 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	Rusty Russell <rusty@...tcorp.com.au>
Cc:	Ingo Molnar <mingo@...e.hu>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Mike Travis <travis@....com>,
	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

On Sun, May 10, 2009 at 06:19:40PM +0930, Rusty Russell wrote:
> On Sat, 9 May 2009 04:39:44 am Ingo Molnar wrote:
> > * 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);
> > > 	};
> 
> Yeah, it's kinda nasty.  Generally, sched_group is dynamically allocated,
> so we just allocate sizeof(struct sched_group) + size of nr_cpu_ids bits.
> 
> These ones are static, and it was easier to put this hack in than make them 
> dynamic.  There's nothing wrong with it, until we really want NR_CPUS ==
> bignum, or we want to get rid of NR_CPUS altogether for 
> CONFIG_CPUMASKS_OFFSTACK (which would be very clean, but not clearly 
> worthwhile).

Nothing wrong with it, except

- C99 only defines variable-length automatic arrays
- VLA in the middle of a struct are difficult to optimize
- gcc's VLA handling WILL change, as gcc docs state
- other compilers -- and sparse -- puke all over VLAs, making
  static analysis impossible for all code with this weirdism


> But more importantly, my comment is obviously unclear, since your patch shows 
> you didn't understand the purpose of the field: The cpus bitmap *is* the sg-
> >cpumask[] array.

I guess you missed the
(1) "this patch is only intended to spark discussion",
(2) a reference to the comment, and
(3) "NOT-signed-off-by" portions of my email.

Regards,

	Jeff



--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ