Re: AC_FUNC_MMAP test fails on AIX for MAP_FIXED: who's at fault?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 29, 2024, at 9:17 AM, Bob Friesenhahn wrote:

>> I suppose that an app that needs mmap but not MAP_FIXED (which is 
>> allowed by POSIX sans XSI) could write its own special-purpose 
>> Autoconf macro for that. That being said, if you're planning to use 
>> mmap on AIX good luck; you may need it[5].

> The complaints seem to primarily be about archaic systems. 
> GraphicsMagick optionally uses mmap() for some use cases, where there is 
> substantial benefit.  There have not been any complaints about it, 
> including under IBM's AIX.  At one time (long ago) I noticed that Linux 
> was the worst performer out of the then current OSs when using mmap() 
> for file I/O. Behavior is subject to change.
>
> Regardless, using mmap() for file I/O is no magic bullet.  It transfers 
> all control to the OS, and the hardware.  The program may be 
> de-scheduled (waiting for page-in, or even page-out) when it could 
> otherwise be doing something useful.

It's not really any of autoconf's business what a program wants to use
mmap() for, _except_ insofar as it affects how autoconf probes for mmap.
I'd guess that modern software uses mmap _without_ MAP_FIXED much more
often than it uses it _with_ MAP_FIXED, which makes autoconf's insistence
on checking for XSI semantics of MAP_FIXED in its only "check for mmap"
macro a little silly.

I don't want to change what AC_FUNC_MMAP does because it seems like that
could break under-maintained old programs that _do_ expect AC_FUNC_MMAP
to check for MAP_FIXED.  However, perhaps we could have a new family of
AC_FUNC_MMAP_* macros that check for specific subsets of mmap functionality
that are generally useful, off the top of my head

- check for the basic functionality of mapping files at kernel-selected
  locations (this can probably just invoke AC_CHECK_HEADERS_ONCE([sys/mman.h])
  and AC_CHECK_FUNCS_ONCE([mmap]))

- figure out the right way to call it to request anonymous memory at a
  kernel-selected location (MAP_ANON vs MAP_ANONYMOUS vs /dev/zero)

- detect whether MAP_FIXED will replace an existing mapping, and/or
  whether MAP_FIXED_NOREPLACE exists

We should probably also document the AIX issues in the "writing portable
C programs" section of the manual if we don't already.

Can any of you think of other subsets of mmap functionality that are
worth supplying a test for in autoconf?  Do any of you have time to
work on patches for any or all of this?

zw





[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux