Page 3 of 3

Re: How do I keep track of which pages are free/used?

Posted: Tue Apr 06, 2021 3:29 am
by rdos
bzt wrote:Not necessarily complicated. Some architectures (like the ARM for example) provide instructions to convert virtual to physical address for you in an absolutely non-complicated way. And yes, you probably only need that when you are freeing the page tables on process exit, because most of the time you can let the MMU do the conversion for you as you don't need to know the actual physical address (only the pointed data).
I think the most common case is MMIO schedules. You have some data you want to put in a schedule, but the device uses physical addresses and not linear, and so you need to convert your buffer to a physical address. The other direction is needed when the PCI device updates the schedules and changes the lists. Then you might need to traverse the schedule, but it has physical addresses and so you need to convert those to linear to be able to follow the updated links. And if your lists are in virtual memory rather than in an identity mapping, there is really no advantage in being able to convert to the identity mapping as that doesn't tell you which object you are following.

My new USB drivers all benefit from fast conversions in both directions since I now follow the schedule links to be able to examine which requests are completed and with what state.