<div><br><div class="gmail_quote"><div>On Sat, Mar 11, 2017 at 9:00 AM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Jeff Hammond <<a href="mailto:jeff.science@gmail.com" class="gmail_msg" target="_blank">jeff.science@gmail.com</a>> writes:<br class="gmail_msg">
> I agree 100% that multithreaded codes that fault pages from the main thread in a NUMA environment are doing something wrong ;-)<br class="gmail_msg">
><br class="gmail_msg">
> Does calloc *guarantee* pages are not mapped? If I calloc(8), do I get the zero page or part of the arena that's already mapped that is zeroed by the heap manager?<br class="gmail_msg">
<br class="gmail_msg">
Is your argument that calloc() should never be used in multi-threaded code?<br class="gmail_msg">
</blockquote><div><br></div><div>I never use it for code that I want to behave well in a NUMA environment. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg">
If the allocation is larger than MMAP_THRESHOLD (128 KiB by default for<br class="gmail_msg">
glibc) then it calls mmap.  This obviously leaves an intermediate size<br class="gmail_msg">
that could be poorly mapped (assuming 4 KiB pages), but it's also so<br class="gmail_msg">
small that it easily fits in cache.</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote><div><br></div><div>Is this behavior standardized or merely implementation-defined? I'm not interested in writing code that assumes Linux/glibc. </div><div><br></div><div>Jeff </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg">
</blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div>