<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 Tue, Sep 8, 2020 at 11:36 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">Hi!<br>
> And I'd like to add the MAP_GROWSDOWN test too, but I haven't come up with<br>
> a way to solve the segment fault on s390x.<br>
> <a href="http://lists.linux.it/pipermail/ltp/2020-August/018416.html" rel="noreferrer" target="_blank">http://lists.linux.it/pipermail/ltp/2020-August/018416.html</a><br>
<br>
Maybe we end up allocating a mapping that is too close to something<br>
else, see:<br>
<br>
<a href="https://stackoverflow.com/questions/56888725/why-is-map-growsdown-mapping-does-not-grow" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/56888725/why-is-map-growsdown-mapping-does-not-grow</a><br>
<br>
I guess that we should make the initial mmap in find_free_range() larger<br>
and return and adress that is quaranteed not to have a mapping that is<br>
closer than 256 pages in the direction we want to grow.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Sounds reasonable. I tried to reserve more space for the mapping grows, and that works for me:). </div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_default" style="font-size:small">static void *find_free_range(size_t size)</div>{<br> <span class="gmail_default" style="font-size:small"> </span>void *mem;<br><br> <span class="gmail_default" style="font-size:small"> </span>/*<br> <span class="gmail_default" style="font-size:small"> </span>* To avoid the mapping grows to within a page of the high end of<br> <span class="gmail_default" style="font-size:small"> </span>* the next lower mapping, which might result in a SIGSEGV signal.<br> <span class="gmail_default" style="font-size:small"> </span>* Here reserve twifold memory spaces for growing, especially for s390x.<br> <span class="gmail_default" style="font-size:small"> </span>*/<br> <span class="gmail_default" style="font-size:small"> </span>mem = SAFE_MMAP(NULL, size * 2, PROT_READ | PROT_WRITE,<br> <span class="gmail_default" style="font-size:small"> </span>MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);<br> <span class="gmail_default" style="font-size:small"> </span>SAFE_MUNMAP(mem, size * 2);<br><br> <span class="gmail_default" style="font-size:small"> </span>return mem;<br>}<br><div class="gmail_default" style="font-size:small"></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>