Re: [PATCH 04/16] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Janne Grunau
Hej, On Tue, Nov 28, 2023, at 21:49, Pasha Tatashin wrote: > Convert iommu/io-pgtable-dart.c to use the new page allocation functions > provided in iommu-pages.h. > > Signed-off-by: Pasha Tatashin > --- > drivers/iommu/io-pgtable-dart.c | 37 + > 1 file changed,

Re: [PATCH 00/16] IOMMU memory observability

2023-11-28 Thread Jason Gunthorpe
On Tue, Nov 28, 2023 at 04:30:27PM -0800, Yosry Ahmed wrote: > On Tue, Nov 28, 2023 at 4:28 PM Jason Gunthorpe wrote: > > > > On Tue, Nov 28, 2023 at 04:25:03PM -0800, Yosry Ahmed wrote: > > > > > > > Right, but as I mention above, if userspace starts depending on this > > > > > equation, we

Re: [PATCH 00/16] IOMMU memory observability

2023-11-28 Thread Yosry Ahmed
On Tue, Nov 28, 2023 at 4:28 PM Jason Gunthorpe wrote: > > On Tue, Nov 28, 2023 at 04:25:03PM -0800, Yosry Ahmed wrote: > > > > > Right, but as I mention above, if userspace starts depending on this > > > > equation, we won't be able to add any more classes of "secondary" page > > > > tables to

Re: [PATCH 00/16] IOMMU memory observability

2023-11-28 Thread Jason Gunthorpe
On Tue, Nov 28, 2023 at 04:25:03PM -0800, Yosry Ahmed wrote: > > > Right, but as I mention above, if userspace starts depending on this > > > equation, we won't be able to add any more classes of "secondary" page > > > tables to SecPageTables. I'd like to avoid that if possible. We can do > > >

Re: [PATCH 00/16] IOMMU memory observability

2023-11-28 Thread Yosry Ahmed
On Tue, Nov 28, 2023 at 3:52 PM Jason Gunthorpe wrote: > > On Tue, Nov 28, 2023 at 03:03:30PM -0800, Yosry Ahmed wrote: > > > Yes, another counter for KVM could be added. On the other hand KVM > > > only can be computed by subtracting one from another as there are only > > > two types of

Re: [PATCH 16/16] vfio: account iommu allocations

2023-11-28 Thread Jason Gunthorpe
On Tue, Nov 28, 2023 at 08:49:38PM +, Pasha Tatashin wrote: > iommu allocations should be accounted in order to allow admins to > monitor and limit the amount of iommu memory. > > Signed-off-by: Pasha Tatashin > --- > drivers/vfio/vfio_iommu_type1.c | 8 +--- > 1 file changed, 5

Re: [PATCH 09/16] iommu/iommufd: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Jason Gunthorpe
On Tue, Nov 28, 2023 at 08:49:31PM +, Pasha Tatashin wrote: > Convert iommu/iommufd/* files to use the new page allocation functions > provided in iommu-pages.h. > > Signed-off-by: Pasha Tatashin > --- > drivers/iommu/iommufd/iova_bitmap.c | 4 ++-- > 1 file changed, 2 insertions(+), 2

Re: [PATCH 08/16] iommu/fsl: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Jason Gunthorpe
On Tue, Nov 28, 2023 at 06:00:13PM -0500, Pasha Tatashin wrote: > On Tue, Nov 28, 2023 at 5:53 PM Robin Murphy wrote: > > > > On 2023-11-28 8:49 pm, Pasha Tatashin wrote: > > > Convert iommu/fsl_pamu.c to use the new page allocation functions > > > provided in iommu-pages.h. > > > > Again, this

Re: [PATCH 05/16] iommu/io-pgtable-arm-v7s: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
On Tue, Nov 28, 2023 at 6:08 PM Robin Murphy wrote: > > On 2023-11-28 10:55 pm, Pasha Tatashin wrote: > >>>kmem_cache_free(data->l2_tables, table); > > > > We only account page allocations, not subpages, however, this is > > something I was surprised about this particular

Re: [PATCH 06/16] iommu/dma: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
> > This is true, however, we want to account and observe the pages > > allocated by IOMMU subsystem for DMA buffers, as they are essentially > > unmovable locked pages. Should we separate IOMMU memory from KVM > > memory all together and add another field to /proc/meminfo, something > > like

Re: [PATCH 06/16] iommu/dma: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
On Tue, Nov 28, 2023 at 5:59 PM Robin Murphy wrote: > > On 2023-11-28 10:50 pm, Pasha Tatashin wrote: > > On Tue, Nov 28, 2023 at 5:34 PM Robin Murphy wrote: > >> > >> On 2023-11-28 8:49 pm, Pasha Tatashin wrote: > >>> Convert iommu/dma-iommu.c to use the new page allocation functions > >>>

Re: [PATCH 08/16] iommu/fsl: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
On Tue, Nov 28, 2023 at 5:53 PM Robin Murphy wrote: > > On 2023-11-28 8:49 pm, Pasha Tatashin wrote: > > Convert iommu/fsl_pamu.c to use the new page allocation functions > > provided in iommu-pages.h. > > Again, this is not a pagetable. This thing doesn't even *have* pagetables. > > Similar to

Re: [PATCH 06/16] iommu/dma: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Robin Murphy
On 2023-11-28 10:50 pm, Pasha Tatashin wrote: On Tue, Nov 28, 2023 at 5:34 PM Robin Murphy wrote: On 2023-11-28 8:49 pm, Pasha Tatashin wrote: Convert iommu/dma-iommu.c to use the new page allocation functions provided in iommu-pages.h. These have nothing to do with IOMMU pagetables, they

Re: [PATCH 05/16] iommu/io-pgtable-arm-v7s: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
> > kmem_cache_free(data->l2_tables, table); We only account page allocations, not subpages, however, this is something I was surprised about this particular architecture of why do we allocate l2 using kmem ? Are the second level tables on arm v7s really sub-page in size? Pasha

Re: [PATCH 06/16] iommu/dma: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
On Tue, Nov 28, 2023 at 5:34 PM Robin Murphy wrote: > > On 2023-11-28 8:49 pm, Pasha Tatashin wrote: > > Convert iommu/dma-iommu.c to use the new page allocation functions > > provided in iommu-pages.h. > > These have nothing to do with IOMMU pagetables, they are DMA buffers and > they belong to

Re: [PATCH 00/16] IOMMU memory observability

2023-11-28 Thread Yosry Ahmed
On Tue, Nov 28, 2023 at 12:49 PM Pasha Tatashin wrote: > > From: Pasha Tatashin > > IOMMU subsystem may contain state that is in gigabytes. Majority of that > state is iommu page tables. Yet, there is currently, no way to observe > how much memory is actually used by the iommu subsystem. > >

[PATCH 16/16] vfio: account iommu allocations

2023-11-28 Thread Pasha Tatashin
iommu allocations should be accounted in order to allow admins to monitor and limit the amount of iommu memory. Signed-off-by: Pasha Tatashin --- drivers/vfio/vfio_iommu_type1.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c

[PATCH 10/16] iommu/rockchip: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/rockchip-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/iommufd/iova_bitmap.c | 2 ++ drivers/iommu/rockchip-iommu.c | 14 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff

[PATCH 11/16] iommu/sun50i: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/sun50i-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/sun50i-iommu.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c

[PATCH 09/16] iommu/iommufd: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/iommufd/* files to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/iommufd/iova_bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommufd/iova_bitmap.c

[PATCH 08/16] iommu/fsl: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/fsl_pamu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/fsl_pamu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c index

[PATCH 06/16] iommu/dma: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/dma-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/dma-iommu.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index

[PATCH 07/16] iommu/exynos: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/exynos-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/exynos-iommu.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c

[PATCH 05/16] iommu/io-pgtable-arm-v7s: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/io-pgtable-arm-v7s.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/io-pgtable-arm-v7s.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c

[PATCH 04/16] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/io-pgtable-dart.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/io-pgtable-dart.c | 37 + 1 file changed, 14 insertions(+), 23 deletions(-) diff --git

[PATCH 02/16] iommu/amd: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/amd/* files to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/amd/amd_iommu.h | 8 --- drivers/iommu/amd/init.c | 91 ++- drivers/iommu/amd/io_pgtable.c| 13 +++--

[PATCH 01/16] iommu/vt-d: add wrapper functions for page allocations

2023-11-28 Thread Pasha Tatashin
In order to improve observability and accountability of IOMMU layer, we must account the number of pages that are allocated by functions that are calling directly into buddy allocator. This is achieved by first wrapping the allocation related functions into a separate inline functions in new

[PATCH 03/16] iommu/io-pgtable-arm: use page allocation function provided by iommu-pages.h

2023-11-28 Thread Pasha Tatashin
Convert iommu/io-pgtable-arm.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/io-pgtable-arm.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c

[PATCH 00/16] IOMMU memory observability

2023-11-28 Thread Pasha Tatashin
From: Pasha Tatashin IOMMU subsystem may contain state that is in gigabytes. Majority of that state is iommu page tables. Yet, there is currently, no way to observe how much memory is actually used by the iommu subsystem. This patch series solves this problem by adding both observability to all