Skip to content

Commit

Permalink
mm: fix page_owner initializing issue for arm32
Browse files Browse the repository at this point in the history
Page owner of pages used by page owner itself used is missing on arm32
targets.  The reason is dummy_handle and failure_handle is not initialized
correctly.  Buddy allocator is used to initialize these two handles.
However, buddy allocator is not ready when page owner calls it.  This
change fixed that by initializing page owner after buddy initialization.

The working flow before and after this change are:
original logic:
 1. allocated memory for page_ext(using memblock).
 2. invoke the init callback of page_ext_ops like page_owner(using buddy
    allocator).
 3. initialize buddy.

after this change:
 1. allocated memory for page_ext(using memblock).
 2. initialize buddy.
 3. invoke the init callback of page_ext_ops like page_owner(using buddy
    allocator).

with the change, failure/dummy_handle can get its correct value and page
owner output for example has the one for page owner itself:

  Page allocated via order 2, mask 0x6202c0(GFP_USER|__GFP_NOWARN), pid 1006, ts 67278156558 ns
  PFN 543776 type Unmovable Block 531 type Unmovable Flags 0x0()
    init_page_owner+0x28/0x2f8
    invoke_init_callbacks_flatmem+0x24/0x34
    start_kernel+0x33c/0x5d8

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Zhenhua Huang <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Zhenhua Huang authored and torvalds committed Dec 15, 2020
1 parent 7d18dd7 commit 7fb7ab6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions include/linux/page_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ static inline void page_ext_init_flatmem(void)
{
}
extern void page_ext_init(void);
static inline void page_ext_init_flatmem_late(void)
{
}
#else
extern void page_ext_init_flatmem(void);
extern void page_ext_init_flatmem_late(void);
static inline void page_ext_init(void)
{
}
Expand Down Expand Up @@ -76,6 +80,10 @@ static inline void page_ext_init(void)
{
}

static inline void page_ext_init_flatmem_late(void)
{
}

static inline void page_ext_init_flatmem(void)
{
}
Expand Down
2 changes: 2 additions & 0 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ static void __init mm_init(void)
init_debug_pagealloc();
report_meminit();
mem_init();
/* page_owner must be initialized after buddy is ready */
page_ext_init_flatmem_late();
kmem_cache_init();
kmemleak_init();
pgtable_init();
Expand Down
10 changes: 8 additions & 2 deletions mm/page_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,19 @@ static void __init invoke_init_callbacks(void)
}
}

#ifndef CONFIG_SPARSEMEM
void __init page_ext_init_flatmem_late(void)
{
invoke_init_callbacks();
}
#endif

static inline struct page_ext *get_entry(void *base, unsigned long index)
{
return base + page_ext_size * index;
}

#if !defined(CONFIG_SPARSEMEM)
#ifndef CONFIG_SPARSEMEM


void __meminit pgdat_page_ext_init(struct pglist_data *pgdat)
Expand Down Expand Up @@ -177,7 +184,6 @@ void __init page_ext_init_flatmem(void)
goto fail;
}
pr_info("allocated %ld bytes of page_ext\n", total_usage);
invoke_init_callbacks();
return;

fail:
Expand Down

0 comments on commit 7fb7ab6

Please sign in to comment.