On 2020-11-06 5:14 p.m., Jason Gunthorpe wrote:
> On Fri, Nov 06, 2020 at 01:03:26PM -0700, Logan Gunthorpe wrote:
>> I don't think a function like that will work for the p2pmem use case. In
>> order to implement proper page freeing I expect I'll need a loop around
>> the allocator and vm_insert_mixed()... Something roughly like:
>>
>> for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) {
>> vaddr = pci_alloc_p2pmem(pdev, PAGE_SIZE);
>> ret = vmf_insert_mixed(vma, addr,
>> __pfn_to_pfn_t(virt_to_pfn(vaddr), PFN_DEV | PFN_MAP));
>> }
>>
>> That way we can call pci_free_p2pmem() when a page's ref count goes to
>> zero. I suspect your use case will need to do something similar.
>
> Yes, but I would say the pci_alloc_p2pmem() layer should be able to
> free pages on a page-by-page basis so you don't have to do stuff like
> the above.
>
> There is often a lot of value in having physical contiguous addresses,
> so allocating page by page as well seems poor.
Agreed. But I'll have to dig to see if genalloc supports freeing blocks
in different sizes than the allocations.
Logan
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
- Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci... Logan Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce... Jason Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PDMA: Intro... Logan Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PDMA: ... Jason Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PD... Logan Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PD... Jason Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PD... Logan Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PD... Jason Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PD... Logan Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PD... Jason Gunthorpe
- Re: [RFC PATCH 14/15] PCI/P2PD... Logan Gunthorpe
- [RFC PATCH 13/15] block: Set FOLL_PCI_P2PDMA in bio_map_... Logan Gunthorpe
- [RFC PATCH 11/15] iov_iter: Introduce iov_iter_get_pages... Logan Gunthorpe
- [RFC PATCH 12/15] block: Set FOLL_PCI_P2PDMA in __bio_io... Logan Gunthorpe
- [RFC PATCH 04/15] lib/scatterlist: Add flag for indicati... Logan Gunthorpe
- Re: [RFC PATCH 04/15] lib/scatterlist: Add flag for... Christoph Hellwig
- Re: [RFC PATCH 04/15] lib/scatterlist: Add flag... Robin Murphy
- Re: [RFC PATCH 04/15] lib/scatterlist: Add flag... Logan Gunthorpe
- Re: [RFC PATCH 04/15] lib/scatterlist: Add ... Dan Williams
- Re: [RFC PATCH 04/15] lib/scatterlist: ... Logan Gunthorpe
- Re: [RFC PATCH 04/15] lib/scatterl... Dan Williams
