On Thu, Jan 27, 2022 at 10:57:30AM +0100, Christoph Hellwig wrote: > On Thu, Jan 27, 2022 at 09:37:59AM +0000, yangx.jy@xxxxxxxxxxx wrote: > > Do you mean we have to consider that some allocated pages come from high > > memory? > > > > I think INFINIBAND_VIRT_DMA kconfig[1] has ensured that all allocated > > pages have a kernel virtual address. > > rxe and siw depend on INFINIBAND_VIRT_DMA which depends on !HIGHMEM, > so you don't need kmap here at all. Until/if I get PKS protecting pmem.[1] Then if the page is pmem, page_address() will give you an address which you will fault on when you access it. > > > In this case, is it OK to call page_address() directly? > > Yes. For now yes... But please use kmap_local_page() and it will do the right thing (by default call page_address() on !HIGHMEM systems). IMO page_address() is a hold over from a time when memory management was much simpler and, again IMO, today its use assumes too much for drivers like this. As more protections on memory are implemented it presents a series of land mines to be found. While kmap is also a hold over I'm trying to redefine it to be 'get the kernel mapping' rather than 'map this into highmem'... But perhaps I'm losing that battle... Ira [1] https://lore.kernel.org/lkml/20220127175505.851391-1-ira.weiny@xxxxxxxxx/T/#mcd60ea9a9c7b90e63b8d333c9270186fc7e47707