[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] alignalloc, xalignalloc: new modules
From: |
Paul Eggert |
Subject: |
Re: [PATCH] alignalloc, xalignalloc: new modules |
Date: |
Sun, 23 Jan 2022 20:36:30 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
On 1/23/22 16:52, Bruno Haible wrote:
- With aligned-malloc, the alignment is a compile-time constant.
Whereas with alignalloc, it is passed at runtime.
Yes, for the application I'm concerned about now (coreutils), runtime
alignment is needed.
I tried pagealign_alloc but found a couple of issues with it:
* lib/pagealign_alloc.c relies on HAVE_MMAP but the pagealign_alloc
module doesn't define HAVE_MMAP.
* I assumed that the HAVE_MMAP situation wasn't intentional, but when I
tried defining HAVE_MMAP by hand I found this caused pagealign_alloc to
issue more syscalls (mmaps) than before. It wasn't clear to me whether
the HAVE_MMAP part of pagealign_alloc is enough of a performance win
nowadays to be worth the trouble.
Nowadays I assume most platforms of interest have posix_memalign.
Although falling back on malloc on older platforms can consume up to
ALIGNMENT extra bytes per call on these platforms, that should be OK as
these platforms shouldn't be worth worrying about that much nowadays.
- aligned-malloc returns non-NULL, except when out-of-memory.
Is that true also for alignalloc?
Yes, when given valid arguments (nonnegative size and power-of-two
alignment). This is because alignalloc calls either:
* glibc aligned_alloc; or
* posix_memalign with a nonzero size; or
* malloc with a nonzero size
and all these calls return non-NULL except when out of memory.