Page MenuHomeFreeBSD

amd64: Handle 1GB mappings in pmap_enter_quick_locked()
ClosedPublic

Authored by markj on Sep 22 2022, 11:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 11:21 AM
Unknown Object (File)
Dec 23 2023, 12:55 AM
Unknown Object (File)
Dec 12 2023, 8:50 AM
Unknown Object (File)
Dec 4 2023, 6:59 PM
Unknown Object (File)
Nov 30 2023, 10:39 PM
Unknown Object (File)
Nov 27 2023, 7:57 PM
Unknown Object (File)
Nov 19 2023, 12:44 PM
Unknown Object (File)
Nov 10 2023, 5:35 AM
Subscribers

Details

Summary

This code path can be triggered by applying MADV_WILLNEED to a 1GB
mapping.

Diff Detail

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

Event Timeline

kib added inline comments.
sys/amd64/amd64/pmap.c
7556

Remove the extra () if you are fixing style

7568
This revision is now accepted and ready to land.Sep 22 2022, 11:53 PM
sys/amd64/amd64/pmap.c
7567–7569

In the newly introduced if statement above, we already know whether pde is not NULL, but I'm pretty sure that the compiler can't infer that pmap_pdpe_to_pde(pdpe, va) cannot be NULL. For example, it doesn't know that physical page 0 is not allocatable. So, you could fold this if/else statement into the above and thereby eliminate the pde NULL check. The PHYS_TO_VM_PAGE line might be the only one that crosses 80 characters.

markj marked an inline comment as done.

Handle review comments

This revision now requires review to proceed.Sep 23 2022, 9:11 PM
sys/amd64/amd64/pmap.c
7567–7569

I rewrote this fragment to avoid needless comparisons, but I can't see a way to do so that doesn't require adding either some code duplication or an ugly goto.

Shouldn't the same change be made on arm64?

sys/amd64/amd64/pmap.c
7567–7569

In this case, I would expect the compiler to be able to deduplicate the generated code with no extra branches.

This revision is now accepted and ready to land.Sep 23 2022, 9:36 PM
In D36674#832879, @alc wrote:

Shouldn't the same change be made on arm64?

Yes, I simply haven't tested my arm64 patch yet.

As a side note, the existing regression tests for posix shared memory would have caught this if not for a bug in the test (largepage_madvise). :(