mm: huge_memory: convert split_huge_pages_all() to use a folio
Subsystems (2)
PATCH v2 1/1 mm: huge_memory: convert split_huge_pages_all() to use a folio
Straightforwardly convert split_huge_pages_all() to use a folio.
---
- adjust indenting of code pointed by Matthew
mm/huge_memory.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
mm/huge_memory.c +17 -8
@@ -2932,6 +2932,7 @@ static void split_huge_pages_all(void) {struct zone *zone;struct page *page; +struct folio *folio;unsigned long pfn, max_zone_pfn;unsigned long total =0 , split =0 ;
@@ -2944,24 +2945,32 @@ static void split_huge_pages_all(void)int nr_pages; page =pfn_to_online_page (pfn); -if (!page || !get_page_unless_zero (page)) +if (!page ||PageTail (page)) +continue ; + folio =page_folio (page); +if (!folio_try_get (folio))continue ; -if (zone !=page_zone (page)) +if (unlikely (page_folio (page) != folio)) + goto next; + +if (zone !=folio_zone (folio)) goto next; -if (!PageHead (page) ||PageHuge (page) || !PageLRU (page)) +if (!folio_test_large (folio) || +folio_test_hugetlb (folio) || + !folio_test_lru (folio)) goto next; total++; -lock_page (page); - nr_pages =thp_nr_pages (page); -if (!split_huge_page (page)) +folio_lock (folio); + nr_pages =folio_nr_pages (folio); +if (!split_folio (folio)) split++; pfn += nr_pages -1 ; -unlock_page (page); +folio_unlock (folio); next: -put_page (page); +folio_put (folio);cond_resched (); } }
Signature · 1 line
2.35.3
Andrew Morton
maintainerQuoted 21 lines · On Fri, 30 Dec 2022 17:30:20 +0800 Kefeng Wang <[email protected]>…
Straightforwardly convert
split_huge_pages_all()to use a folio....
mm/huge_memory.c +3
-1@@ -2932,6 +2932,7 @@ static void split_huge_pages_all(void) {struct zone *zone;struct page *page; +struct folio *folio;unsigned long pfn, max_zone_pfn;unsigned long total =0 , split =0 ;@@ -2944,24 +2945,32 @@ static void split_huge_pages_all(void)int nr_pages; page =pfn_to_online_page (pfn); -if (!page || !get_page_unless_zero (page)) +if (!page ||PageTail (page)) +continue ;
mm/huge_memory.c static void split_huge_pages_all(void) · line 2958
Quoted 10 lines
mm/huge_memory.c +6
-1+ folio =page_folio (page); +if (!folio_try_get (folio))continue ; -if (zone !=page_zone (page)) +if (unlikely (page_folio (page) != folio)) + goto next; + +if (zone !=folio_zone (folio)) goto next;
I'm still not understanding the above hunk. Why is the "page_folio(page) != folio" check added? Should it be commented?
Quoted 25 lines
mm/huge_memory.c +8
-6-if (!PageHead (page) ||PageHuge (page) || !PageLRU (page)) +if (!folio_test_large (folio) || +folio_test_hugetlb (folio) || + !folio_test_lru (folio)) goto next; total++; -lock_page (page); - nr_pages =thp_nr_pages (page); -if (!split_huge_page (page)) +folio_lock (folio); + nr_pages =folio_nr_pages (folio); +if (!split_folio (folio)) split++; pfn += nr_pages -1 ; -unlock_page (page); +folio_unlock (folio); next: -put_page (page); +folio_put (folio);cond_resched (); } }Signature · 1 line
2.35.3
Quoted 27 lines · Andrew Morton
Quoted 25 lines · On Fri, 30 Dec 2022 17:30:20 +0800 Kefeng Wang <[email protected]>…
Straightforwardly convert
split_huge_pages_all()to use a folio....
mm/huge_memory.c +5
-1@@ -2932,6 +2932,7 @@ static void split_huge_pages_all(void) {struct zone *zone;struct page *page; +struct folio *folio;unsigned long pfn, max_zone_pfn;unsigned long total =0 , split =0 ;@@ -2944,24 +2945,32 @@ static void split_huge_pages_all(void)int nr_pages; page =pfn_to_online_page (pfn); -if (!page || !get_page_unless_zero (page)) +if (!page ||PageTail (page)) +continue ; + folio =page_folio (page); +if (!folio_try_get (folio))continue ;
Quoted 9 lines
mm/huge_memory.c static void split_huge_pages_all(void) · line 2958
Quoted 6 lines
mm/huge_memory.c +4
-1-if (zone !=page_zone (page)) +if (unlikely (page_folio (page) != folio)) + goto next; + +if (zone !=folio_zone (folio)) goto next;I'm still not understanding the above hunk. Why is the "
page_folio(page)!= folio" check added? Should it be commented?
There is a comment in try_get_folio(), is it enough?
Andrew Morton
maintainerQuoted 40 lines · On Tue, 3 Jan 2023 09:58:36 +0800 Kefeng Wang <[email protected]>…
Quoted 27 lines · Andrew Morton
Quoted 25 lines · On Fri, 30 Dec 2022 17:30:20 +0800 Kefeng Wang <[email protected]>…
Straightforwardly convert
split_huge_pages_all()to use a folio....
mm/huge_memory.c +5
-1@@ -2932,6 +2932,7 @@ static void split_huge_pages_all(void) {struct zone *zone;struct page *page; +struct folio *folio;unsigned long pfn, max_zone_pfn;unsigned long total =0 , split =0 ;@@ -2944,24 +2945,32 @@ static void split_huge_pages_all(void)int nr_pages; page =pfn_to_online_page (pfn); -if (!page || !get_page_unless_zero (page)) +if (!page ||PageTail (page)) +continue ; + folio =page_folio (page); +if (!folio_try_get (folio))continue ;Quoted 9 lines
mm/huge_memory.c static void split_huge_pages_all(void) · line 2958
Quoted 6 lines
mm/huge_memory.c +4
-1-if (zone !=page_zone (page)) +if (unlikely (page_folio (page) != folio)) + goto next; + +if (zone !=folio_zone (folio)) goto next;I'm still not understanding the above hunk. Why is the "
page_folio(page)!= folio" check added? Should it be commented?
Quoted 1 line
There is a comment in
try_get_folio(), is it enough?
Nobody would think to look at a private function in gup.c.
I suggest this folio_try_get() rule be documented at the folio_try_get() implementation site.
Most callers do perform this check, but not the ones in vmscan.c?
Quoted 42 lines · Andrew Morton
Quoted 40 lines · On Tue, 3 Jan 2023 09:58:36 +0800 Kefeng Wang <[email protected]>…
Quoted 36 lines · Andrew Morton
Quoted 21 lines · On Fri, 30 Dec 2022 17:30:20 +0800 Kefeng Wang <[email protected]>…
Straightforwardly convert
split_huge_pages_all()to use a folio....
mm/huge_memory.c +3
-1@@ -2932,6 +2932,7 @@ static void split_huge_pages_all(void) {struct zone *zone;struct page *page; +struct folio *folio;unsigned long pfn, max_zone_pfn;unsigned long total =0 , split =0 ;@@ -2944,24 +2945,32 @@ static void split_huge_pages_all(void)int nr_pages; page =pfn_to_online_page (pfn); -if (!page || !get_page_unless_zero (page)) +if (!page ||PageTail (page)) +continue ;mm/huge_memory.c static void split_huge_pages_all(void) · line 2958
Quoted 10 lines
mm/huge_memory.c +6
-1+ folio =page_folio (page); +if (!folio_try_get (folio))continue ; -if (zone !=page_zone (page)) +if (unlikely (page_folio (page) != folio)) + goto next; + +if (zone !=folio_zone (folio)) goto next;I'm still not understanding the above hunk. Why is the "
page_folio(page)!= folio" check added? Should it be commented?
Quoted 3 lines
Quoted 1 line
There is a comment in
try_get_folio(), is it enough?Nobody would think to look at a private function in
gup.c.
Sorry,I mean that comment is to explain why adding a new recheck.
Quoted 5 lines
I suggest this
folio_try_get()rule be documented at thefolio_try_get()implementation site.Most callers do perform this check, but not the ones in
vmscan.c?
Hope Matthew could give some advise, thanks