linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: convert hugetlb_change_protection() to folios
@ 2025-05-28 19:20 Sidhartha Kumar
  2025-05-28 22:56 ` Matthew Wilcox
  2025-06-03  5:28 ` Oscar Salvador
  0 siblings, 2 replies; 3+ messages in thread
From: Sidhartha Kumar @ 2025-05-28 19:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, akpm, willy, muchun.song, osalvador, Sidhartha Kumar

The for loop inside hugetlb_change_protection() increments by the huge
page size:

psize = huge_page_size(h);
for (; address < end; address += psize)

so we are operating on the head page of the huge pages between address
and end. We can safely convert the struct page usage to struct folio.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
 mm/hugetlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index df1759e0b7fe..25d3768c6eca 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -7185,11 +7185,11 @@ long hugetlb_change_protection(struct vm_area_struct *vma,
 			/* Nothing to do. */
 		} else if (unlikely(is_hugetlb_entry_migration(pte))) {
 			swp_entry_t entry = pte_to_swp_entry(pte);
-			struct page *page = pfn_swap_entry_to_page(entry);
+			struct folio *folio = pfn_swap_entry_folio(entry);
 			pte_t newpte = pte;
 
 			if (is_writable_migration_entry(entry)) {
-				if (PageAnon(page))
+				if (folio_test_anon(folio))
 					entry = make_readable_exclusive_migration_entry(
 								swp_offset(entry));
 				else
-- 
2.43.0




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

* Re: [PATCH] mm/hugetlb: convert hugetlb_change_protection() to folios
  2025-05-28 19:20 [PATCH] mm/hugetlb: convert hugetlb_change_protection() to folios Sidhartha Kumar
@ 2025-05-28 22:56 ` Matthew Wilcox
  2025-06-03  5:28 ` Oscar Salvador
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2025-05-28 22:56 UTC (permalink / raw)
  To: Sidhartha Kumar; +Cc: linux-kernel, linux-mm, akpm, muchun.song, osalvador

On Wed, May 28, 2025 at 03:20:13PM -0400, Sidhartha Kumar wrote:
> The for loop inside hugetlb_change_protection() increments by the huge
> page size:
> 
> psize = huge_page_size(h);
> for (; address < end; address += psize)
> 
> so we are operating on the head page of the huge pages between address
> and end. We can safely convert the struct page usage to struct folio.
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>

Reviewwd-by: Matthew Wilcox (Oracle) <willy@infradead.org>


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

* Re: [PATCH] mm/hugetlb: convert hugetlb_change_protection() to folios
  2025-05-28 19:20 [PATCH] mm/hugetlb: convert hugetlb_change_protection() to folios Sidhartha Kumar
  2025-05-28 22:56 ` Matthew Wilcox
@ 2025-06-03  5:28 ` Oscar Salvador
  1 sibling, 0 replies; 3+ messages in thread
From: Oscar Salvador @ 2025-06-03  5:28 UTC (permalink / raw)
  To: Sidhartha Kumar; +Cc: linux-kernel, linux-mm, akpm, willy, muchun.song

On Wed, May 28, 2025 at 03:20:13PM -0400, Sidhartha Kumar wrote:
> The for loop inside hugetlb_change_protection() increments by the huge
> page size:
> 
> psize = huge_page_size(h);
> for (; address < end; address += psize)
> 
> so we are operating on the head page of the huge pages between address
> and end. We can safely convert the struct page usage to struct folio.
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>


-- 
Oscar Salvador
SUSE Labs


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

end of thread, other threads:[~2025-06-03  5:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-28 19:20 [PATCH] mm/hugetlb: convert hugetlb_change_protection() to folios Sidhartha Kumar
2025-05-28 22:56 ` Matthew Wilcox
2025-06-03  5:28 ` Oscar Salvador

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).