Skip to contentSkip to conversation

mm: fix regression with deferred struct page init

RFC PATCH In review Juergen Gross 2 participants 3 messages Jun 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 mm: fix regression with deferred struct page init

Commit 0e56acae4b4dd4a9 ("mm: initialize MAX_ORDER_NR_PAGES at a time instead of doing larger sections") is causing a regression on some systems when the kernel is booted as Xen dom0.

The system will just hang in early boot.

Reason is an endless loop in get_page_from_freelist() in case the first zone looked at has no free memory. deferred_grow_zone() is always returning true due to the following code snipplet:

  /* If the zone is empty somebody else may have cleared out the zone */
  if (!deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn,
                                           first_deferred_pfn)) {
          pgdat->first_deferred_pfn = ULONG_MAX;
          pgdat_resize_unlock(pgdat, &flags);
          return true;
  }

This in turn results in the loop as get_page_from_freelist() is assuming forward progress can be made by doing some more struct page initialization.

Fixes 0e56acae4b4dd4a9 ("mm: initialize MAX_ORDER_NR_PAGES at a time instead of doing larger sections")

---
This patch makes my system boot again as Xen dom0, but I'm not really sure it is the correct way to do it, hence the RFC.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index d66bc8abe0af..6ee754b5cd92 100644
@@ -1826,7 +1826,7 @@ deferred_grow_zone(struct zone *zone, unsigned int order)
 						 first_deferred_pfn)) {
 		pgdat->first_deferred_pfn = ULONG_MAX;
 		pgdat_resize_unlock(pgdat, &flags);
-		return true;
+		return false;
 	}
 
 	/*
Signature · 1 line
2.16.4
#1 lore raw
Quoted 36 lines · Juergen Gross

Commit 0e56acae4b4dd4a9 ("mm: initialize MAX_ORDER_NR_PAGES at a time instead of doing larger sections") is causing a regression on some systems when the kernel is booted as Xen dom0.

The system will just hang in early boot.

Reason is an endless loop in get_page_from_freelist() in case the first zone looked at has no free memory. deferred_grow_zone() is always returning true due to the following code snipplet:

  /* If the zone is empty somebody else may have cleared out the zone */
  if (!deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn,
                                           first_deferred_pfn)) {
          pgdat->first_deferred_pfn = ULONG_MAX;
          pgdat_resize_unlock(pgdat, &flags);
          return true;
  }

This in turn results in the loop as get_page_from_freelist() is assuming forward progress can be made by doing some more struct page initialization.

Fixes 0e56acae4b4dd4a9 ("mm: initialize MAX_ORDER_NR_PAGES at a time instead of doing larger sections")

---
This patch makes my system boot again as Xen dom0, but I'm not really sure it is the correct way to do it, hence the RFC.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +0 -0
index d66bc8abe0af..6ee754b5cd92 100644

mm/page_alloc.c deferred_grow_zone(struct zone *zone, unsigned int order) · line 1832

Quoted 8 lines
mm/page_alloc.c +1 -1
@@ -1826,7 +1826,7 @@ deferred_grow_zone(struct zone *zone, unsigned int order)
 						 first_deferred_pfn)) {
 		pgdat->first_deferred_pfn = ULONG_MAX;
 		pgdat_resize_unlock(pgdat, &flags);
-		return true;
+		return false;
 	}
 
 	/*

The one change I might make to this would be to do:

	return first_deferred_pfn != ULONG_MAX;

That way in the event the previous caller did free up the last of the pages and empty the zone just before we got here then we will try one more time. Otherwise if it was already done before we got here we exit.

#2 lore raw
Quoted 44 lines · Alexander Duyck
Quoted 43 lines · Juergen Gross

Commit 0e56acae4b4dd4a9 ("mm: initialize MAX_ORDER_NR_PAGES at a time instead of doing larger sections") is causing a regression on some systems when the kernel is booted as Xen dom0.

The system will just hang in early boot.

Reason is an endless loop in get_page_from_freelist() in case the first zone looked at has no free memory. deferred_grow_zone() is always returning true due to the following code snipplet:

   /* If the zone is empty somebody else may have cleared out the zone */
   if (!deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn,
                                            first_deferred_pfn)) {
           pgdat->first_deferred_pfn = ULONG_MAX;
           pgdat_resize_unlock(pgdat, &flags);
           return true;
   }

This in turn results in the loop as get_page_from_freelist() is assuming forward progress can be made by doing some more struct page initialization.

Fixes 0e56acae4b4dd4a9 ("mm: initialize MAX_ORDER_NR_PAGES at a time instead of doing larger sections")

---
This patch makes my system boot again as Xen dom0, but I'm not really sure it is the correct way to do it, hence the RFC.

---
  mm/page_alloc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index d66bc8abe0af..6ee754b5cd92 100644
@@ -1826,7 +1826,7 @@ deferred_grow_zone(struct zone *zone, unsigned int order)
  						 first_deferred_pfn)) {
  		pgdat->first_deferred_pfn = ULONG_MAX;
  		pgdat_resize_unlock(pgdat, &flags);
-		return true;
+		return false;
  	}
 
Quoted 8 lines

mm/page_alloc.c deferred_grow_zone(struct zone *zone, unsigned int order) · line 1832

Quoted 1 line
mm/page_alloc.c +0 -0
  	/*

The one change I might make to this would be to do:

	return first_deferred_pfn != ULONG_MAX;

That way in the event the previous caller did free up the last of the pages and empty the zone just before we got here then we will try one more time. Otherwise if it was already done before we got here we exit.

Thanks for the constructive feedback!

Will send a non-RFC variant soon.

Juergen