Skip to contentSkip to conversation

mm: page_isolation: use compound_nr() correctly in isolate_single_pageblock()

PATCH Applied Zi Yan 5 participants 5 messages May 31, 2022

Subsystems (2)
lore
Share & tools
lore

Zi Yan

author
#0 lore raw

PATCH 1/1 mm: page_isolation: use compound_nr() correctly in isolate_single_pageblock()

From: Zi Yan <[email protected]>

When compound_nr(page) was used, page was not guaranteed to be the head of the compound page and it could cause an infinite loop. Fix it by calling it on the head page.

Fixes b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")
---
 mm/page_isolation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_isolation.c +1 -1
index 6021f8444b5a..d200d41ad0d3 100644
@@ -385,9 +385,9 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags,
 		 * above do the rest. If migration is not possible, just fail.
 		 */
 		if (PageCompound(page)) {
-			unsigned long nr_pages = compound_nr(page);
 			struct page *head = compound_head(page);
 			unsigned long head_pfn = page_to_pfn(head);
+			unsigned long nr_pages = compound_nr(head);
 
 			if (head_pfn + nr_pages <= boundary_pfn) {
 				pfn = head_pfn + nr_pages;
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Zi Yan

From: Zi Yan <[email protected]>

When compound_nr(page) was used, page was not guaranteed to be the head of the compound page and it could cause an infinite loop. Fix it by calling it on the head page.

Fixes b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")
Quoted 19 lines
---
 mm/page_isolation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_isolation.c +1 -1
index 6021f8444b5a..d200d41ad0d3 100644
@@ -385,9 +385,9 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags,
 		 * above do the rest. If migration is not possible, just fail.
 		 */
 		if (PageCompound(page)) {
-			unsigned long nr_pages = compound_nr(page);
 			struct page *head = compound_head(page);
 			unsigned long head_pfn = page_to_pfn(head);
+			unsigned long nr_pages = compound_nr(head);
 
 			if (head_pfn + nr_pages <= boundary_pfn) {
 				pfn = head_pfn + nr_pages;
Acked-by on v1 1/1
#2 lore raw
In reply to Zi Yan
Quoted 10 lines · Zi Yan

From: Zi Yan <[email protected]>

When compound_nr(page) was used, page was not guaranteed to be the head of the compound page and it could cause an infinite loop. Fix it by calling it on the head page.

Fixes b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")

Thanks.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Zi Yan
Quoted 10 lines · Zi Yan

From: Zi Yan <[email protected]>

When compound_nr(page) was used, page was not guaranteed to be the head of the compound page and it could cause an infinite loop. Fix it by calling it on the head page.

Fixes b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")
Quoted 22 lines
---
 mm/page_isolation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_isolation.c +1 -1
index 6021f8444b5a..d200d41ad0d3 100644
@@ -385,9 +385,9 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags,
 		 * above do the rest. If migration is not possible, just fail.
 		 */
 		if (PageCompound(page)) {
-			unsigned long nr_pages = compound_nr(page);
 			struct page *head = compound_head(page);
 			unsigned long head_pfn = page_to_pfn(head);
+			unsigned long nr_pages = compound_nr(head);
 
 			if (head_pfn + nr_pages <= boundary_pfn) {
 				pfn = head_pfn + nr_pages;
Signature · 1 line
2.35.1
Signature · 2 lines
Oscar Salvador
SUSE Labs
Reviewed-by on v1 1/1
#4 lore raw
In reply to Zi Yan
Quoted 10 lines · Zi Yan

From: Zi Yan <[email protected]>

When compound_nr(page) was used, page was not guaranteed to be the head of the compound page and it could cause an infinite loop. Fix it by calling it on the head page.

Fixes b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")

LGTM. Thanks!

Quoted 20 lines
---
 mm/page_isolation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_isolation.c +1 -1
index 6021f8444b5a..d200d41ad0d3 100644
@@ -385,9 +385,9 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags,
 		 * above do the rest. If migration is not possible, just fail.
 		 */
 		if (PageCompound(page)) {
-			unsigned long nr_pages = compound_nr(page);
 			struct page *head = compound_head(page);
 			unsigned long head_pfn = page_to_pfn(head);
+			unsigned long nr_pages = compound_nr(head);
 
 			if (head_pfn + nr_pages <= boundary_pfn) {
 				pfn = head_pfn + nr_pages;