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)
Thu, May 16, 12:44 AM
Unknown Object (File)
Wed, May 8, 7:56 AM
Unknown Object (File)
Mar 17 2024, 4:56 AM
Unknown Object (File)
Mar 17 2024, 4:56 AM
Unknown Object (File)
Mar 14 2024, 12:09 PM
Unknown Object (File)
Mar 14 2024, 11:52 AM
Unknown Object (File)
Dec 29 2023, 12:08 AM
Unknown Object (File)
Dec 20 2023, 3:49 AM
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.