The part about getting everything into hugepages sounds interesting. Any idea where can I find some resources on that? Most of what I was able to find only tell you how to do that for heap allocations.
Perhaps [1] is a good resource to start with (page nr. 7). Example code is here [2]. And [3] makes some experiments with it.
[1] https://www.kernel.org/doc/ols/2006/ols2006v2-pages-83-90.pd...
[2] https://github.com/intel/iodlr/blob/master/large_page-c/exam...
[3] https://easyperf.net/blog/2022/09/01/Utilizing-Huge-Pages-Fo...
Finding out the beginning of the stack should be possible to deduce from memory addresses upon entering the main().
Finding out the end of the stack depends on how big the stack is and whether it grows upwards or downwards. Former is of dynamic nature but usually configured at system level on Linux and for the latter I am not sure but I think it grows downwards.