From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mel Gorman <mgorman@suse.de>,
David Rientjes <rientjes@google.com>,
Rik van Riel <riel@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] mm/page_alloc: separate steal decision from steal behaviour part
Date: Mon, 2 Feb 2015 16:02:49 +0900 [thread overview]
Message-ID: <20150202070248.GA6488@js1304-P5Q-DELUXE> (raw)
In-Reply-To: <54CB94E6.7010805@suse.cz>
On Fri, Jan 30, 2015 at 03:27:50PM +0100, Vlastimil Babka wrote:
> On 01/30/2015 01:34 PM, Joonsoo Kim wrote:
> > From: Joonsoo <iamjoonsoo.kim@lge.com>
> >
> > This is preparation step to use page allocator's anti fragmentation logic
> > in compaction. This patch just separates steal decision part from actual
> > steal behaviour part so there is no functional change.
> >
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> > ---
> > mm/page_alloc.c | 49 ++++++++++++++++++++++++++++++++-----------------
> > 1 file changed, 32 insertions(+), 17 deletions(-)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 8d52ab1..ef74750 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -1122,6 +1122,24 @@ static void change_pageblock_range(struct page *pageblock_page,
> > }
> > }
> >
> > +static bool can_steal_freepages(unsigned int order,
> > + int start_mt, int fallback_mt)
> > +{
> > + if (is_migrate_cma(fallback_mt))
> > + return false;
> > +
> > + if (order >= pageblock_order)
> > + return true;
> > +
> > + if (order >= pageblock_order / 2 ||
> > + start_mt == MIGRATE_RECLAIMABLE ||
> > + start_mt == MIGRATE_UNMOVABLE ||
> > + page_group_by_mobility_disabled)
> > + return true;
> > +
> > + return false;
> > +}
> > +
> > /*
> > * When we are falling back to another migratetype during allocation, try to
> > * steal extra free pages from the same pageblocks to satisfy further
> > @@ -1138,9 +1156,10 @@ static void change_pageblock_range(struct page *pageblock_page,
> > * as well.
> > */
> > static void try_to_steal_freepages(struct zone *zone, struct page *page,
> > - int start_type, int fallback_type)
> > + int start_type)
>
> It's actually not 'try_to_' anymore, is it? But could be, see below.
>
> > {
> > int current_order = page_order(page);
> > + int pages;
> >
> > /* Take ownership for orders >= pageblock_order */
> > if (current_order >= pageblock_order) {
> > @@ -1148,19 +1167,12 @@ static void try_to_steal_freepages(struct zone *zone, struct page *page,
> > return;
> > }
> >
> > - if (current_order >= pageblock_order / 2 ||
> > - start_type == MIGRATE_RECLAIMABLE ||
> > - start_type == MIGRATE_UNMOVABLE ||
> > - page_group_by_mobility_disabled) {
> > - int pages;
> > + pages = move_freepages_block(zone, page, start_type);
> >
> > - pages = move_freepages_block(zone, page, start_type);
> > -
> > - /* Claim the whole block if over half of it is free */
> > - if (pages >= (1 << (pageblock_order-1)) ||
> > - page_group_by_mobility_disabled)
> > - set_pageblock_migratetype(page, start_type);
> > - }
> > + /* Claim the whole block if over half of it is free */
> > + if (pages >= (1 << (pageblock_order-1)) ||
> > + page_group_by_mobility_disabled)
> > + set_pageblock_migratetype(page, start_type);
> > }
> >
> > /* Remove an element from the buddy allocator from the fallback list */
> > @@ -1170,6 +1182,7 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype)
> > struct free_area *area;
> > unsigned int current_order;
> > struct page *page;
> > + bool can_steal;
> >
> > /* Find the largest possible block of pages in the other list */
> > for (current_order = MAX_ORDER-1;
> > @@ -1192,10 +1205,11 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype)
> > struct page, lru);
> > area->nr_free--;
> >
> > - if (!is_migrate_cma(migratetype)) {
> > + can_steal = can_steal_freepages(current_order,
> > + start_migratetype, migratetype);
> > + if (can_steal) {
>
> can_steal is only used once, why not do if (can_steal_freepages()) directly?
>
> Or, call can_steal_freepages() from try_to_steal_freepages() and make
> try_to_steal_freepages() return its result. Then here it simplifies to:
>
> if (!try_to_steal_freepages(...) && is_migrate_cma(...))
> buddy_type = migratetype;
You're right. Your commented code loosk better.
Your comment on 3/4 and 4/4 makes me reconsider this code factorization
and I found better solution.
I will send it soon.
Thanks.
--
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>
next prev parent reply other threads:[~2015-02-02 7:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 12:34 [PATCH v2 0/4] enhance compaction success rate Joonsoo Kim
2015-01-30 12:34 ` [PATCH v2 1/4] mm/compaction: fix wrong order check in compact_finished() Joonsoo Kim
2015-01-30 13:27 ` Vlastimil Babka
2015-01-31 7:38 ` Zhang Yanfei
2015-01-30 12:34 ` [PATCH v2 2/4] mm/compaction: stop the isolation when we isolate enough freepage Joonsoo Kim
2015-01-30 13:47 ` Vlastimil Babka
2015-01-31 7:49 ` Zhang Yanfei
2015-01-31 8:31 ` Vlastimil Babka
2015-01-31 10:17 ` Zhang Yanfei
2015-01-30 12:34 ` [PATCH v2 3/4] mm/page_alloc: separate steal decision from steal behaviour part Joonsoo Kim
2015-01-30 14:27 ` Vlastimil Babka
2015-02-02 7:02 ` Joonsoo Kim [this message]
2015-01-31 12:38 ` Zhang Yanfei
2015-02-02 7:03 ` Joonsoo Kim
2015-01-30 12:34 ` [PATCH v2 4/4] mm/compaction: enhance compaction finish condition Joonsoo Kim
2015-01-30 14:43 ` Vlastimil Babka
2015-02-02 7:11 ` Joonsoo Kim
2015-01-31 15:58 ` Zhang Yanfei
2015-02-02 7:12 ` 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=20150202070248.GA6488@js1304-P5Q-DELUXE \
--to=iamjoonsoo.kim@lge.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=riel@redhat.com \
--cc=rientjes@google.com \
--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