linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Zhenhua Huang <zhenhuah@codeaurora.org>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm: fix page_owner initializing issue for arm32
Date: Sun, 25 Oct 2020 17:42:53 +0200	[thread overview]
Message-ID: <20201025154253.GH392079@kernel.org> (raw)
In-Reply-To: <1602839640-13125-1-git-send-email-zhenhuah@codeaurora.org>

On Fri, Oct 16, 2020 at 05:14:00PM +0800, Zhenhua Huang wrote:
> 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).

Is anything that requires a memblock allocation FLATMEM?
Any fundamental reason why wouldn't alloc_pages_exact_nid/vzalloc_node()
work in this case?

It seems to me that for FLATMEM configuration we can allocate the
page_ext using alloc_pages() with a fallback to vzalloc_node() and then
we can unify lot's of page_ext code and entirely drop
page_ext_init_flatmem().

> 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
>    (null)
> 
> Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
> ---
>  include/linux/page_ext.h | 8 ++++++++
>  init/main.c              | 2 ++
>  mm/page_ext.c            | 8 +++++++-
>  3 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
> index cfce186..aff81ba 100644
> --- a/include/linux/page_ext.h
> +++ b/include/linux/page_ext.h
> @@ -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)
>  {
>  }
> @@ -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)
>  {
>  }
> diff --git a/init/main.c b/init/main.c
> index 130376e..b34c475 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -818,6 +818,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();
> diff --git a/mm/page_ext.c b/mm/page_ext.c
> index a3616f7..373f7a1 100644
> --- a/mm/page_ext.c
> +++ b/mm/page_ext.c
> @@ -99,6 +99,13 @@ static void __init invoke_init_callbacks(void)
>  	}
>  }
>  
> +#if !defined(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;
> @@ -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:
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
> 

-- 
Sincerely yours,
Mike.


  parent reply	other threads:[~2020-10-25 15:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  9:14 Zhenhua Huang
2020-10-16 10:41 ` Vlastimil Babka
2020-10-19 10:39   ` Zhenhua Huang
2020-10-25 15:42 ` Mike Rapoport [this message]
     [not found]   ` <20201026071255.GA31027@codeaurora.org>
2020-10-26  9:39     ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201025154253.GH392079@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=zhenhuah@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox