mbox series

[v3,0/2] iommu: Allow passing custom allocators to pgtable drivers

Message ID 20231124142434.1577550-1-boris.brezillon@collabora.com (mailing list archive)
Headers show
Series iommu: Allow passing custom allocators to pgtable drivers | expand

Message

Boris Brezillon Nov. 24, 2023, 2:24 p.m. UTC
Hello,

This patchset is an attempt at making page table allocation
customizable. This is useful to some GPU drivers for various reasons:

- speed-up upcoming page table allocations by managing a pool of free
  pages
- batch page table allocation instead of allocating one page at a time
- pre-reserve pages for page tables needed for map/unmap operations and
  return the unused page tables to some pool

The first and last reasons are particularly important for GPU drivers
wanting to implement asynchronous VM_BIND. Asynchronous VM_BIND requires
that any page table needed for a map/unmap operation to succeed be
allocated at VM_BIND job creation time. At the time of the job creation,
we don't know what the VM will look like when we get to execute the
map/unmap, and can't guess how many page tables we will need. Because
of that, we have to over-provision page tables for the worst case
scenario (page table tree is empty), which means we will allocate/free
a lot. Having pool a pool of free pages is crucial if we want to
speed-up VM_BIND requests.

There might also be other good reasons to want custom allocators, like
fine-grained memory accounting and resource limiting.

Regards,

Boris

Changes in v3:
- Add Robin's R-b
- Cosmetic changes
- Improve the allocator doc
- Stop passing GFP_ZERO to custom allocators

Changes in v2:
- Add Steven's R-b
- Expand on possible use-cases for custom allocators
- Add a caps field to io_pgtable_init_fns

Boris Brezillon (2):
  iommu: Allow passing custom allocators to pgtable drivers
  iommu: Extend LPAE page table format to support custom allocators

 drivers/iommu/io-pgtable-arm.c | 55 ++++++++++++++++++++++++----------
 drivers/iommu/io-pgtable.c     | 23 ++++++++++++++
 include/linux/io-pgtable.h     | 34 +++++++++++++++++++++
 3 files changed, 96 insertions(+), 16 deletions(-)

Comments

Joerg Roedel Nov. 27, 2023, 10:10 a.m. UTC | #1
On Fri, Nov 24, 2023 at 03:24:32PM +0100, Boris Brezillon wrote:
> Boris Brezillon (2):
>   iommu: Allow passing custom allocators to pgtable drivers
>   iommu: Extend LPAE page table format to support custom allocators
> 
>  drivers/iommu/io-pgtable-arm.c | 55 ++++++++++++++++++++++++----------
>  drivers/iommu/io-pgtable.c     | 23 ++++++++++++++
>  include/linux/io-pgtable.h     | 34 +++++++++++++++++++++
>  3 files changed, 96 insertions(+), 16 deletions(-)

Applied, thanks.
Gaurav Kohli Nov. 27, 2023, 1:35 p.m. UTC | #2
On 11/27/2023 3:40 PM, Joerg Roedel wrote:
> On Fri, Nov 24, 2023 at 03:24:32PM +0100, Boris Brezillon wrote:
>> Boris Brezillon (2):
>>    iommu: Allow passing custom allocators to pgtable drivers
>>    iommu: Extend LPAE page table format to support custom allocators
>>
>>   drivers/iommu/io-pgtable-arm.c | 55 ++++++++++++++++++++++++----------
>>   drivers/iommu/io-pgtable.c     | 23 ++++++++++++++
>>   include/linux/io-pgtable.h     | 34 +++++++++++++++++++++
>>   3 files changed, 96 insertions(+), 16 deletions(-)
> 
> Applied, thanks.

Tested patch v3 also and reviewed also, both looks good , please feel 
free to add in case of merging:

Reviewed-by: Gaurav Kohli <quic_gkohli@quicinc.com>
Tested-by: Gaurav Kohli <quic_gkohli@quicinc.com>