]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/mm_init.c: print mem_init info after defer_init is done
authorWei Yang <richard.weiyang@gmail.com>
Tue, 11 Jun 2024 14:52:23 +0000 (14:52 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 4 Jul 2024 02:30:08 +0000 (19:30 -0700)
Current call flow looks like this:

start_kernel
  mm_core_init
    mem_init
    mem_init_print_info
  rest_init
    kernel_init
      kernel_init_freeable
        page_alloc_init_late
          deferred_init_memmap

If CONFIG_DEFERRED_STRUCT_PAGE_INIT, the time mem_init_print_info()
calls, pages are not totally initialized and freed to buddy.

This has one issue

  * nr_free_pages() just contains partial free pages in the system,
    which is not we expect.

Let's print the mem info after defer_init is done.

Also this would help changing totalram_pages accounting, since we plan
to move the accounting into __free_pages_core().

Link: https://lkml.kernel.org/r/20240611145223.16872-1-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mm_init.c

index 779b4e3d63391a63a27dc174d43d7da2ebda3ad0..1bab27398302c9fe75af8b45f5e6a5c226438161 100644 (file)
@@ -2321,6 +2321,7 @@ void set_zone_contiguous(struct zone *zone)
        zone->contiguous = true;
 }
 
+static void __init mem_init_print_info(void);
 void __init page_alloc_init_late(void)
 {
        struct zone *zone;
@@ -2347,6 +2348,8 @@ void __init page_alloc_init_late(void)
        files_maxfiles_init();
 #endif
 
+       /* Accounting of total+free memory is stable at this point. */
+       mem_init_print_info();
        buffer_init();
 
        /* Discard memblock private memory */
@@ -2707,7 +2710,6 @@ void __init mm_core_init(void)
        kmsan_init_shadow();
        stack_depot_early_init();
        mem_init();
-       mem_init_print_info();
        kmem_cache_init();
        /*
         * page_owner must be initialized after buddy is ready, and also after