linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gup: optimize longterm pin_user_pages() for large folio
@ 2025-06-04  3:15 lizhe.67
  2025-06-04  3:44 ` Andrew Morton
  2025-06-04  8:12 ` David Hildenbrand
  0 siblings, 2 replies; 5+ messages in thread
From: lizhe.67 @ 2025-06-04  3:15 UTC (permalink / raw)
  To: akpm, david, jgg, jhubbard, peterx
  Cc: linux-mm, linux-kernel, dev.jain, muchun.song, lizhe.67

From: Li Zhe <lizhe.67@bytedance.com>

In the current implementation of the longterm pin_user_pages() function,
we invoke the collect_longterm_unpinnable_folios() function. This function
iterates through the list to check whether each folio belongs to the
"longterm_unpinnabled" category. The folios in this list essentially
correspond to a contiguous region of user-space addresses, with each folio
representing a physical address in increments of PAGESIZE. If this
user-space address range is mapped with large folio, we can optimize the
performance of function pin_user_pages() by reducing the frequency of
memory accesses using READ_ONCE. This patch leverages this approach to
achieve performance improvements.

The performance test results obtained through the gup_test tool from the
kernel source tree are as follows. We achieve an improvement of over 70%
for large folio with pagesize=2M. For normal page, we have only observed
a very slight degradation in performance.

Without this patch:

    [root@localhost ~] ./gup_test -HL -m 8192 -n 512
    TAP version 13
    1..1
    # PIN_LONGTERM_BENCHMARK: Time: get:13623 put:10799 us#
    ok 1 ioctl status 0
    # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
    [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
    TAP version 13
    1..1
    # PIN_LONGTERM_BENCHMARK: Time: get:129733 put:31753 us#
    ok 1 ioctl status 0
    # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0

With this patch:

    [root@localhost ~] ./gup_test -HL -m 8192 -n 512
    TAP version 13
    1..1
    # PIN_LONGTERM_BENCHMARK: Time: get:4075 put:10792 us#
    ok 1 ioctl status 0
    # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
    [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
    TAP version 13
    1..1
    # PIN_LONGTERM_BENCHMARK: Time: get:130727 put:31763 us#
    ok 1 ioctl status 0
    # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0

Signed-off-by: Li Zhe <lizhe.67@bytedance.com>
---
Changelogs:

v1->v2:
- Modify some unreliable code.
- Update performance test data.

v1 patch: https://lore.kernel.org/all/20250530092351.32709-1-lizhe.67@bytedance.com/

 mm/gup.c | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 84461d384ae2..57fd324473a1 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2317,6 +2317,31 @@ static void pofs_unpin(struct pages_or_folios *pofs)
 		unpin_user_pages(pofs->pages, pofs->nr_entries);
 }
 
+static struct folio *pofs_next_folio(struct folio *folio,
+				struct pages_or_folios *pofs, long *index_ptr)
+{
+	long i = *index_ptr + 1;
+
+	if (!pofs->has_folios) {
+		unsigned long start_pfn = folio_pfn(folio);
+		unsigned long end_pfn = start_pfn + folio_nr_pages(folio);
+
+		for (; i < pofs->nr_entries; i++) {
+			unsigned long pfn = page_to_pfn(pofs->pages[i]);
+
+			/* Is this page part of this folio? */
+			if ((pfn < start_pfn) || (pfn >= end_pfn))
+				break;
+		}
+	}
+
+	if (unlikely(i == pofs->nr_entries))
+		return NULL;
+	*index_ptr = i;
+
+	return pofs_get_folio(pofs, i);
+}
+
 /*
  * Returns the number of collected folios. Return value is always >= 0.
  */
@@ -2324,16 +2349,12 @@ static void collect_longterm_unpinnable_folios(
 		struct list_head *movable_folio_list,
 		struct pages_or_folios *pofs)
 {
-	struct folio *prev_folio = NULL;
 	bool drain_allow = true;
-	unsigned long i;
-
-	for (i = 0; i < pofs->nr_entries; i++) {
-		struct folio *folio = pofs_get_folio(pofs, i);
+	long i = 0;
+	struct folio *folio;
 
-		if (folio == prev_folio)
-			continue;
-		prev_folio = folio;
+	for (folio = pofs_get_folio(pofs, 0); folio;
+			folio = pofs_next_folio(folio, pofs, &i)) {
 
 		if (folio_is_longterm_pinnable(folio))
 			continue;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gup: optimize longterm pin_user_pages() for large folio
  2025-06-04  3:15 [PATCH v2] gup: optimize longterm pin_user_pages() for large folio lizhe.67
@ 2025-06-04  3:44 ` Andrew Morton
  2025-06-04  7:58   ` lizhe.67
  2025-06-04  8:12 ` David Hildenbrand
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2025-06-04  3:44 UTC (permalink / raw)
  To: lizhe.67
  Cc: david, jgg, jhubbard, peterx, linux-mm, linux-kernel, dev.jain,
	muchun.song

On Wed,  4 Jun 2025 11:15:36 +0800 lizhe.67@bytedance.com wrote:

> From: Li Zhe <lizhe.67@bytedance.com>
> 
> In the current implementation of the longterm pin_user_pages() function,
> we invoke the collect_longterm_unpinnable_folios() function. This function
> iterates through the list to check whether each folio belongs to the
> "longterm_unpinnabled" category. The folios in this list essentially
> correspond to a contiguous region of user-space addresses, with each folio
> representing a physical address in increments of PAGESIZE. If this
> user-space address range is mapped with large folio, we can optimize the
> performance of function pin_user_pages() by reducing the frequency of
> memory accesses using READ_ONCE. This patch leverages this approach to
> achieve performance improvements.
> 
> The performance test results obtained through the gup_test tool from the
> kernel source tree are as follows. We achieve an improvement of over 70%
> for large folio with pagesize=2M. For normal page, we have only observed
> a very slight degradation in performance.
> 
> Without this patch:
> 
>     [root@localhost ~] ./gup_test -HL -m 8192 -n 512
>     TAP version 13
>     1..1
>     # PIN_LONGTERM_BENCHMARK: Time: get:13623 put:10799 us#
>     ok 1 ioctl status 0
>     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>     [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
>     TAP version 13
>     1..1
>     # PIN_LONGTERM_BENCHMARK: Time: get:129733 put:31753 us#
>     ok 1 ioctl status 0
>     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> 
> With this patch:
> 
>     [root@localhost ~] ./gup_test -HL -m 8192 -n 512
>     TAP version 13
>     1..1
>     # PIN_LONGTERM_BENCHMARK: Time: get:4075 put:10792 us#
>     ok 1 ioctl status 0
>     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>     [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
>     TAP version 13
>     1..1
>     # PIN_LONGTERM_BENCHMARK: Time: get:130727 put:31763 us#
>     ok 1 ioctl status 0
>     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0

I see no READ_ONCE()s in the patch and I had to go off and read the v1
review to discover that the READ_ONCE is invoked in
page_folio()->_compound_head().  Please help us out by including such
details in the changelogs.

Is it credible that a humble READ_ONCE could yield a 3x improvement in
one case?  Why would this happen?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gup: optimize longterm pin_user_pages() for large folio
  2025-06-04  3:44 ` Andrew Morton
@ 2025-06-04  7:58   ` lizhe.67
  0 siblings, 0 replies; 5+ messages in thread
From: lizhe.67 @ 2025-06-04  7:58 UTC (permalink / raw)
  To: akpm
  Cc: david, dev.jain, jgg, jhubbard, linux-kernel, linux-mm, lizhe.67,
	muchun.song, peterx

On Tue, 3 Jun 2025 20:44:14 -0700, akpm@linux-foundation.org wrote:

> On Wed,  4 Jun 2025 11:15:36 +0800 lizhe.67@bytedance.com wrote:
> 
> > From: Li Zhe <lizhe.67@bytedance.com>
> > 
> > In the current implementation of the longterm pin_user_pages() function,
> > we invoke the collect_longterm_unpinnable_folios() function. This function
> > iterates through the list to check whether each folio belongs to the
> > "longterm_unpinnabled" category. The folios in this list essentially
> > correspond to a contiguous region of user-space addresses, with each folio
> > representing a physical address in increments of PAGESIZE. If this
> > user-space address range is mapped with large folio, we can optimize the
> > performance of function pin_user_pages() by reducing the frequency of
> > memory accesses using READ_ONCE. This patch leverages this approach to
> > achieve performance improvements.
> > 
> > The performance test results obtained through the gup_test tool from the
> > kernel source tree are as follows. We achieve an improvement of over 70%
> > for large folio with pagesize=2M. For normal page, we have only observed
> > a very slight degradation in performance.
> > 
> > Without this patch:
> > 
> >     [root@localhost ~] ./gup_test -HL -m 8192 -n 512
> >     TAP version 13
> >     1..1
> >     # PIN_LONGTERM_BENCHMARK: Time: get:13623 put:10799 us#
> >     ok 1 ioctl status 0
> >     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> >     [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
> >     TAP version 13
> >     1..1
> >     # PIN_LONGTERM_BENCHMARK: Time: get:129733 put:31753 us#
> >     ok 1 ioctl status 0
> >     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> > 
> > With this patch:
> > 
> >     [root@localhost ~] ./gup_test -HL -m 8192 -n 512
> >     TAP version 13
> >     1..1
> >     # PIN_LONGTERM_BENCHMARK: Time: get:4075 put:10792 us#
> >     ok 1 ioctl status 0
> >     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> >     [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
> >     TAP version 13
> >     1..1
> >     # PIN_LONGTERM_BENCHMARK: Time: get:130727 put:31763 us#
> >     ok 1 ioctl status 0
> >     # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> 
> I see no READ_ONCE()s in the patch and I had to go off and read the v1
> review to discover that the READ_ONCE is invoked in
> page_folio()->_compound_head().  Please help us out by including such
> details in the changelogs.

Sorry for the inconvenience. I will refine the wording of this part in
the next version.

> Is it credible that a humble READ_ONCE could yield a 3x improvement in
> one case?  Why would this happen?

Sorry for the incomplete description. I believe that this optimization
is the result of multiple factors working together. In addition to
reducing the use of READ_ONCE(), when dealing with a large folio, we
simplify the check from comparing with prev_folio after invoking
pofs_get_folio() to determine if the next page is within the folio.
This change reduces the number of branches and increase cache hit rates.
The overall effect is a combination of these optimizations. I will
incorporate these details into the commit message in the next version.

Thanks,
Zhe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gup: optimize longterm pin_user_pages() for large folio
  2025-06-04  3:15 [PATCH v2] gup: optimize longterm pin_user_pages() for large folio lizhe.67
  2025-06-04  3:44 ` Andrew Morton
@ 2025-06-04  8:12 ` David Hildenbrand
  2025-06-04  9:11   ` lizhe.67
  1 sibling, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2025-06-04  8:12 UTC (permalink / raw)
  To: lizhe.67, akpm, jgg, jhubbard, peterx
  Cc: linux-mm, linux-kernel, dev.jain, muchun.song

On 04.06.25 05:15, lizhe.67@bytedance.com wrote:
> From: Li Zhe <lizhe.67@bytedance.com>
> 
> In the current implementation of the longterm pin_user_pages() function,
> we invoke the collect_longterm_unpinnable_folios() function. This function
> iterates through the list to check whether each folio belongs to the
> "longterm_unpinnabled" category. The folios in this list essentially
> correspond to a contiguous region of user-space addresses, with each folio
> representing a physical address in increments of PAGESIZE. If this
> user-space address range is mapped with large folio, we can optimize the
> performance of function pin_user_pages() by reducing the frequency of
> memory accesses using READ_ONCE. This patch leverages this approach to
> achieve performance improvements.
> 
> The performance test results obtained through the gup_test tool from the
> kernel source tree are as follows. We achieve an improvement of over 70%
> for large folio with pagesize=2M. For normal page, we have only observed
> a very slight degradation in performance.
> 
> Without this patch:
> 
>      [root@localhost ~] ./gup_test -HL -m 8192 -n 512
>      TAP version 13
>      1..1
>      # PIN_LONGTERM_BENCHMARK: Time: get:13623 put:10799 us#
>      ok 1 ioctl status 0
>      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>      [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
>      TAP version 13
>      1..1
>      # PIN_LONGTERM_BENCHMARK: Time: get:129733 put:31753 us#
>      ok 1 ioctl status 0
>      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> 
> With this patch:
> 
>      [root@localhost ~] ./gup_test -HL -m 8192 -n 512
>      TAP version 13
>      1..1
>      # PIN_LONGTERM_BENCHMARK: Time: get:4075 put:10792 us#
>      ok 1 ioctl status 0
>      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>      [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
>      TAP version 13
>      1..1
>      # PIN_LONGTERM_BENCHMARK: Time: get:130727 put:31763 us#
>      ok 1 ioctl status 0
>      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> 
> Signed-off-by: Li Zhe <lizhe.67@bytedance.com>
> ---
> Changelogs:
> 
> v1->v2:
> - Modify some unreliable code.
> - Update performance test data.
> 
> v1 patch: https://lore.kernel.org/all/20250530092351.32709-1-lizhe.67@bytedance.com/
> 
>   mm/gup.c | 37 +++++++++++++++++++++++++++++--------
>   1 file changed, 29 insertions(+), 8 deletions(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 84461d384ae2..57fd324473a1 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2317,6 +2317,31 @@ static void pofs_unpin(struct pages_or_folios *pofs)
>   		unpin_user_pages(pofs->pages, pofs->nr_entries);
>   }
>   
> +static struct folio *pofs_next_folio(struct folio *folio,
> +				struct pages_or_folios *pofs, long *index_ptr)
> +{
> +	long i = *index_ptr + 1;
> +
> +	if (!pofs->has_folios) {

&& folio_test_large(folio)

To avoid all that for small folios.

> +		unsigned long start_pfn = folio_pfn(folio);> +		unsigned long end_pfn = start_pfn + folio_nr_pages(folio);

I guess both could be const

> +> +		for (; i < pofs->nr_entries; i++) {
> +			unsigned long pfn = page_to_pfn(pofs->pages[i]);
> +
> +			/* Is this page part of this folio? */
> +			if ((pfn < start_pfn) || (pfn >= end_pfn))


No need for the inner ()

> +				break;
> +		}
> +	}
> +
> +	if (unlikely(i == pofs->nr_entries))
> +		return NULL;
> +	*index_ptr = i;> +
> +	return pofs_get_folio(pofs, i);

We're now doing two "pofs->has_folios" checks. Maybe the compiler is
smart enough to figure that out.

> +}
> +
>   /*>    * Returns the number of collected folios. Return value is always >= 0.
>    */
> @@ -2324,16 +2349,12 @@ static void collect_longterm_unpinnable_folios(
>   		struct list_head *movable_folio_list,
>   		struct pages_or_folios *pofs)
>   {
> -	struct folio *prev_folio = NULL;
>   	bool drain_allow = true;
> -	unsigned long i;
> -
> -	for (i = 0; i < pofs->nr_entries; i++) {
> -		struct folio *folio = pofs_get_folio(pofs, i);
> +	long i = 0;
> +	struct folio *folio;

Please keep the reverse christmas tree where we have it. Why
the change from "unsigned long" -> "long" ?

>   
> -		if (folio == prev_folio)
> -			continue;
> -		prev_folio = folio;
> +	for (folio = pofs_get_folio(pofs, 0); folio;
> +			folio = pofs_next_folio(folio, pofs, &i)) {

Please indent as

for (folio = pofs_get_folio(pofs, 0); folio;
      folio = pofs_next_folio(folio, pofs, &i)) {

But the usage of "0" and "&i" is a bit suboptimal.

for (folio = pofs_get_folio(pofs, i); folio;
      folio = pofs_next_folio(folio, pofs, &i)) {

Might be better.

-- 
Cheers,

David / dhildenb


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] gup: optimize longterm pin_user_pages() for large folio
  2025-06-04  8:12 ` David Hildenbrand
@ 2025-06-04  9:11   ` lizhe.67
  0 siblings, 0 replies; 5+ messages in thread
From: lizhe.67 @ 2025-06-04  9:11 UTC (permalink / raw)
  To: david
  Cc: akpm, dev.jain, jgg, jhubbard, linux-kernel, linux-mm, lizhe.67,
	muchun.song, peterx

On Wed, 4 Jun 2025 10:12:00 +0200, david@redhat.com wrote:

> On 04.06.25 05:15, lizhe.67@bytedance.com wrote:
> > From: Li Zhe <lizhe.67@bytedance.com>
> > 
> > In the current implementation of the longterm pin_user_pages() function,
> > we invoke the collect_longterm_unpinnable_folios() function. This function
> > iterates through the list to check whether each folio belongs to the
> > "longterm_unpinnabled" category. The folios in this list essentially
> > correspond to a contiguous region of user-space addresses, with each folio
> > representing a physical address in increments of PAGESIZE. If this
> > user-space address range is mapped with large folio, we can optimize the
> > performance of function pin_user_pages() by reducing the frequency of
> > memory accesses using READ_ONCE. This patch leverages this approach to
> > achieve performance improvements.
> > 
> > The performance test results obtained through the gup_test tool from the
> > kernel source tree are as follows. We achieve an improvement of over 70%
> > for large folio with pagesize=2M. For normal page, we have only observed
> > a very slight degradation in performance.
> > 
> > Without this patch:
> > 
> >      [root@localhost ~] ./gup_test -HL -m 8192 -n 512
> >      TAP version 13
> >      1..1
> >      # PIN_LONGTERM_BENCHMARK: Time: get:13623 put:10799 us#
> >      ok 1 ioctl status 0
> >      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> >      [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
> >      TAP version 13
> >      1..1
> >      # PIN_LONGTERM_BENCHMARK: Time: get:129733 put:31753 us#
> >      ok 1 ioctl status 0
> >      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> > 
> > With this patch:
> > 
> >      [root@localhost ~] ./gup_test -HL -m 8192 -n 512
> >      TAP version 13
> >      1..1
> >      # PIN_LONGTERM_BENCHMARK: Time: get:4075 put:10792 us#
> >      ok 1 ioctl status 0
> >      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> >      [root@localhost ~]# ./gup_test -LT -m 8192 -n 512
> >      TAP version 13
> >      1..1
> >      # PIN_LONGTERM_BENCHMARK: Time: get:130727 put:31763 us#
> >      ok 1 ioctl status 0
> >      # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> > 
> > Signed-off-by: Li Zhe <lizhe.67@bytedance.com>
> > ---
> > Changelogs:
> > 
> > v1->v2:
> > - Modify some unreliable code.
> > - Update performance test data.
> > 
> > v1 patch: https://lore.kernel.org/all/20250530092351.32709-1-lizhe.67@bytedance.com/
> > 
> >   mm/gup.c | 37 +++++++++++++++++++++++++++++--------
> >   1 file changed, 29 insertions(+), 8 deletions(-)
> > 
> > diff --git a/mm/gup.c b/mm/gup.c
> > index 84461d384ae2..57fd324473a1 100644
> > --- a/mm/gup.c
> > +++ b/mm/gup.c
> > @@ -2317,6 +2317,31 @@ static void pofs_unpin(struct pages_or_folios *pofs)
> >   		unpin_user_pages(pofs->pages, pofs->nr_entries);
> >   }
> >   
> > +static struct folio *pofs_next_folio(struct folio *folio,
> > +				struct pages_or_folios *pofs, long *index_ptr)
> > +{
> > +	long i = *index_ptr + 1;
> > +
> > +	if (!pofs->has_folios) {
> 
> && folio_test_large(folio)
> 
> To avoid all that for small folios.

Great! This approach will minimize the impact on small folios.

> > +		unsigned long start_pfn = folio_pfn(folio);> +		unsigned long end_pfn = start_pfn + folio_nr_pages(folio);
> 
> I guess both could be const
> 
> > +> +		for (; i < pofs->nr_entries; i++) {
> > +			unsigned long pfn = page_to_pfn(pofs->pages[i]);
> > +
> > +			/* Is this page part of this folio? */
> > +			if ((pfn < start_pfn) || (pfn >= end_pfn))
> 
> No need for the inner ()
> 
> > +				break;
> > +		}
> > +	}
> > +
> > +	if (unlikely(i == pofs->nr_entries))
> > +		return NULL;
> > +	*index_ptr = i;> +
> > +	return pofs_get_folio(pofs, i);
> 
> We're now doing two "pofs->has_folios" checks. Maybe the compiler is
> smart enough to figure that out.

I also hope that the compiler can optimize this logic.

> > +}
> > +
> >   /*>    * Returns the number of collected folios. Return value is always >= 0.
> >    */
> > @@ -2324,16 +2349,12 @@ static void collect_longterm_unpinnable_folios(
> >   		struct list_head *movable_folio_list,
> >   		struct pages_or_folios *pofs)
> >   {
> > -	struct folio *prev_folio = NULL;
> >   	bool drain_allow = true;
> > -	unsigned long i;
> > -
> > -	for (i = 0; i < pofs->nr_entries; i++) {
> > -		struct folio *folio = pofs_get_folio(pofs, i);
> > +	long i = 0;
> > +	struct folio *folio;
> 
> Please keep the reverse christmas tree where we have it. Why
> the change from "unsigned long" -> "long" ?

This is because I want to match the type of pages_or_folios->nr_entries.
I'm not sure if it's necessary.

> >   
> > -		if (folio == prev_folio)
> > -			continue;
> > -		prev_folio = folio;
> > +	for (folio = pofs_get_folio(pofs, 0); folio;
> > +			folio = pofs_next_folio(folio, pofs, &i)) {
> 
> Please indent as
> 
> for (folio = pofs_get_folio(pofs, 0); folio;
>       folio = pofs_next_folio(folio, pofs, &i)) {
> 
> But the usage of "0" and "&i" is a bit suboptimal.
> 
> for (folio = pofs_get_folio(pofs, i); folio;
>       folio = pofs_next_folio(folio, pofs, &i)) {
> 
> Might be better.

Thank you for all your suggestions! I will complete the amendments
as you advised.

Thanks,
Zhe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-04  9:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-04  3:15 [PATCH v2] gup: optimize longterm pin_user_pages() for large folio lizhe.67
2025-06-04  3:44 ` Andrew Morton
2025-06-04  7:58   ` lizhe.67
2025-06-04  8:12 ` David Hildenbrand
2025-06-04  9:11   ` lizhe.67

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).