[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shrinking stack
>
> The stack space will remain at 400kB even if the rest of the program only
> needs up to 10kB. (I have a patch to view the unused stack through /proc)
Only if you ever touch the stack page, will it be allocated. Else, no
physical page is associated. And if the kernel runs low on memory, it
will reclaim rarely accessed pages.
> I've implemented a patch where the kernel provides the vma->vm_start of
> the stack area through prctl() syscall. Its very simple and adds very
> little to the kernel code.
I believe there is only one foolproof method of determing the stack.
And that is by looking at the user's esp. (Programs probably might
have multiple stack segments, maybe even switch between them by
modifying esp ... in extreme cases. Not sure how pthreads work in
this respect.)
Thus, instead of having the kernel do this, you can do this in
userland by getting /proc/pid/maps, then identifying the vma that
contains the current value of esp. (To get the esp, you can either
write processor specific code, or maybe get the address of a variable
on stack).
Kanoj
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/