Page MenuHomeFreeBSD

vm: Fix address hints of 0 with MAP_32BIT
ClosedPublic

Authored by alc on Aug 9 2023, 6:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 25 2024, 12:24 AM
Unknown Object (File)
Sep 24 2024, 10:17 AM
Unknown Object (File)
Sep 22 2024, 12:08 AM
Unknown Object (File)
Sep 8 2024, 12:10 PM
Unknown Object (File)
Sep 8 2024, 9:25 AM
Unknown Object (File)
Sep 8 2024, 4:41 AM
Unknown Object (File)
Aug 19 2024, 8:28 PM
Unknown Object (File)
Aug 19 2024, 6:28 PM
Subscribers

Details

Summary

Also, I want to rename min_addr to default_addr, which I contend better reflects what it represents. The min_addr is not a minimum address in the same way that max_addr is actually a maximum address that can be allocated. For example, a non-zero hint can be less than min_addr and be allocated.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

alc requested review of this revision.Aug 9 2023, 6:14 PM
alc created this revision.
alc added reviewers: kib, markj, dchagin.
alc edited the summary of this revision. (Show Details)
markj added inline comments.
sys/vm/vm_mmap.c
1638

Should we try to avoid the unnecessary calculation when MAP_32BIT is set?

#ifdef MAP_32BIT
if ((flags & MAP_32BIT) != 0)
    default_addr = 0;
else
#endif
    default_addr = round_page(...
This revision is now accepted and ready to land.Aug 9 2023, 8:34 PM
sys/vm/vm_mmap.c
1638

My assumption is that MAP_32BIT is rarely used. Handling MAP_32BIT in this way leads the compiler to generate a conditional move instruction rather than a conditional branch.

Thank you for fixing this

sys/vm/vm_mmap.c
1633

btw, Is this cast really necessary?

sys/vm/vm_mmap.c
1633

Yes, it is. vm_daddr_t is a caddr_t. The implementation of round_page() is machine-dependent. On some architectures, it internally casts its argument to an unsigned long. On the other architectures, where it doesn't have that internal cast, there will be a compilation error.

This revision was automatically updated to reflect the committed changes.