[PATCH 2/2] mm/gup: Remove page_folio() in memfd_pin_folios()

Vishal Moola (Oracle) posted 2 patches 9 months, 2 weeks ago
[PATCH 2/2] mm/gup: Remove page_folio() in memfd_pin_folios()
Posted by Vishal Moola (Oracle) 9 months, 2 weeks ago
We can get the folio directly from the folio batch, so remove the
unnecessary page_folio() call.

Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
 mm/gup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/gup.c b/mm/gup.c
index 1fb8f3b9a493..795fd94f379d 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -3640,7 +3640,7 @@ long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end,
 			}
 
 			for (i = 0; i < nr_found; i++) {
-				folio = page_folio(&fbatch.folios[i]->page);
+				folio = fbatch.folios[i];
 
 				if (try_grab_folio(folio, 1, FOLL_PIN)) {
 					folio_batch_release(&fbatch);
-- 
2.49.0
RE: [PATCH 2/2] mm/gup: Remove page_folio() in memfd_pin_folios()
Posted by Kasireddy, Vivek 9 months, 1 week ago
Hi Vishal,

> Subject: [PATCH 2/2] mm/gup: Remove page_folio() in memfd_pin_folios()
> 
> We can get the folio directly from the folio batch, so remove the
> unnecessary page_folio() call.
> 
> Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
> ---
>  mm/gup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 1fb8f3b9a493..795fd94f379d 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -3640,7 +3640,7 @@ long memfd_pin_folios(struct file *memfd, loff_t
> start, loff_t end,
>  			}
> 
>  			for (i = 0; i < nr_found; i++) {
> -				folio = page_folio(&fbatch.folios[i]->page);
> +				folio = fbatch.folios[i];
I don't recall why I chose to extract the folio in a roundabout way. LGTM.

Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>

Thanks,
Vivek

> 
>  				if (try_grab_folio(folio, 1, FOLL_PIN)) {
>  					folio_batch_release(&fbatch);
> --
> 2.49.0
Re: [PATCH 2/2] mm/gup: Remove page_folio() in memfd_pin_folios()
Posted by David Hildenbrand 9 months, 2 weeks ago
On 30.04.25 03:00, Vishal Moola (Oracle) wrote:
> We can get the folio directly from the folio batch, so remove the
> unnecessary page_folio() call.
> 
> Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
> ---
>   mm/gup.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 1fb8f3b9a493..795fd94f379d 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -3640,7 +3640,7 @@ long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end,
>   			}
>   
>   			for (i = 0; i < nr_found; i++) {
> -				folio = page_folio(&fbatch.folios[i]->page);
> +				folio = fbatch.folios[i];
>   
>   				if (try_grab_folio(folio, 1, FOLL_PIN)) {
>   					folio_batch_release(&fbatch);

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb