[llvmlinux] Can alloca() be used in the kernel instead of VLAIS or VLA?

Vinícius Tinti 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.
LOL!

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



Behan

--
Behan Webster
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
replacing VLAIS?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/llvmlinux/attachments/20150202/7fd089df/attachment-0001.html>


More information about the LLVMLinux mailing list