Page MenuHomeFreeBSD

vm: pair up conversion macros
Needs ReviewPublic

Authored by dougm on Thu, May 16, 7:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 9, 1:29 PM
Unknown Object (File)
Sun, May 26, 8:40 PM
Unknown Object (File)
Wed, May 22, 3:02 AM
Unknown Object (File)
Tue, May 21, 8:55 PM
Unknown Object (File)
Sun, May 19, 5:00 PM
Unknown Object (File)
Sat, May 18, 7:05 AM
Unknown Object (File)
Thu, May 16, 10:56 PM

Details

Reviewers
alc
andrew
manu
Group Reviewers
bhyve
Summary

In the vm domain, where a pair of macros are frequently composed, with inner macro transforming one type to another and then the outer macro transforming that to a third type, define some macros to combine the transformations and allow shorter lines that use them.

Specifically, define VM_PAGE_TO_DMAP and DMAP_TO_VM_PAGE to transform back and forth via the intermediate type PHYS, and use the new macros everywhere they apply. For riscv and arm64 specifically, define PTE_TO_DMAP to compose a pair of transformations via PHYS, and use them where feasible.

Test Plan

Kernels for i386, amd64, powerpc, riscv and arm64 have been compiled successfully.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Thu, May 16, 7:46 AM
bz added inline comments.
sys/compat/linuxkpi/common/src/linux_page.c
207

@markj seems this was added after my initial PAGE_IS_LKPI_PAGE pass.
@dougm can we leave the temp variable please as in the future linux_free_pages may accept a real struct page and not a vm_page_t

mhorne added inline comments.
sys/amd64/acpica/acpi_wakeup.c
348

Passing the type as an argument is not a win for readability, IMO. I suggest simply casting where needed, as the resulting line length is the same.

Make changes to address feedback.

sys/amd64/acpica/acpi_wakeup.c
348

To be honest, I don't really like this ASSIGN_VM_PAGE_TO_DMAP. It's a strange syntax for assigning to a local variable. It looks as though it's performing some kind of global operation under the hood.

sys/vm/vm.h
61

If you're trying to simply avoid casting, why not make this new VM_PAGE_TO_DMAP() return a (void *)?