linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Joonsoo Kim <js1304@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>, Vlastimil Babka <vbabka@suse.cz>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH 2/2] mm/page_owner: set correct gfp_mask on page_owner
Date: Thu, 16 Jul 2015 09:06:13 +0900	[thread overview]
Message-ID: <20150716000613.GE988@bgram> (raw)
In-Reply-To: <1436942039-16897-2-git-send-email-iamjoonsoo.kim@lge.com>

On Wed, Jul 15, 2015 at 03:33:59PM +0900, Joonsoo Kim wrote:
> Currently, we set wrong gfp_mask to page_owner info in case of
> isolated freepage by compaction and split page. It causes incorrect
> mixed pageblock report that we can get from '/proc/pagetypeinfo'.
> This metric is really useful to measure fragmentation effect so
> should be accurate. This patch fixes it by setting correct
> information.
> 
> Without this patch, after kernel build workload is finished, number
> of mixed pageblock is 112 among roughly 210 movable pageblocks.
> 
> But, with this fix, output shows that mixed pageblock is just 57.
> 
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
>  include/linux/page_owner.h | 13 +++++++++++++
>  mm/page_alloc.c            |  8 +++++---
>  mm/page_owner.c            |  7 +++++++
>  3 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h
> index b48c347..cacaabe 100644
> --- a/include/linux/page_owner.h
> +++ b/include/linux/page_owner.h
> @@ -8,6 +8,7 @@ extern struct page_ext_operations page_owner_ops;
>  extern void __reset_page_owner(struct page *page, unsigned int order);
>  extern void __set_page_owner(struct page *page,
>  			unsigned int order, gfp_t gfp_mask);
> +extern gfp_t __get_page_owner_gfp(struct page *page);
>  
>  static inline void reset_page_owner(struct page *page, unsigned int order)
>  {
> @@ -25,6 +26,14 @@ static inline void set_page_owner(struct page *page,
>  
>  	__set_page_owner(page, order, gfp_mask);
>  }
> +
> +static inline gfp_t get_page_owner_gfp(struct page *page)
> +{
> +	if (likely(!page_owner_inited))
> +		return 0;
> +
> +	return __get_page_owner_gfp(page);
> +}
>  #else
>  static inline void reset_page_owner(struct page *page, unsigned int order)
>  {
> @@ -33,6 +42,10 @@ static inline void set_page_owner(struct page *page,
>  			unsigned int order, gfp_t gfp_mask)
>  {
>  }
> +static inline gfp_t get_page_owner_gfp(struct page *page)
> +{
> +	return 0;
> +}
>  
>  #endif /* CONFIG_PAGE_OWNER */
>  #endif /* __LINUX_PAGE_OWNER_H */
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 70d6a85..3ce3ec2 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1957,6 +1957,7 @@ void free_hot_cold_page_list(struct list_head *list, bool cold)
>  void split_page(struct page *page, unsigned int order)
>  {
>  	int i;
> +	gfp_t gfp_mask;
>  
>  	VM_BUG_ON_PAGE(PageCompound(page), page);
>  	VM_BUG_ON_PAGE(!page_count(page), page);
> @@ -1970,10 +1971,11 @@ void split_page(struct page *page, unsigned int order)
>  		split_page(virt_to_page(page[0].shadow), order);
>  #endif
>  
> -	set_page_owner(page, 0, 0);
> +	gfp_mask = get_page_owner_gfp(page);
> +	set_page_owner(page, 0, gfp_mask);
>  	for (i = 1; i < (1 << order); i++) {
>  		set_page_refcounted(page + i);
> -		set_page_owner(page + i, 0, 0);
> +		set_page_owner(page + i, 0, gfp_mask);
>  	}
>  }
>  EXPORT_SYMBOL_GPL(split_page);
> @@ -2003,7 +2005,7 @@ int __isolate_free_page(struct page *page, unsigned int order)
>  	zone->free_area[order].nr_free--;
>  	rmv_page_order(page);
>  
> -	set_page_owner(page, order, 0);
> +	set_page_owner(page, order, __GFP_MOVABLE);

It seems the reason why  __GFP_MOVABLE is okay is that __isolate_free_page
works on a free page on MIGRATE_MOVABLE|MIGRATE_CMA's pageblock. But if we
break the assumption in future, here is broken again?

Please put the comment here to cause it.

Otherwise, Good spot!

Reviewed-by: Minchan Kim <minchan@kernel.org>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-07-16  0:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15  6:33 [PATCH 1/2] mm/page_owner: fix possible access violation Joonsoo Kim
2015-07-15  6:33 ` [PATCH 2/2] mm/page_owner: set correct gfp_mask on page_owner Joonsoo Kim
2015-07-16  0:06   ` Minchan Kim [this message]
2015-07-20 11:27     ` Vlastimil Babka
2015-07-20 11:54       ` Minchan Kim
2015-07-23  5:21         ` Joonsoo Kim
2015-07-15 23:53 ` [PATCH 1/2] mm/page_owner: fix possible access violation Minchan Kim
2015-07-23  5:11   ` Joonsoo Kim

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=20150716000613.GE988@bgram \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=js1304@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=vbabka@suse.cz \
    /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;
as well as URLs for NNTP newsgroup(s).