On 2022-01-11 1:17 a.m., John Hubbard wrote:
On 1/10/22 11:34, Matthew Wilcox wrote:
TLDR: I want to introduce a new data type:
struct phyr { phys_addr_t addr; size_t len; };
and use it to replace bio_vec as well as using it to replace the array of struct pages used by get_user_pages() and friends.
This would certainly solve quite a few problems at once. Very compelling.
I agree.
Zooming in on the pinning aspect for a moment: last time I attempted to convert O_DIRECT callers from gup to pup, I recall wanting very much to record, in each bio_vec, whether these pages were acquired via FOLL_PIN, or some non-FOLL_PIN method. Because at the end of the IO, it is not easy to disentangle which pages require put_page() and which require unpin_user_page*().
And changing the bio_vec for *that* purpose was not really acceptable.
But now that you're looking to change it in a big way (and with some spare bits avaiable...oohh!), maybe I can go that direction after all.
Or, are you looking at a design in which any phyr is implicitly FOLL_PIN'd if it exists at all?
I'd also second being able to store a handful of flags in each phyr. My userspace P2PDMA patchset needs to add a flag to each sgl to indicate whether it was mapped as a bus address or not (which would be necessary for the DMA mapped side dma_map_phyr).
Though, it's not immediately obvious where to put the flags without increasing the size of the structure :(
Logan