On 05/01/2022 17:07, Andrew Stubbs wrote: > I don't believe 64KB will be anything like enough for any real HPC > application. Is it really worth optimizing for this case? > > Anyway, I'm working on an implementation using mmap instead of malloc > for pinned allocations. I figure that will simplify the unpin algorithm > (because it'll be munmap) and optimize for large allocations such as I > imagine HPC applications will use. It won't fix the ulimit issue. Here's my new patch. This version is intended to apply on top of the latest version of my low-latency allocator patch, although the dependency is mostly textual. Pinned memory is allocated via mmap + mlock, and allocation fails (returns NULL) if the lock fails and there's no fallback configured. This means that large allocations will now be page aligned and therefore pin the smallest number of pages for the size requested, and that that memory will be unpinned automatically when freed via munmap, or moved via mremap. Obviously this is not ideal for allocations much smaller than one page. If that turns out to be a problem in the real world then we can add a special case fairly straight-forwardly, and incur the extra page tracking expense in those cases only, or maybe implement our own pinned-memory heap (something like already proposed for low-latency memory, perhaps). Also new is a realloc implementation that works better when reallocation fails. This is confirmed by the new testcases. OK for stage 1? Thanks Andrew