online_page_ext and page_ext_init allocate page_ext for each section, but
they do not allocate if the first PFN is !pfn_present(pfn) or
!pfn_valid(pfn).

Though the first page is not valid, page_ext could be useful for other
pages in the section. But checking all PFNs in a section may be time
consuming job. Let's check each (section count / 16) PFN, then prepare
page_ext if any PFN is present or valid.

Signed-off-by: Jaewon Kim <jaewon31....@samsung.com>
---
 mm/page_ext.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/mm/page_ext.c b/mm/page_ext.c
index 32f18911deda..634f9c5a8b9b 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c
@@ -312,7 +312,17 @@ static int __meminit online_page_ext(unsigned long 
start_pfn,
        }
 
        for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION) {
-               if (!pfn_present(pfn))
+               unsigned long t_pfn = pfn;
+               bool present = false;
+
+               while (t_pfn <  ALIGN(pfn + 1, PAGES_PER_SECTION)) {
+                       if (pfn_present(t_pfn)) {
+                               present = true;
+                               break;
+                       }
+                       t_pfn = ALIGN(pfn + 1, PAGES_PER_SECTION >> 4);
+               }
+               if (!present)
                        continue;
                fail = init_section_page_ext(pfn, nid);
        }
@@ -391,8 +401,17 @@ void __init page_ext_init(void)
                 */
                for (pfn = start_pfn; pfn < end_pfn;
                        pfn = ALIGN(pfn + 1, PAGES_PER_SECTION)) {
-
-                       if (!pfn_valid(pfn))
+                       unsigned long t_pfn = pfn;
+                       bool valid = false;
+
+                       while (t_pfn <  ALIGN(pfn + 1, PAGES_PER_SECTION)) {
+                               if (pfn_valid(t_pfn)) {
+                                       valid = true;
+                                       break;
+                               }
+                               t_pfn = ALIGN(pfn + 1, PAGES_PER_SECTION >> 4);
+                       }
+                       if (!valid)
                                continue;
                        /*
                         * Nodes's pfns can be overlapping.
-- 
2.13.0

Reply via email to