Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-19 Thread Jason Gunthorpe via iommu
On Thu, Jun 16, 2022 at 10:27:02AM +0800, Baolu Lu wrote: > On 2022/6/15 23:40, Jason Gunthorpe wrote: > > On Fri, Jun 10, 2022 at 01:37:20PM +0800, Baolu Lu wrote: > > > On 2022/6/9 20:49, Jason Gunthorpe wrote: > > > > > +void iommu_free_pgtbl_pages(struct iommu_domain *domain, > > > > > +

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-15 Thread Baolu Lu
On 2022/6/15 23:40, Jason Gunthorpe wrote: On Fri, Jun 10, 2022 at 01:37:20PM +0800, Baolu Lu wrote: On 2022/6/9 20:49, Jason Gunthorpe wrote: +void iommu_free_pgtbl_pages(struct iommu_domain *domain, + struct list_head *pages) +{ + struct page *page, *next; + +

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-15 Thread Jason Gunthorpe via iommu
On Fri, Jun 10, 2022 at 01:37:20PM +0800, Baolu Lu wrote: > On 2022/6/9 20:49, Jason Gunthorpe wrote: > > > +void iommu_free_pgtbl_pages(struct iommu_domain *domain, > > > + struct list_head *pages) > > > +{ > > > + struct page *page, *next; > > > + > > > + if

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-10 Thread Baolu Lu
On 2022/6/10 01:06, Raj, Ashok wrote: On Thu, Jun 09, 2022 at 03:08:10PM +0800, Lu Baolu wrote: The IOMMU page tables are updated using iommu_map/unmap() interfaces. Currently, there is no mandatory requirement for drivers to use locks to ensure concurrent updates to page tables, because it's

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-10 Thread Baolu Lu
On 2022/6/9 21:32, Jason Gunthorpe wrote: On Thu, Jun 09, 2022 at 02:19:06PM +0100, Robin Murphy wrote: Is there a significant benefit to keeping both paths, or could we get away with just always using RCU? Realistically, pagetable pages aren't likely to be freed all that frequently, except

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-09 Thread Baolu Lu
On 2022/6/9 20:49, Jason Gunthorpe wrote: +void iommu_free_pgtbl_pages(struct iommu_domain *domain, + struct list_head *pages) +{ + struct page *page, *next; + + if (!domain->concurrent_traversal) { + put_pages_list(pages); +

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-09 Thread Raj, Ashok
On Thu, Jun 09, 2022 at 03:08:10PM +0800, Lu Baolu wrote: > The IOMMU page tables are updated using iommu_map/unmap() interfaces. > Currently, there is no mandatory requirement for drivers to use locks > to ensure concurrent updates to page tables, because it's assumed that > overlapping IOVA

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-09 Thread Jason Gunthorpe via iommu
On Thu, Jun 09, 2022 at 02:19:06PM +0100, Robin Murphy wrote: > Is there a significant benefit to keeping both paths, or could we get away > with just always using RCU? Realistically, pagetable pages aren't likely to > be freed all that frequently, except perhaps at domain teardown, but that >

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-09 Thread Robin Murphy
On 2022-06-09 13:49, Jason Gunthorpe wrote: On Thu, Jun 09, 2022 at 03:08:10PM +0800, Lu Baolu wrote: The IOMMU page tables are updated using iommu_map/unmap() interfaces. Currently, there is no mandatory requirement for drivers to use locks to ensure concurrent updates to page tables, because

Re: [RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-09 Thread Jason Gunthorpe via iommu
On Thu, Jun 09, 2022 at 03:08:10PM +0800, Lu Baolu wrote: > The IOMMU page tables are updated using iommu_map/unmap() interfaces. > Currently, there is no mandatory requirement for drivers to use locks > to ensure concurrent updates to page tables, because it's assumed that > overlapping IOVA

[RFC PATCHES 1/2] iommu: Add RCU-protected page free support

2022-06-09 Thread Lu Baolu
The IOMMU page tables are updated using iommu_map/unmap() interfaces. Currently, there is no mandatory requirement for drivers to use locks to ensure concurrent updates to page tables, because it's assumed that overlapping IOVA ranges do not have concurrent updates. Therefore the IOMMU drivers