[llvmlinux] Can alloca() be used in the kernel instead of VLAIS or VLA?
viniciustinti at gmail.com
Mon Feb 2 21:31:43 UTC 2015
On Mon, Feb 2, 2015, 18:22 Behan Webster <behanw at converseincode.com> wrote:
On 02/02/15 15:04, David Woodhouse wrote:
> On Mon, 2015-02-02 at 20:28 +0100, Behan Webster wrote:
>>> The real reason we don't use alloca() in the kernel is because the
>>> kernel has very limited stack space.
>> That makes sense.
>> Though for a similarly sized piece of memory you would allocate as an
>> automatic variable, wouldn't alloca then also be okay?
> You might possibly think that. It might even seem logical.
> But alloc() screams "HAHA I AM ALLOCATING VARIABLY-SIZED STUFF ON THE
> STACK. LOOK AT ME. WHAT BOUNDS ARE THERE ON THE SIZE OF THIS OBJECT?" in
> a way that VLAIS does not.
> So if you're "fixing" the VLAIS, sometimes you might get prodded to fix
> it *differently* rather than just changing it to alloca().
That makes sense.
We certainly haven't used alloca so far in our efforts. For small things
we've used automatic variables (for things which are guaranteed to
always be small) and for larger things kmalloc.
behanw@ <behanw at converseincode.com>converseincode.com
<behanw at converseincode.com>
How different is a VLA from VLAIS or alloca? Can/should we use it for
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the LLVMLinux