linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Rafael Aquini <aquini@redhat.com>
To: Mel Gorman <mgorman@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Minchan Kim <minchan@kernel.org>, Xishi Qiu <qiuxishi@huawei.com>,
	riel@redhat.com, linux-mm@kvack.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: Improve documentation of page_order
Date: Fri, 17 Jan 2014 16:40:42 -0200	[thread overview]
Message-ID: <20140117184041.GA7449@localhost.localdomain> (raw)
In-Reply-To: <20140117143221.GA24851@suse.de>

On Fri, Jan 17, 2014 at 02:32:21PM +0000, Mel Gorman wrote:
> Developers occasionally try and optimise PFN scanners by using page_order
> but miss that in general it requires zone->lock. This has happened twice for
> compaction.c and rejected both times.  This patch clarifies the documentation
> of page_order and adds a note to compaction.c why page_order is not used.
> 
> Signed-off-by: Mel Gorman <mgorman@suse.de>
> ---
>  mm/compaction.c | 5 ++++-
>  mm/internal.h   | 8 +++++---
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index f58bcd0..f91d26b 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -522,7 +522,10 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
>  		if (!isolation_suitable(cc, page))
>  			goto next_pageblock;
>  
> -		/* Skip if free */
> +		/*
> +		 * Skip if free. page_order cannot be used without zone->lock
> +		 * as nothing prevents parallel allocations or buddy merging.
> +		 */
>  		if (PageBuddy(page))
>  			continue;
>  
> diff --git a/mm/internal.h b/mm/internal.h
> index 684f7aa..09cd8be 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -144,9 +144,11 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
>  #endif
>  
>  /*
> - * function for dealing with page's order in buddy system.
> - * zone->lock is already acquired when we use these.
> - * So, we don't need atomic page->flags operations here.
> + * This functions returns the order of a free page in the buddy system.
> + * In general, page_zone(page)->lock must be held by the caller to prevent
> + * the page being allocated in parallel and returning garbage as the order.
> + * If the caller does not hold page_zone(page), they must guarantee that
> + * the page cannot be allocated or merged in parallel.
>   */
>  static inline unsigned long page_order(struct page *page)
>  {

Acked-by: Rafael Aquini <aquini@redhat.com>


--
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:[~2014-01-17 18:40 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14  4:45 [PATCH] mm: skip the page buddy block instead of one page Xishi Qiu
2013-08-14  7:07 ` Minchan Kim
2013-08-14  8:57 ` Mel Gorman
2013-08-14  9:14   ` Xishi Qiu
2013-08-14 15:52   ` Minchan Kim
2013-08-14 16:16     ` Mel Gorman
2013-08-14 16:39       ` Minchan Kim
2013-08-14 18:00         ` Mel Gorman
2013-08-14 19:11           ` Minchan Kim
2013-08-15  2:32           ` Xishi Qiu
2013-08-15  2:44             ` Minchan Kim
2013-08-15  3:46               ` Xishi Qiu
2013-08-15  3:59                 ` Wanpeng Li
2013-08-15  3:59                 ` Wanpeng Li
2013-08-15  4:17                 ` Minchan Kim
2013-08-15  4:24                   ` Minchan Kim
2013-08-15  7:45                     ` Xishi Qiu
2013-08-15  9:51                       ` Wanpeng Li
2013-08-15  9:51                       ` Wanpeng Li
2013-08-15 11:15                         ` Xishi Qiu
2013-08-15 11:23                           ` Wanpeng Li
2013-08-15 11:23                           ` Wanpeng Li
2013-08-15 11:17                         ` Xishi Qiu
2013-08-15  6:38                   ` Xishi Qiu
2013-08-15 11:30                   ` Mel Gorman
2013-08-15 13:19                     ` Minchan Kim
2013-08-15 13:42                       ` Mel Gorman
2013-08-15 14:16                         ` Minchan Kim
2013-08-14 20:26     ` Andrew Morton
2013-08-14 22:22       ` Mel Gorman
2014-01-17 14:32         ` [PATCH] mm: Improve documentation of page_order Mel Gorman
2014-01-17 18:40           ` Rafael Aquini [this message]
2014-01-17 18:53           ` Laura Abbott
2014-01-17 19:59             ` Mel Gorman
2014-01-21 11:05               ` [PATCH] mm: Improve documentation of page_order v2 Mel Gorman
2014-01-20  6:12           ` [PATCH] mm: Improve documentation of page_order Minchan 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=20140117184041.GA7449@localhost.localdomain \
    --to=aquini@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=minchan@kernel.org \
    --cc=qiuxishi@huawei.com \
    --cc=riel@redhat.com \
    /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).