Page MenuHomeFreeBSD

Make rtld use read(2) instead of mmap(2) for ELF headers
Needs ReviewPublic

Authored by trasz on Nov 18 2017, 10:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 4:10 PM
Unknown Object (File)
Feb 11 2024, 9:29 AM
Unknown Object (File)
Dec 20 2023, 2:01 AM
Unknown Object (File)
Sep 30 2023, 9:11 AM
Unknown Object (File)
Aug 9 2023, 10:41 PM
Unknown Object (File)
Apr 25 2023, 1:35 PM
Unknown Object (File)
Nov 28 2022, 2:17 AM
Unknown Object (File)
Nov 27 2022, 6:41 AM
Subscribers

Details

Reviewers
kib
Summary

Make rtld use read(2) instead of mmap(2) for ELF headers. This results
in one fewer syscall per shared object. It's similar to Linux behaviour.
On amd64 it results in a rather trivial performance gain - ~0.1% faster
time for a binary that's linked against five libraries and doesn't do
much otherwise.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 12826
Build 13090: arc lint + arc unit

Event Timeline

Using read means that the you use twice as much memory, and due to the malloc() internals, the allocated memory is not returned to the system. Mmaped page is remapped when the text is mapped, and de-facto prefaulted.

Why twice?

As for returning the memory - yup, it's additional 4kB of swap per process. Still, I believe the relative overhead of the calls to munmap(2) removed is larger.