<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 9, 2020 at 9:13 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail_default" style="font-size:small">...</span><br>
> static void split_unmapped_plus_stack(void *start, size_t size)<br>
> {<br>
>     /* start           start + size<br>
>     * +---------------------+----------------------+-----------+<br>
>     * + unmapped            | mapped               | 256 pages |<br>
>     * +---------------------+----------------------+-----------+<br>
>     *                       stack<br>
>     */<br>
<br>
Shouldn't the 256 pages follow the unmapped part?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Yes, you're right. I made a mistake on draw that. Will fix in V4.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
If I'm not mistaken if stack grows down the address decreases with stack<br>
allocations, so it should be as:<br>
<br>
| 256 pages | unmapped | mapped |<br>
<br>
<br>
That would also mean that we should map the stack at address start +<br>
total_size - size if I'm not mistaken. I guess that we can put all the<br>
mess into a single function as well and have just allocate_stack() that<br>
will find a suitable address, mmap the stack together, splitting this<br>
into two functions is unnecessary confusing.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Good point, it makes sense to me.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
>     stack = SAFE_MMAP(start + size, size, PROT_READ | PROT_WRITE,<br>
>                              MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS |<br>
> MAP_GROWSDOWN,<br>
>                              -1, 0);<br>
> }<br>
<br>
Also I would like to get rid of the -fno-optimize-sibling-calls in the<br>
Makefile, this makes the test a bit fragile and less portable.<br>
<br>
-- <br>
Cyril Hrubis<br>
<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>