Page MenuHomeFreeBSD

Tweak linux mmap address hint handling.
ClosedPublic

Authored by trasz on Jan 29 2017, 3:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 6, 7:51 AM
Unknown Object (File)
Feb 29 2024, 12:51 AM
Unknown Object (File)
Feb 27 2024, 5:18 AM
Unknown Object (File)
Feb 6 2024, 6:27 AM
Unknown Object (File)
Jan 20 2024, 10:11 AM
Unknown Object (File)
Jan 7 2024, 10:16 AM
Unknown Object (File)
Dec 20 2023, 2:33 AM
Unknown Object (File)
Dec 17 2023, 1:07 AM
Subscribers

Details

Summary

FreeBSD is free to ignore the address hint if MAP_FIXED wasn't
passed. However, some Linux applications, like the ART runtime,
depend on the hint. If the MAP_FIXED wasn't passed, but the
address is not zero, try with MAP_FIXED and MAP_EXCL first,
and fall back to the normal behaviour if that fails.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

trasz retitled this revision from to Tweak linux mmap address hint handling..
trasz updated this object.
trasz edited the test plan for this revision. (Show Details)

Dmitry, could you test it?

Also, the description should probably mention that the application that does this is the native Linux version of ART (the Android component).

FreeBSD does not ignore hint address for mmap(2). We start searching for the free gap starting at the hint, up in the direction of higher addresses. What FreeBSD does which might confuse Linux apps is the superpage alignment of the start address. Look at the sys/vm/vm_mmap.c:vm_mmap_object(), the fitit and findspace variables.

The proper solution is probably to allow your caller of vm_mmap.c to request that findspace was set to VMFS_ANY_SPACE. This would require some plumbing, but definitely it is much cleaner than MAP_EXCL hack (assuming my guess about superalign is correct).

I'm not sure if I want to clutter other parts of the system just for this. This is specific to Linux, and not even Linux in general - it's a workaround for arguably buggy behaviour of some linux apps (ART in this case). In other words it's a bug compatibility. We already have lots of those in linuxulator.

dchagin edited edge metadata.
This revision is now accepted and ready to land.Feb 18 2017, 5:02 PM
This revision was automatically updated to reflect the committed changes.