[PATCH v2 2/2] udmabuf: fix vmap missed offset page

2025-04-28 Thread Huan Yang
Before invoke vmap, we need offer a pages pointer array which each page need to map in vmalloc area. But currently vmap_udmabuf only set each folio's head page into pages, missed each offset pages when iter. This patch set the correctly offset page in each folio into array. Signed-off-by:

[PATCH v2 1/2] Revert "udmabuf: fix vmap_udmabuf error page set"

2025-04-28 Thread Huan Yang
with pages/folios backed by shmem/hugetlbfs/THP, vmap_pfn() is not the right tool or API to invoke for implementing vmap. Signed-off-by: Huan Yang Suggested-by: Kasireddy, Vivek Reported-by: Bingbu Cao Closes: https://lore.kernel.org/dri-devel/eb7e0137-3508-4287-98c4-816c5fd98...@vivo.com/T

[PATCH v2 0/2] Fix udmabuf vmap error

2025-04-28 Thread Huan Yang
ore.kernel.org/all/9172a601-c360-0d5b-ba1b-33deba430...@linux.intel.com/ [2] https://lore.kernel.org/all/20250312061513.1126496-1-l...@vivo.com/ [3] https://lore.kernel.org/all/20250327092922.536-1-l...@vivo.com/ Huan Yang (2): Revert "udmabuf: fix vmap_udmabuf error page set" udmabuf:

Re: [PATCH 1/2] Revert "udmabuf: fix vmap_udmabuf error page set"

2025-04-28 Thread Huan Yang
在 2025/4/28 12:16, Kasireddy, Vivek 写道: Hi Huan, Subject: Re: [PATCH 1/2] Revert "udmabuf: fix vmap_udmabuf error page set" From 38aa11d92f209e7529736f3e11e08dfc804bdfae Mon Sep 17 00:00:00 2001 From: Huan Yang Date: Tue, 15 Apr 2025 10:04:18 +0800 Subject: [PATCH 1/2] Rever

Re: [PATCH 1/2] Revert "udmabuf: fix vmap_udmabuf error page set"

2025-04-23 Thread Huan Yang
From 38aa11d92f209e7529736f3e11e08dfc804bdfae Mon Sep 17 00:00:00 2001 From: Huan Yang Date: Tue, 15 Apr 2025 10:04:18 +0800 Subject: [PATCH 1/2] Revert "udmabuf: fix vmap_udmabuf error page set" This reverts commit 18d7de823b7150344d242c3677e65d68c5271b04. This given a misuse o

Re: [PATCH 2/2] udmabuf: fix vmap missed offset page

2025-04-23 Thread Huan Yang
pages, missed each offset pages when iter. This patch set the correctly offset page in each folio into array. Signed-off-by: Huan Yang Fixes: 5e72b2b41a21 ("udmabuf: convert udmabuf driver to use folios") --- drivers/dma-buf/udmabuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-

Re: [PATCH 1/2] Revert "udmabuf: fix vmap_udmabuf error page set"

2025-04-23 Thread Huan Yang
based user invoke, i.e. PCIe BARs and other. The commit message can be improved a little bit to briefly explain why vmap_pfn() would not work for this use-case. OK, I will update patch direct in later reply.:) Thanks, Huan Acked-by: Vivek Kasireddy Thanks, Vivek Signed-off-by: Huan Yang R

[PATCH 1/2] Revert "udmabuf: fix vmap_udmabuf error page set"

2025-04-15 Thread Huan Yang
This reverts commit 18d7de823b7150344d242c3677e65d68c5271b04. This given a misuse of vmap_pfn, vmap_pfn only allow none-page based user invoke, i.e. PCIe BARs and other. Signed-off-by: Huan Yang Reported-by: Bingbu Cao Closes: https://lore.kernel.org/dri-devel/eb7e0137-3508-4287-98c4

[PATCH 0/2] Fix udmabuf vmap error

2025-04-14 Thread Huan Yang
[3] https://lore.kernel.org/all/20250327092922.536-1-l...@vivo.com/ Huan Yang (2): Revert "udmabuf: fix vmap_udmabuf error page set" udmabuf: fix vmap missed offset page drivers/dma-buf/Kconfig | 1 - drivers/dma-buf/udmabuf.c | 23 --- 2 files changed, 8 inserti

[PATCH 2/2] udmabuf: fix vmap missed offset page

2025-04-14 Thread Huan Yang
Before invoke vmap, we need offer a pages pointer array which each page need to map in vmalloc area. But currently vmap_udmabuf only set each folio's head page into pages, missed each offset pages when iter. This patch set the correctly offset page in each folio into array. Signed-off-by:

Re: CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP is broken, was Re: [RFC PATCH 0/6] Deep talk about folio vmap

2025-04-07 Thread Huan Yang
在 2025/4/7 15:22, Muchun Song 写道: On Apr 7, 2025, at 15:09, Huan Yang wrote: 在 2025/4/7 14:43, Muchun Song 写道: On Apr 7, 2025, at 11:37, Muchun Song wrote: On Apr 7, 2025, at 11:21, Huan Yang wrote: 在 2025/4/7 10:57, Muchun Song 写道: On Apr 7, 2025, at 09:59, Huan Yang wrote

Re: CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP is broken, was Re: [RFC PATCH 0/6] Deep talk about folio vmap

2025-04-07 Thread Huan Yang
在 2025/4/7 14:43, Muchun Song 写道: On Apr 7, 2025, at 11:37, Muchun Song wrote: On Apr 7, 2025, at 11:21, Huan Yang wrote: 在 2025/4/7 10:57, Muchun Song 写道: On Apr 7, 2025, at 09:59, Huan Yang wrote: 在 2025/4/4 18:07, Muchun Song 写道: On Apr 4, 2025, at 17:38, Muchun Song wrote

Re: CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP is broken, was Re: [RFC PATCH 0/6] Deep talk about folio vmap

2025-04-06 Thread Huan Yang
在 2025/4/7 10:57, Muchun Song 写道: On Apr 7, 2025, at 09:59, Huan Yang wrote: 在 2025/4/4 18:07, Muchun Song 写道: On Apr 4, 2025, at 17:38, Muchun Song wrote: On Apr 4, 2025, at 17:01, Christoph Hellwig wrote: After the btrfs compressed bio discussion I think the hugetlb changes that

Re: CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP is broken, was Re: [RFC PATCH 0/6] Deep talk about folio vmap

2025-04-06 Thread Huan Yang
need map page 2-7, can we use vmap do something correctly? Or something I still misunderstand, please correct me. Thanks, Huan Yang of the fundamentals of HVO, I kindly suggest a thorough review of the document in [3]. [2] https://lore.kernel.org/lkml/5229b24f-1984-4225-ae03-8b952de56...@v

[RFC PATCH 5/6] udmabuf: vmap test suit for pages and pfns compare

2025-03-27 Thread Huan Yang
This patch both compare pages and pfns based vmap, to show folios range vmap and pfn range vmap can work. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 64 --- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/drivers/dma-buf

[RFC PATCH 4/6] udmabuf: use vmap_range_folios

2025-03-27 Thread Huan Yang
This patch change udmabuf from use pfn based into folio based vmap. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 25 - 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index fbe4b59b4c97

[RFC PATCH 1/6] udmabuf: try fix udmabuf vmap

2025-03-27 Thread Huan Yang
vmap_pfn design to only allow none page based pfn map. This patch try simple copy pfn vmap code to fix it. Fix vunmap_udmabuf fix match with vmap_udmabuf, use vunmap. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 49 +++ 1 file changed, 45

[RFC PATCH 3/6] mm/vmalloc: try add vmap folios range

2025-03-27 Thread Huan Yang
pages). Signed-off-by: Huan Yang --- include/linux/vmalloc.h | 57 + mm/vmalloc.c| 47 + 2 files changed, 104 insertions(+) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 31e9ffd936e3..007a398

[RFC PATCH 6/6] udmabuf: remove no need code

2025-03-27 Thread Huan Yang
This patch remove each test code. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 142 --- include/uapi/linux/udmabuf.h | 5 - .../selftests/drivers/dma-buf/Makefile| 1 - .../selftests/drivers/dma-buf/udmabuf_vmap.c | 166

[RFC PATCH 2/6] udmabuf: try udmabuf vmap test

2025-03-27 Thread Huan Yang
This patch add a test ioctl in udmabuf to show vmap can work. by compare pfn vmap and pages vmap. But this skip HVO folio compare due to can't use pages vmap. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 71 include/uapi/linux/udma

[RFC PATCH 0/6] Deep talk about folio vmap

2025-03-27 Thread Huan Yang
check output, and dmesg if any warn. [1] https://lore.kernel.org/all/9172a601-c360-0d5b-ba1b-33deba430...@linux.intel.com/ [2] https://lore.kernel.org/lkml/20250312061513.1126496-1-l...@vivo.com/ [3] https://lore.kernel.org/linux-mm/20250131001806.92349-1-vishal.mo...@gmail.com/ Huan Yang (6)

Re: udmabuf vmap failed (Revert "udmabuf: fix vmap_udmabuf error page set" can help)

2025-03-11 Thread Huan Yang
在 2025/3/11 19:14, Ryan Roberts 写道: Hi, On 11/03/2025 09:34, Huan Yang wrote: Hi Christoph and Ryan, Can you help us check vmap_pfn's pfn check is right? Did here mischecked pfn_valid? I'm no expert on this piece of code, but I believe pfn_valid() is checking to see if a pf

Re: udmabuf vmap failed (Revert "udmabuf: fix vmap_udmabuf error page set" can help)

2025-03-11 Thread Huan Yang
Hi Christoph and Ryan, Can you help us check vmap_pfn's pfn check is right? Did here mischecked pfn_valid? Thank you. 在 2025/3/11 17:02, Bingbu Cao 写道: Christoph and Ryan, Could you help check this? Thanks. On 3/11/25 4:54 PM, Huan Yang wrote: 在 2025/3/11 16:42, Bingbu Cao 写道:

Re: udmabuf vmap failed (Revert "udmabuf: fix vmap_udmabuf error page set" can help)

2025-03-11 Thread Huan Yang
在 2025/3/11 16:42, Bingbu Cao 写道: [You don't often get email from bingbu@linux.intel.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] Huan, Thanks for your response. On 3/11/25 3:12 PM, Huan Yang wrote: 在 2025/3/11 14:40, Bingbu Cao 写道: [You

Re: udmabuf vmap failed (Revert "udmabuf: fix vmap_udmabuf error page set" can help)

2025-03-11 Thread Huan Yang
在 2025/3/11 14:40, Bingbu Cao 写道: [You don't often get email from bingbu@linux.intel.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] Huan Yang and Vivek, I am trying to use udmabuf for my test, and I cannot vmap the udmabuf buffers now. vmap_pfn_

Re: [PATCH v7 0/7] udmabuf bug fix and some improvements

2024-09-22 Thread Huan Yang
74914-1-l...@vivo.com/ v3 https://lore.kernel.org/all/20240813090518.3252469-1-l...@vivo.com/ v2 https://lore.kernel.org/all/20240805032550.3912454-1-l...@vivo.com/ v1 https://lore.kernel.org/all/20240801104512.4056860-1-l...@vivo.com/ Huan Yang (7): udmabuf: pre-fault when first pa

[PATCH v7 7/7] udmabuf: reuse folio array when pin folios

2024-09-17 Thread Huan Yang
if each item's range folio's count is large, we may fallback each into vmalloc. This patch find the largest range folio in items, then alloc this size's folio array. When pin range folios, reuse this array. Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy ---

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

2024-09-17 Thread Huan Yang
https://lore.kernel.org/all/20240822084342.1574914-1-l...@vivo.com/ v3 https://lore.kernel.org/all/20240813090518.3252469-1-l...@vivo.com/ v2 https://lore.kernel.org/all/20240805032550.3912454-1-l...@vivo.com/ v1 https://lore.kernel.org/all/20240801104512.4056860-1-l...@vivo.com/ Huan Yang (

[PATCH v7 5/7] udmabuf: introduce udmabuf init and deinit helper

2024-09-17 Thread Huan Yang
. This patch give a helper function when init and deinit, by this, reduce duplicate code. Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 52 +++ 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/dma-buf

[PATCH v7 6/7] udmabuf: remove udmabuf_folio

2024-09-17 Thread Huan Yang
, depend on the large folio's number, the pinned_folios array may take more memory, but it still can makes unpin access more cache-friendly. Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 65 +-- 1 file changed, 29 inser

[PATCH v7 4/7] udmabuf: udmabuf_create pin folio codestyle cleanup

2024-09-17 Thread Huan Yang
then record each offset in it. Compare to iter by pgcnt, more readable. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 137 +- 1 file changed, 76 insertions(+), 61 deletions(-) diff --git a

[PATCH v7 3/7] udmabuf: fix vmap_udmabuf error page set

2024-09-17 Thread Huan Yang
t use page array to map, instead, use pfn array. By this, we removed page usage in udmabuf totally. Fixes: 5e72b2b41a21 ("udmabuf: convert udmabuf driver to use folios") Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/Kconfig | 1

[PATCH v7 1/7] udmabuf: pre-fault when first page fault

2024-09-17 Thread Huan Yang
truly accessed Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 33 +++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index

[PATCH v7 2/7] udmabuf: change folios array from kmalloc to kvmalloc

2024-09-17 Thread Huan Yang
cation for any size and does not affect the performance of kmalloc allocations. Signed-off-by: Huan Yang Acked-by: Christian König Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/d

Re: [PATCH v6 4/7] udmabuf: udmabuf_create pin folio codestyle cleanup

2024-09-12 Thread Huan Yang
modifies the original loop condition, using the pinned folio as the external loop condition, and sets the offset and folio during the traversal process. By this, more readable. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 134

Re: [PATCH v6 3/7] udmabuf: fix vmap_udmabuf error page set

2024-09-12 Thread Huan Yang
f: convert udmabuf driver to use folios") OK, I'll update it Thanks, Vivek Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/Kconfig | 1 + drivers/dma-buf/udmabuf.c | 22 +++--- 2 files changed, 16 inser

[PATCH v6 6/7] udmabuf: remove udmabuf_folio

2024-09-09 Thread Huan Yang
e can iterate through the folios array during release and unpin any folio that is different from the ones previously accessed. By this, not only saves the overhead of the udmabuf_folio data structure but also makes array access more cache-friendly. Signed-off-by: Huan Yang Acked-by: Vivek Kasi

[PATCH v6 7/7] udmabuf: reuse folio array when pin folios

2024-09-09 Thread Huan Yang
size is huge, need fallback into vmalloc, then, not well, due to each page need alloc, and map into vmalloc area. Too heavy. Now that we need to iter each udmabuf item, then pin it's range folios, we can reuse the maximum size range's folios array. Signed-off-by: Huan Yang Acked

[PATCH v6 4/7] udmabuf: udmabuf_create pin folio codestyle cleanup

2024-09-09 Thread Huan Yang
traversal process. By this, more readable. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 134 +- 1 file changed, 76 insertions(+), 58 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c

[PATCH v6 3/7] udmabuf: fix vmap_udmabuf error page set

2024-09-09 Thread Huan Yang
t use page array to map, instead, use pfn array. By this, we removed page usage in udmabuf totally. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/Kconfig | 1 + drivers/dma-buf/udmabuf.c | 22 +++--- 2 files changed, 16 ins

[PATCH v6 2/7] udmabuf: change folios array from kmalloc to kvmalloc

2024-09-09 Thread Huan Yang
cation for any size and does not affect the performance of kmalloc allocations. Signed-off-by: Huan Yang Acked-by: Christian König Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/d

[PATCH v6 5/7] udmabuf: introduce udmabuf init and deinit helper

2024-09-09 Thread Huan Yang
. This patch give a helper function when init and deinit, by this, reduce duplicate code. Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 52 +++ 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/dma-buf

[PATCH v6 1/7] udmabuf: pre-fault when first page fault

2024-09-09 Thread Huan Yang
truly accessed Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 33 +++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index

[PATCH v6 0/7] udmabuf bug fix and some improvements

2024-09-09 Thread Huan Yang
ttps://lore.kernel.org/all/20240805032550.3912454-1-l...@vivo.com/ v1 https://lore.kernel.org/all/20240801104512.4056860-1-l...@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:

Re: [PATCH v5 4/7] udmabuf: udmabuf_create pin folio codestyle cleanup

2024-09-08 Thread Huan Yang
, end of loop. By this, more readable. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 132 -- 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 456db58446e1..ca2b21c5c57f

Re: [PATCH v5 7/7] udmabuf: reuse folio array when pin folios

2024-09-06 Thread Huan Yang
, then pin it's range folios, we can reuse the maximum size range's folios array. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 34 -- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf

Re: [PATCH v5 6/7] udmabuf: remove udmabuf_folio

2024-09-06 Thread Huan Yang
cture but also makes array access more cache-friendly. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 65 +-- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 254d9ec

Re: [PATCH v5 5/7] udmabuf: introduce udmabuf init and deinit helper

2024-09-06 Thread Huan Yang
correctness in the commit messages of other patches as well. I'll fix it in next-version Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 52 +++ 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dm

Re: [PATCH v5 1/7] udmabuf: pre-fault when first page fault

2024-09-06 Thread Huan Yang
t the first time. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 35 +-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 047c3cd2ceff..0a8c231a36e1 1

Re: [PATCH v5 4/7] udmabuf: udmabuf_create pin folio codestyle cleanup

2024-09-06 Thread Huan Yang
iterates through folios, while the inner loop correctly sets the folio and corresponding offset into the udmabuf starting from the offset. if reach to pgcnt or nr_folios, end of loop. By this, more readable. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 132

[PATCH v5 7/7] udmabuf: reuse folio array when pin folios

2024-09-03 Thread Huan Yang
size is huge, need fallback into vmalloc, then, not well, due to each page will iter alloc, and map into vmalloc area. Too heavy. Now that we need to iter each udmabuf item, then pin it's range folios, we can reuse the maximum size range's folios array. Signed-off-by: Huan Yang --- d

[PATCH v5 6/7] udmabuf: remove udmabuf_folio

2024-09-03 Thread Huan Yang
e can iterate through the folios array during release and unpin any folio that is different from the ones previously accessed. By this, not only saves the overhead of the udmabuf_folio data structure but also makes array access more cache-friendly. Signed-off-by: Huan Yang --- drivers/dma-buf/udma

[PATCH v5 5/7] udmabuf: introduce udmabuf init and deinit helper

2024-09-03 Thread Huan Yang
. This patch give a helper function when init and deinit, by this, deduce duplicate code. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 52 +++ 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf

[PATCH v5 4/7] udmabuf: udmabuf_create pin folio codestyle cleanup

2024-09-03 Thread Huan Yang
. if reach to pgcnt or nr_folios, end of loop. By this, more readable. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 132 -- 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index

[PATCH v5 3/7] udmabuf: fix vmap_udmabuf error page set

2024-09-03 Thread Huan Yang
t use page array to map, instead, use pfn array. By this, we removed page usage in udmabuf totally. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang Acked-by: Vivek Kasireddy --- drivers/dma-buf/Kconfig | 1 + drivers/dma-buf/udmabuf.c | 22 +++--- 2 files changed, 16 ins

[PATCH v5 2/7] udmabuf: change folios array from kmalloc to kvmalloc

2024-09-03 Thread Huan Yang
cation for any size and does not affect the performance of kmalloc allocations. Signed-off-by: Huan Yang Acked-by: Christian König Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/d

[PATCH v5 1/7] udmabuf: pre-fault when first page fault

2024-09-03 Thread Huan Yang
table, and then pre-fault each pfn into vma, when first access. Should know, if anything wrong when pre-fault, will not report it's error, else, report when task access it at the first time. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c

[PATCH v5 0/7] udmbuf bug fix and some improvements

2024-09-03 Thread Huan Yang
vo.com/ v3 https://lore.kernel.org/all/20240813090518.3252469-1-l...@vivo.com/ v2 https://lore.kernel.org/all/20240805032550.3912454-1-l...@vivo.com/ v1 https://lore.kernel.org/all/20240801104512.4056860-1-l...@vivo.com/ Huan Yang (7): udmabuf: pre-fault when first page fault udmabuf: chan

Re: [PATCH v4 5/5] udmabuf: remove udmabuf_folio

2024-08-28 Thread Huan Yang
array record each folio is ok. Compare udmabuf_folio 24 byte, folio array is 8 byte. Even if array need to be pgcnt*8, may waste some memory when use large folio. The access of array is faster than list, also, if 4K, array can also save memory than list. Signed-off-by: Huan Yang --- drivers/dm

Re: [PATCH v4 4/5] udmabuf: udmabuf_create codestyle cleanup

2024-08-28 Thread Huan Yang
se of folios when iter create head, just use max size of item. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 165 +++--- 1 file changed, 101 insertions(+), 64 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 0bbc9df

Re: [PATCH v4 1/5] udmabuf: direct map pfn when first page fault

2024-08-28 Thread Huan Yang
in mmap, when creating a large size udmabuf, this represents a considerable overhead. This patch fill vma area with pfn when the first page fault trigger, so, any other access will not enter page fault. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 26

[PATCH v4 4/5] udmabuf: udmabuf_create codestyle cleanup

2024-08-22 Thread Huan Yang
, folios may use vmalloc to get memory, which can't cache but return into pcp(or buddy) when vfree. So, each pin may waste some time in folios array alloc. This patch also reuse of folios when iter create head, just use max size of item. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c

[PATCH v4 5/5] udmabuf: remove udmabuf_folio

2024-08-22 Thread Huan Yang
pgcnt*8, may waste some memory when use large folio. The access of array is faster than list, also, if 4K, array can also save memory than list. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 80 ++- 1 file changed, 37 insertions(+), 43 deletions(-)

[PATCH v4 3/5] udmabuf: fix vmap_udmabuf error page set

2024-08-22 Thread Huan Yang
t use page array to map, instead, use pfn array. By this, we removed page usage in udmabuf totally. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang --- drivers/dma-buf/Kconfig | 1 + drivers/dma-buf/udmabuf.c | 22 +++--- 2 files changed, 16 insertions(+), 7 deletions(-

[PATCH v4 2/5] udmabuf: change folios array from kmalloc to kvmalloc

2024-08-22 Thread Huan Yang
cation for any size and does not affect the performance of kmalloc allocations. Signed-off-by: Huan Yang Acked-by: Christian König Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/d

[PATCH v4 0/5] udmbuf bug fix and some improvements

2024-08-22 Thread Huan Yang
as "pgcnt". make sure pass self test. remove v1's patch4 v3 https://lore.kernel.org/all/20240813090518.3252469-1-l...@vivo.com/ v2 https://lore.kernel.org/all/20240805032550.3912454-1-l...@vivo.com/ v1 https://lore.kernel.org/all/20240801104512.4056860-1-l...@vivo.com/ H

[PATCH v4 1/5] udmabuf: direct map pfn when first page fault

2024-08-22 Thread Huan Yang
the first page fault trigger, so, any other access will not enter page fault. Suggested-by: Vivek Kasireddy Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 26 -- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers

Re: [PATCH v3 5/5] udmabuf: remove udmabuf_folio

2024-08-19 Thread Huan Yang
for memfds backed by shmem, but I suspect this may not work if THP is enabled. Thanks, Vivek By this, not only saves the overhead of the udmabuf_folio data structure but also makes array access more cache-friendly. Signed-off-by: Huan Yang --- drivers/dm

Re: [PATCH v3 4/5] udmabuf: codestyle cleanup

2024-08-19 Thread Huan Yang
folio to the unpin_list. The outer loop of this patch iterates through folios, while the inner loop correctly sets the folio and corresponding offset into the udmabuf starting from the offset. if reach to pgcnt or nr_folios, end of loop. By this, more readable. Signed-off-by: Huan Yang

Re: [PATCH v3 3/5] fix vmap_udmabuf error page set

2024-08-19 Thread Huan Yang
>folios is only contain's the folio's head page. That mean we repeatedly mapped the folio head page to the vmalloc area. Due to udmabuf can use hugetlb, if HVO enabled, tail page may not exist, so, we can't use page array to map, instead, use pfn array. Signed-off-by: Huan Ya

Re: [PATCH v3 1/5] udmabuf: cancel mmap page fault, direct map it

2024-08-19 Thread Huan Yang
mmap, when creating a large size udmabuf, this represents a considerable overhead. The current patch removes the page fault method of mmap and instead fills pfn directly when mmap is triggered. Signed-off-by: Huan Yang Suggested-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 37

[PATCH v3 4/5] udmabuf: codestyle cleanup

2024-08-13 Thread Huan Yang
patch iterates through folios, while the inner loop correctly sets the folio and corresponding offset into the udmabuf starting from the offset. if reach to pgcnt or nr_folios, end of loop. By this, more readable. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 65

[PATCH v3 2/5] udmabuf: change folios array from kmalloc to kvmalloc

2024-08-13 Thread Huan Yang
cation for any size and does not affect the performance of kmalloc allocations. Signed-off-by: Huan Yang Acked-by: Christian König Acked-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/d

[PATCH v3 5/5] udmabuf: remove udmabuf_folio

2024-08-13 Thread Huan Yang
e can iterate through the folios array during release and unpin any folio that is different from the ones previously accessed. By this, not only saves the overhead of the udmabuf_folio data structure but also makes array access more cache-friendly. Signed-off-by: Huan Yang --- drivers/dma-buf/udma

[PATCH v3 1/5] udmabuf: cancel mmap page fault, direct map it

2024-08-13 Thread Huan Yang
a considerable overhead. The current patch removes the page fault method of mmap and instead fills pfn directly when mmap is triggered. Signed-off-by: Huan Yang Suggested-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 37 +++-- 1 file changed, 15 insertions

[PATCH v3 3/5] fix vmap_udmabuf error page set

2024-08-13 Thread Huan Yang
t use page array to map, instead, use pfn array. Signed-off-by: Huan Yang Suggested-by: Vivek Kasireddy --- drivers/dma-buf/udmabuf.c | 22 +++--- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 3ec72d47bb

[PATCH v3 0/5] udmbuf bug fix and some improvements

2024-08-13 Thread Huan Yang
make sure pass self test. remove v1's patch4 v2 https://lore.kernel.org/all/20240805032550.3912454-1-l...@vivo.com/ v1 https://lore.kernel.org/all/20240801104512.4056860-1-l...@vivo.com/ Huan Yang (5): udmabuf: cancel mmap page fault, direct map it udmabuf: change folios array

Re: [PATCH v2 1/4] udmabuf: cancel mmap page fault, direct map it

2024-08-11 Thread Huan Yang
sound, but it may not save memory, only increase context switch overhead. whether opengl is available in the environment or not. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 39 --- 1 file changed, 16 insertions(+), 23 deletions(-) diff --

Re: [PATCH v2 4/4] udmabuf: remove folio unpin list

2024-08-11 Thread Huan Yang
not work if THP is enabled. Considering the existence of HVO, I also feel the need to find further optimization methods. Thanks. Thanks, Vivek Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 167 ++ 1 file changed, 61 insertions(+), 106

Re: [PATCH v2 3/4] fix vmap_udmabuf error page set

2024-08-11 Thread Huan Yang
But, ubuf->folios is only contain's the folio's head page. That mean we repeatedly mapped the folio head page to the vmalloc area. This patch fix it, set each folio's page correct, so that pages array contains right page, and then map into vmalloc area Signed-off-by: Huan Yang ---

Re: [PATCH v2 2/4] udmabuf: change folios array from kmalloc to kvmalloc

2024-08-11 Thread Huan Yang
allocations. Signed-off-by: Huan Yang Acked-by: Christian König --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 475268d4ebb1..af2391cea0bf 100644 --- a/driv

[PATCH v2 4/4] udmabuf: remove folio unpin list

2024-08-04 Thread Huan Yang
g the list during unpinning. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 167 ++ 1 file changed, 61 insertions(+), 106 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 9737f063b6b3..442ed99d8b33 100644 --- a/dr

[PATCH v2 1/4] udmabuf: cancel mmap page fault, direct map it

2024-08-04 Thread Huan Yang
access to virtual addresses needs to trap into kernel mode. Therefore, when creating a large size udmabuf, this represents a considerable overhead. The current patch removes the page fault method of mmap and instead fills it directly when mmap is triggered. Signed-off-by: Huan Yang --- drivers/dma

[PATCH v2 2/4] udmabuf: change folios array from kmalloc to kvmalloc

2024-08-04 Thread Huan Yang
cation for any size and does not affect the performance of kmalloc allocations. Signed-off-by: Huan Yang Acked-by: Christian König --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/d

[PATCH v2 3/4] fix vmap_udmabuf error page set

2024-08-04 Thread Huan Yang
page, and then map into vmalloc area Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index af2391cea0bf..9737f063b6b3 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/dr

[PATCH v2 0/4] udmbuf bug fix and some improvements

2024-08-04 Thread Huan Yang
ns such as "pgcnt". make sure pass self test. remove v1's patch4 v1 https://lore.kernel.org/all/20240801104512.4056860-1-l...@vivo.com/ Huan Yang (4): udmabuf: cancel mmap page fault, direct map it udmabuf: change folios array from kmalloc to kvmalloc fix vmap_udmabuf erro

Re: [PATCH 0/5] udmbuf bug fix and some improvements

2024-08-01 Thread Huan Yang
arious data structures in udmabuf have the following corresponding relationships: pagecount * PAGESIZE = sum(folios_size(folios[i])) i=0->nr_folios pagecount * PAGESIZE = sum(item_size[i]) i=0, item_count (do not record) item_offset use to record each memfd offset if exist, else 0. Huan Y

Re: [PATCH 1/5] udmabuf: cancel mmap page fault, direct map it

2024-08-01 Thread Huan Yang
在 2024/8/1 18:50, Christian König 写道: Am 01.08.24 um 12:45 schrieb Huan Yang: The current udmabuf mmap uses a page fault mechanism to populate the vma. However, the current udmabuf has already obtained and pinned the folio upon completion of the creation.This means that the physical memory

[PATCH 5/5] udmabuf: remove folio pin list

2024-08-01 Thread Huan Yang
s, we can accept the overhead of the udmabuf_folio structure and the performance loss of traversing the list during unpinning. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 149 +- 1 file changed, 66 insertions(+), 83 deletions(-) diff --git a/drive

[PATCH 0/5] udmbuf bug fix and some improvements

2024-08-01 Thread Huan Yang
* PAGESIZE = sum(folios_size(folios[i])) i=0->nr_folios pagecount * PAGESIZE = sum(item_size[i]) i=0, item_count (do not record) item_offset use to record each memfd offset if exist, else 0. Huan Yang (5): udmabuf: cancel mmap page fault, direct map it udmabuf: change folios array from

[PATCH 3/5] udmabuf: fix vmap_udmabuf error page set

2024-08-01 Thread Huan Yang
page, and then map into vmalloc area Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index a915714c5dce..7ed532342d7f 100644 --- a/drivers/dma-buf/udma

[PATCH 1/5] udmabuf: cancel mmap page fault, direct map it

2024-08-01 Thread Huan Yang
access to virtual addresses needs to trap into kernel mode. Therefore, when creating a large size udmabuf, this represents a considerable overhead. Therefore, the current patch removes the page fault method of mmap and instead fills it directly when mmap is triggered. Signed-off-by: Huan Yang

[PATCH 2/5] udmabuf: change folios array from kmalloc to kvmalloc

2024-08-01 Thread Huan Yang
cation for any size and does not affect the performance of kmalloc allocations. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index d69aea

[PATCH 4/5] udmabuf: add get_sg_table helper function

2024-08-01 Thread Huan Yang
. Or else, try alloc a new sgt, and cmpxchg to set it. When the swap fails, it means that another process has set sg correctly. Therefore, we reuse the new sg. If trigger by device, need invoke map to sync it. Signed-off-by: Huan Yang --- drivers/dma-buf/udmab

Re: [PATCH v2 0/5] Introduce DMA_HEAP_ALLOC_AND_READ_FILE heap flag

2024-07-31 Thread Huan Yang
在 2024/8/1 4:46, Daniel Vetter 写道: On Tue, Jul 30, 2024 at 08:04:04PM +0800, Huan Yang wrote: 在 2024/7/30 17:05, Huan Yang 写道: 在 2024/7/30 16:56, Daniel Vetter 写道: [? daniel.vet...@ffwll.ch ? https://aka.ms/LearnAboutSenderIdentification?] On Tue, Jul 30, 2024

Re: [PATCH v3] udmabuf: use kmem_cache to alloc udmabuf folio

2024-07-31 Thread Huan Yang
在 2024/8/1 1:11, Christophe JAILLET 写道: [Some people who received this message don't often get email from christophe.jail...@wanadoo.fr. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] Le 31/07/2024 à 09:37, Huan Yang a écrit : The current udmabuf_

[PATCH 2/2] udmabuf: make udmabuf folios and offsets set more readable

2024-07-31 Thread Huan Yang
nto loop variables. Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 40 --- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 6604d91e7072..0285194e6b51 100644 --- a/drivers/dma-

[PATCH 1/2] udmabuf: fix vmap_udmabuf error page set

2024-07-31 Thread Huan Yang
page, and then map into vmalloc area Signed-off-by: Huan Yang --- drivers/dma-buf/udmabuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 047c3cd2ceff..6604d91e7072 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/dr

[PATCH v3] udmabuf: use kmem_cache to alloc udmabuf folio

2024-07-31 Thread Huan Yang
, while also avoiding memory waste. Signed-off-by: Huan Yang --- v3 -> v2: fix error description. v2 -> v1: fix double unregister, remove unlikely. drivers/dma-buf/udmabuf.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drive

Re: [PATCH v2] udmabuf: use kmem_cache to alloc udmabuf folio

2024-07-31 Thread Huan Yang
在 2024/7/31 14:26, Huan Yang 写道: The current udmabuf_folio contains a list_head and the corresponding folio pointer, with a size of 24 bytes. udmabuf_folio uses kmalloc to allocate memory. However, kmalloc is a public pool, starting from 64 bytes. This means that each udmabuf_folio allocation

  1   2   >