lkml.org 
[lkml]   [2021]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p2pmem()



On 2021-09-28 2:05 p.m., Jason Gunthorpe wrote:
> On Thu, Sep 16, 2021 at 05:40:59PM -0600, Logan Gunthorpe wrote:
>
>> +static void pci_p2pdma_unmap_mappings(void *data)
>> +{
>> + struct pci_dev *pdev = data;
>> + struct pci_p2pdma *p2pdma = rcu_dereference_protected(pdev->p2pdma, 1);
>> +
>> + p2pdma->active = false;
>> + synchronize_rcu();
>> + unmap_mapping_range(p2pdma->inode->i_mapping, 0, 0, 1);
>> + pci_p2pdma_free_mappings(p2pdma->inode->i_mapping);
>> +}
>
> If this is going to rely on unmap_mapping_range then GUP should also
> reject this memory for FOLL_LONGTERM..

Right, makes sense.

>
> What along this control flow:
>
>> + error = devm_add_action_or_reset(&pdev->dev, pci_p2pdma_unmap_mappings,
>> + pdev);
>
> Waits for all the page refcounts to go to zero?

That's already in the existing code as part of memunmap_pages() which
puts the original reference to all the pages and then waits for the
reference to go to zero.

This new action unmaps all the VMAs so that the subsequent call to
memunmap_pages() doesn't block on userspace processes.

Logan

\
 
 \ /
  Last update: 2021-09-29 23:47    [W:0.142 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site