mbox series

[v7,0/7] udmabuf bug fix and some improvements

Message ID 20240918025238.2957823-1-link@vivo.com (mailing list archive)
Headers show
Series udmabuf bug fix and some improvements | expand

Message

Huan Yang Sept. 18, 2024, 2:52 a.m. UTC
This patchset attempts to fix some errors in udmabuf and remove the
upin_list structure, also try clean up code.

By this patchset, udmabuf remove page struct relay, only use
pfn and folios.

Some of this fix just gather the patches which I upload before.

Any patch has passed the udmabuf self-test suite's tests.
Suggested by Kasireddy, Vivek <vivek.kasireddy@intel.com>
Patch6 modified the unpin function, therefore running the udmabuf
self-test program in a loop did not reveal any memory leaks.

Notice: Test item 6 maybe requires running the command:
  echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages

Changelog
===
  v6 - > v7:
    A little change, update some commit message.
    Patch3: add fixes tag.
    Patch4: update ack tag, remove the redundant if (!memfd) check from
            check_memfd_seals(). update commit message.
    Patch6: update commit message to describe how unpin array worked.
    Patch7: update commit message to describe why need reuse the folios
            array.
  v5 -> v6:
    Patch1 use Vivek's comments(thank you), fix code style, update ack-tag.
    Patch2, 3 no change.
    Patch4 fix memfd miss fput, use Vivek's comments(thank you),
           fix code style, update suggested-by.
    Patch5 update ack-tag, fix error word in commit message.
    Patch6 update ack-tag, use xmas style.
    Patch7 update ack-tag, remove unused ret variable.

---
  v4 -> v5:
    Patch1 doc why pre-fault failed not report error.
    Patch2 no change
    Patch3 update ack tag marked in v4
    Patch4 split some change into patch5 and patch7, this only contains
           udmabuf pin folio's function
    Patch5 add helper init/deini to clean udmabuf struct initialized
    Patch6 remove unnecessary code
    Patch7 remove reuse folio remove v4 patch4

---
  v3 -> v4:
    Patch1 fill vma area with pfn only when true access.
    Patch2 no change
    Patch3 select VMAP_PFN
    Patch4 use function pin each item.
    Patch5 use pinned folio array instead udmabuf_folio struct.

---
  v2 -> v3:
    Patch1, avoid use page, instead, use pfn, and use vmf_insert_pfn map
    suggested-by Kasireddy, Vivek <vivek.kasireddy@intel.com>

    Patch2, update acked-by Kasireddy, Vivek <vivek.kasireddy@intel.com>
    And keep the kvcalloc on the same line.

    Patch3, avoid use page, instead, use pfn, then use vmap_pfn map

    Patch4, split v2 patch4, single update codestyle to keep review
    easy.

    Patch5, another way to remove udmabuf_folio
    
---
  v1 -> v2:
    Patch1, 3 Rectify the improper use of the sg table.
    suggested-by Christian König <christian.koenig@amd.com>
    
    Patch2 add acked-by Christian K�nig <christian.koenig@amd.com> which
    marked in v1

    Patch4
    Modify the data structure to restore the use of pages and
    correct the misunderstanding of loop conditions such as "pgcnt".
    make sure pass self test.

    remove v1's patch4
v6
  https://lore.kernel.org/all/20240909091851.1165742-1-link@vivo.com/
v5
  https://lore.kernel.org/all/20240903083818.3071759-1-link@vivo.com/
v4
  https://lore.kernel.org/all/20240822084342.1574914-1-link@vivo.com/
v3
  https://lore.kernel.org/all/20240813090518.3252469-1-link@vivo.com/
v2
  https://lore.kernel.org/all/20240805032550.3912454-1-link@vivo.com/
v1
  https://lore.kernel.org/all/20240801104512.4056860-1-link@vivo.com/

Huan Yang (7):
  udmabuf: pre-fault when first page fault
  udmabuf: change folios array from kmalloc to kvmalloc
  udmabuf: fix vmap_udmabuf error page set
  udmabuf: udmabuf_create pin folio codestyle cleanup
  udmabuf: introduce udmabuf init and deinit helper
  udmabuf: remove udmabuf_folio
  udmabuf: reuse folio array when pin folios

 drivers/dma-buf/Kconfig   |   1 +
 drivers/dma-buf/udmabuf.c | 275 +++++++++++++++++++++++---------------
 2 files changed, 169 insertions(+), 107 deletions(-)


base-commit: 57f962b956f1d116cd64d5c406776c4975de549d

Comments

Kasireddy, Vivek Sept. 21, 2024, 12:04 a.m. UTC | #1
Hi Huan,

> Subject: [PATCH v7 0/7] udmabuf bug fix and some improvements
> 
> This patchset attempts to fix some errors in udmabuf and remove the
> upin_list structure, also try clean up code.
> 
> By this patchset, udmabuf remove page struct relay, only use
> pfn and folios.
> 
> Some of this fix just gather the patches which I upload before.
> 
> Any patch has passed the udmabuf self-test suite's tests.
> Suggested by Kasireddy, Vivek <vivek.kasireddy@intel.com>
> Patch6 modified the unpin function, therefore running the udmabuf
> self-test program in a loop did not reveal any memory leaks.
> 
> Notice: Test item 6 maybe requires running the command:
>   echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages 

Thank you for the patches. Series applied to drm-misc-next.

Thanks,
Vivek

> Changelog
> ===
>   v6 - > v7:
>     A little change, update some commit message.
>     Patch3: add fixes tag.
>     Patch4: update ack tag, remove the redundant if (!memfd) check from
>             check_memfd_seals(). update commit message.
>     Patch6: update commit message to describe how unpin array worked.
>     Patch7: update commit message to describe why need reuse the folios
>             array.
>   v5 -> v6:
>     Patch1 use Vivek's comments(thank you), fix code style, update ack-tag.
>     Patch2, 3 no change.
>     Patch4 fix memfd miss fput, use Vivek's comments(thank you),
>            fix code style, update suggested-by.
>     Patch5 update ack-tag, fix error word in commit message.
>     Patch6 update ack-tag, use xmas style.
>     Patch7 update ack-tag, remove unused ret variable.
> 
> ---
>   v4 -> v5:
>     Patch1 doc why pre-fault failed not report error.
>     Patch2 no change
>     Patch3 update ack tag marked in v4
>     Patch4 split some change into patch5 and patch7, this only contains
>            udmabuf pin folio's function
>     Patch5 add helper init/deini to clean udmabuf struct initialized
>     Patch6 remove unnecessary code
>     Patch7 remove reuse folio remove v4 patch4
> 
> ---
>   v3 -> v4:
>     Patch1 fill vma area with pfn only when true access.
>     Patch2 no change
>     Patch3 select VMAP_PFN
>     Patch4 use function pin each item.
>     Patch5 use pinned folio array instead udmabuf_folio struct.
> 
> ---
>   v2 -> v3:
>     Patch1, avoid use page, instead, use pfn, and use vmf_insert_pfn map
>     suggested-by Kasireddy, Vivek <vivek.kasireddy@intel.com>
> 
>     Patch2, update acked-by Kasireddy, Vivek <vivek.kasireddy@intel.com>
>     And keep the kvcalloc on the same line.
> 
>     Patch3, avoid use page, instead, use pfn, then use vmap_pfn map
> 
>     Patch4, split v2 patch4, single update codestyle to keep review
>     easy.
> 
>     Patch5, another way to remove udmabuf_folio
> 
> ---
>   v1 -> v2:
>     Patch1, 3 Rectify the improper use of the sg table.
>     suggested-by Christian König <christian.koenig@amd.com>
> 
>     Patch2 add acked-by Christian K�nig <christian.koenig@amd.com> which
>     marked in v1
> 
>     Patch4
>     Modify the data structure to restore the use of pages and
>     correct the misunderstanding of loop conditions such as "pgcnt".
>     make sure pass self test.
> 
>     remove v1's patch4
> v6
>   https://lore.kernel.org/all/20240909091851.1165742-1-link@vivo.com/
> v5
>   https://lore.kernel.org/all/20240903083818.3071759-1-link@vivo.com/
> v4
>   https://lore.kernel.org/all/20240822084342.1574914-1-link@vivo.com/
> v3
>   https://lore.kernel.org/all/20240813090518.3252469-1-link@vivo.com/
> v2
>   https://lore.kernel.org/all/20240805032550.3912454-1-link@vivo.com/
> v1
>   https://lore.kernel.org/all/20240801104512.4056860-1-link@vivo.com/
> 
> Huan Yang (7):
>   udmabuf: pre-fault when first page fault
>   udmabuf: change folios array from kmalloc to kvmalloc
>   udmabuf: fix vmap_udmabuf error page set
>   udmabuf: udmabuf_create pin folio codestyle cleanup
>   udmabuf: introduce udmabuf init and deinit helper
>   udmabuf: remove udmabuf_folio
>   udmabuf: reuse folio array when pin folios
> 
>  drivers/dma-buf/Kconfig   |   1 +
>  drivers/dma-buf/udmabuf.c | 275 +++++++++++++++++++++++---------------
>  2 files changed, 169 insertions(+), 107 deletions(-)
> 
> 
> base-commit: 57f962b956f1d116cd64d5c406776c4975de549d
> --
> 2.45.2
Huan Yang Sept. 23, 2024, 1:11 a.m. UTC | #2
在 2024/9/21 8:04, Kasireddy, Vivek 写道:
> Hi Huan,
>
>> Subject: [PATCH v7 0/7] udmabuf bug fix and some improvements
>>
>> This patchset attempts to fix some errors in udmabuf and remove the
>> upin_list structure, also try clean up code.
>>
>> By this patchset, udmabuf remove page struct relay, only use
>> pfn and folios.
>>
>> Some of this fix just gather the patches which I upload before.
>>
>> Any patch has passed the udmabuf self-test suite's tests.
>> Suggested by Kasireddy, Vivek <vivek.kasireddy@intel.com>
>> Patch6 modified the unpin function, therefore running the udmabuf
>> self-test program in a loop did not reveal any memory leaks.
>>
>> Notice: Test item 6 maybe requires running the command:
>>    echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
> Thank you for the patches. Series applied to drm-misc-next.
OK, Thanks. :)
>
> Thanks,
> Vivek
>
>> Changelog
>> ===
>>    v6 - > v7:
>>      A little change, update some commit message.
>>      Patch3: add fixes tag.
>>      Patch4: update ack tag, remove the redundant if (!memfd) check from
>>              check_memfd_seals(). update commit message.
>>      Patch6: update commit message to describe how unpin array worked.
>>      Patch7: update commit message to describe why need reuse the folios
>>              array.
>>    v5 -> v6:
>>      Patch1 use Vivek's comments(thank you), fix code style, update ack-tag.
>>      Patch2, 3 no change.
>>      Patch4 fix memfd miss fput, use Vivek's comments(thank you),
>>             fix code style, update suggested-by.
>>      Patch5 update ack-tag, fix error word in commit message.
>>      Patch6 update ack-tag, use xmas style.
>>      Patch7 update ack-tag, remove unused ret variable.
>>
>> ---
>>    v4 -> v5:
>>      Patch1 doc why pre-fault failed not report error.
>>      Patch2 no change
>>      Patch3 update ack tag marked in v4
>>      Patch4 split some change into patch5 and patch7, this only contains
>>             udmabuf pin folio's function
>>      Patch5 add helper init/deini to clean udmabuf struct initialized
>>      Patch6 remove unnecessary code
>>      Patch7 remove reuse folio remove v4 patch4
>>
>> ---
>>    v3 -> v4:
>>      Patch1 fill vma area with pfn only when true access.
>>      Patch2 no change
>>      Patch3 select VMAP_PFN
>>      Patch4 use function pin each item.
>>      Patch5 use pinned folio array instead udmabuf_folio struct.
>>
>> ---
>>    v2 -> v3:
>>      Patch1, avoid use page, instead, use pfn, and use vmf_insert_pfn map
>>      suggested-by Kasireddy, Vivek <vivek.kasireddy@intel.com>
>>
>>      Patch2, update acked-by Kasireddy, Vivek <vivek.kasireddy@intel.com>
>>      And keep the kvcalloc on the same line.
>>
>>      Patch3, avoid use page, instead, use pfn, then use vmap_pfn map
>>
>>      Patch4, split v2 patch4, single update codestyle to keep review
>>      easy.
>>
>>      Patch5, another way to remove udmabuf_folio
>>
>> ---
>>    v1 -> v2:
>>      Patch1, 3 Rectify the improper use of the sg table.
>>      suggested-by Christian König <christian.koenig@amd.com>
>>
>>      Patch2 add acked-by Christian K�nig <christian.koenig@amd.com> which
>>      marked in v1
>>
>>      Patch4
>>      Modify the data structure to restore the use of pages and
>>      correct the misunderstanding of loop conditions such as "pgcnt".
>>      make sure pass self test.
>>
>>      remove v1's patch4
>> v6
>>    https://lore.kernel.org/all/20240909091851.1165742-1-link@vivo.com/
>> v5
>>    https://lore.kernel.org/all/20240903083818.3071759-1-link@vivo.com/
>> v4
>>    https://lore.kernel.org/all/20240822084342.1574914-1-link@vivo.com/
>> v3
>>    https://lore.kernel.org/all/20240813090518.3252469-1-link@vivo.com/
>> v2
>>    https://lore.kernel.org/all/20240805032550.3912454-1-link@vivo.com/
>> v1
>>    https://lore.kernel.org/all/20240801104512.4056860-1-link@vivo.com/
>>
>> Huan Yang (7):
>>    udmabuf: pre-fault when first page fault
>>    udmabuf: change folios array from kmalloc to kvmalloc
>>    udmabuf: fix vmap_udmabuf error page set
>>    udmabuf: udmabuf_create pin folio codestyle cleanup
>>    udmabuf: introduce udmabuf init and deinit helper
>>    udmabuf: remove udmabuf_folio
>>    udmabuf: reuse folio array when pin folios
>>
>>   drivers/dma-buf/Kconfig   |   1 +
>>   drivers/dma-buf/udmabuf.c | 275 +++++++++++++++++++++++---------------
>>   2 files changed, 169 insertions(+), 107 deletions(-)
>>
>>
>> base-commit: 57f962b956f1d116cd64d5c406776c4975de549d
>> --
>> 2.45.2