linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
	Christoph Lameter <cl@linux-foundation.org>,
	Adam Litke <agl@us.ibm.com>, Avi Kivity <avi@redhat.com>,
	David Rientjes <rientjes@google.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 05/12] Memory compaction core
Date: Fri, 19 Feb 2010 14:33:10 +0000	[thread overview]
Message-ID: <20100219143310.GM30258@csn.ul.ie> (raw)
In-Reply-To: <28c262361002181721k2c40854ah638eaaf2254e92a@mail.gmail.com>

On Fri, Feb 19, 2010 at 10:21:10AM +0900, Minchan Kim wrote:
> On Fri, Feb 19, 2010 at 2:34 AM, Mel Gorman <mel@csn.ul.ie> wrote:
> > On Fri, Feb 19, 2010 at 01:58:44AM +0900, Minchan Kim wrote:
> >> On Fri, 2010-02-12 at 12:00 +0000, Mel Gorman wrote:
> >> > +/* Isolate free pages onto a private freelist. Must hold zone->lock */
> >> > +static int isolate_freepages_block(struct zone *zone,
> >>
> >> return type 'int'?
> >> I think we can't return signed value.
> >>
> >
> > I don't understand your query. What's wrong with returning int?
> 
> It's just nitpick. I mean this functions doesn't return minus value.
> Never mind.
> 
> >
> >> > +                           unsigned long blockpfn,
> >> > +                           struct list_head *freelist)
> >> > +{
> >> > +   unsigned long zone_end_pfn, end_pfn;
> >> > +   int total_isolated = 0;
> >> > +
> >> > +   /* Get the last PFN we should scan for free pages at */
> >> > +   zone_end_pfn = zone->zone_start_pfn + zone->spanned_pages;
> >> > +   end_pfn = blockpfn + pageblock_nr_pages;
> >> > +   if (end_pfn > zone_end_pfn)
> >> > +           end_pfn = zone_end_pfn;
> >> > +
> >> > +   /* Isolate free pages. This assumes the block is valid */
> >> > +   for (; blockpfn < end_pfn; blockpfn++) {
> >> > +           struct page *page;
> >> > +           int isolated, i;
> >> > +
> >> > +           if (!pfn_valid_within(blockpfn))
> >> > +                   continue;
> >> > +
> >> > +           page = pfn_to_page(blockpfn);
> >> > +           if (!PageBuddy(page))
> >> > +                   continue;
> >> > +
> >> > +           /* Found a free page, break it into order-0 pages */
> >> > +           isolated = split_free_page(page);
> >> > +           total_isolated += isolated;
> >> > +           for (i = 0; i < isolated; i++) {
> >> > +                   list_add(&page->lru, freelist);
> >> > +                   page++;
> >> > +           }
> >> > +           blockpfn += isolated - 1;
> >
> > Incidentally, this line is wrong but will be fixed in line 3. If
> > split_free_page() fails, it causes an infinite loop.
> >
> >> > +   }
> >> > +
> >> > +   return total_isolated;
> >> > +}
> >> > +
> >> > +/* Returns 1 if the page is within a block suitable for migration to */
> >> > +static int suitable_migration_target(struct page *page)
> >> > +{
> >> > +   /* If the page is a large free page, then allow migration */
> >> > +   if (PageBuddy(page) && page_order(page) >= pageblock_order)
> >> > +           return 1;
> >> > +
> >> > +   /* If the block is MIGRATE_MOVABLE, allow migration */
> >> > +   if (get_pageblock_migratetype(page) == MIGRATE_MOVABLE)
> >> > +           return 1;
> >> > +
> >> > +   /* Otherwise skip the block */
> >> > +   return 0;
> >> > +}
> >> > +
> >> > +/*
> >> > + * Based on information in the current compact_control, find blocks
> >> > + * suitable for isolating free pages from
> >> > + */
> >> > +static void isolate_freepages(struct zone *zone,
> >> > +                           struct compact_control *cc)
> >> > +{
> >> > +   struct page *page;
> >> > +   unsigned long high_pfn, low_pfn, pfn;
> >> > +   unsigned long flags;
> >> > +   int nr_freepages = cc->nr_freepages;
> >> > +   struct list_head *freelist = &cc->freepages;
> >> > +
> >> > +   pfn = cc->free_pfn;
> >> > +   low_pfn = cc->migrate_pfn + pageblock_nr_pages;
> >> > +   high_pfn = low_pfn;
> >> > +
> >> > +   /*
> >> > +    * Isolate free pages until enough are available to migrate the
> >> > +    * pages on cc->migratepages. We stop searching if the migrate
> >> > +    * and free page scanners meet or enough free pages are isolated.
> >> > +    */
> >> > +   spin_lock_irqsave(&zone->lock, flags);
> >> > +   for (; pfn > low_pfn && cc->nr_migratepages > nr_freepages;
> >> > +                                   pfn -= pageblock_nr_pages) {
> >> > +           int isolated;
> >> > +
> >> > +           if (!pfn_valid(pfn))
> >> > +                   continue;
> >> > +
> >> > +           /* Check for overlapping nodes/zones */
> >> > +           page = pfn_to_page(pfn);
> >> > +           if (page_zone(page) != zone)
> >> > +                   continue;
> >>
> >> We are progressing backward by physical page order in a zone.
> >> If we meet crossover between zone, Why are we going backward
> >> continuously? Before it happens, migration and free scanner would meet.
> >> Am I miss something?
> >>
> >
> > I was considering a situation like the following
> >
> >
> > Node-0     Node-1       Node-0
> > DMA        DMA          DMA
> > 0-1023     1024-2047    2048-4096
> >
> > In that case, a PFN scanner can enter a new node and zone but the migrate
> > and free scanners have not necessarily met. This configuration is *extremely*
> > rare but it happens on messed-up LPAR configurations on POWER.
> 
> I don't know such architecture until now.
> Thanks for telling me.
> How about adding the comment about that?
> 

Sure

> >
> >> > +
> >> > +           /* Check the block is suitable for migration */
> >> > +           if (!suitable_migration_target(page))
> >> > +                   continue;
> >>
> >> Dumb question.
> >> suitable_migration_target considers three type's pages
> >>
> >> 1. free page and page's order >= pageblock_order
> >> 2. free pages and pages's order < pageblock_order with movable page
> >> 3. used page with movable
> >>
> >> I can understand 1 and 2 but can't 3. This function is for gathering
> >> free page. How do you handle used page as free one?
> >>
> >> In addition, as I looked into isolate_freepages_block, it doesn't
> >> consider 3 by PageBuddy check.
> >>
> >> I am confusing. Pz, correct me.
> >>
> >
> > I'm afraid I don't understand your question. At the point
> > suitable_migration_target() is called, the only concern is finding a pageblock
> > of pages that should be scanned for free pages by isolate_freepages_block().
> > What do you mean by "used page with movable" ?
> 
> After I looked into code, I understand it.
> Thanks.
> 
> <snip>
> >>> +/* Similar to split_page except the page is already free */
> >> Sometime, this function changes pages's type to MIGRATE_MOVABLE.
> >> I hope adding comment about that.
> >>
> >
> > There is a comment within the function about it. Do you want it moved to
> > here?
> 
> If you don't mind, I hope so. :)
> 

Done.

> That's because you wrote down only "except the page is already free" in
> function description. So I thought it's only difference with split_page at first
> glance. I think information that setting MIGRATE_MOVABLE is important.
> 
> Pz, thinks it as just nitpick.

No, it's a fair point. I can see how it could trip someone up.

Thanks

-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
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:[~2010-02-19 14:33 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-12 12:00 [PATCH 0/12] Memory Compaction v2r12 Mel Gorman
2010-02-12 12:00 ` [PATCH 01/12] mm: Document /proc/pagetypeinfo Mel Gorman
2010-02-12 15:54   ` Christoph Lameter
2010-02-16  7:05   ` KOSAKI Motohiro
2010-02-12 12:00 ` [PATCH 02/12] Allow CONFIG_MIGRATION to be set without CONFIG_NUMA or memory hot-remove Mel Gorman
2010-02-16 17:43   ` Rik van Riel
2010-02-12 12:00 ` [PATCH 03/12] Export unusable free space index via /proc/pagetypeinfo Mel Gorman
2010-02-16  7:03   ` KOSAKI Motohiro
2010-02-16  8:36     ` Mel Gorman
2010-02-16  8:41       ` KOSAKI Motohiro
2010-02-16  8:50         ` Mel Gorman
2010-02-16 18:28   ` Rik van Riel
2010-02-18 15:23   ` Minchan Kim
2010-02-18 15:32     ` Mel Gorman
2010-02-12 12:00 ` [PATCH 04/12] Export fragmentation " Mel Gorman
2010-02-16  7:59   ` KOSAKI Motohiro
2010-02-16  8:41     ` Mel Gorman
2010-02-16  8:49       ` KOSAKI Motohiro
2010-02-17  1:44   ` Rik van Riel
2010-02-18 15:37   ` Minchan Kim
2010-02-12 12:00 ` [PATCH 05/12] Memory compaction core Mel Gorman
2010-02-16  8:31   ` KOSAKI Motohiro
2010-02-16  8:48     ` Mel Gorman
2010-02-16 14:55       ` Christoph Lameter
2010-02-16 14:59         ` Mel Gorman
2010-02-18 19:37           ` Christoph Lameter
2010-02-18 21:35             ` Mel Gorman
2010-02-19  0:04             ` KAMEZAWA Hiroyuki
2010-02-17 13:29     ` Mel Gorman
2010-02-17 15:45       ` Rik van Riel
2010-02-18 16:58   ` Minchan Kim
2010-02-18 17:34     ` Mel Gorman
2010-02-19  1:21       ` Minchan Kim
2010-02-19 14:33         ` Mel Gorman [this message]
2010-02-12 12:00 ` [PATCH 06/12] Add /proc trigger for memory compaction Mel Gorman
2010-02-12 18:34   ` Valdis.Kletnieks
2010-02-12 18:38     ` Mel Gorman
2010-02-17 16:30   ` Rik van Riel
2010-02-18 19:51   ` Christoph Lameter
2010-02-19  1:56   ` Minchan Kim
2010-02-12 12:00 ` [PATCH 07/12] Add /sys trigger for per-node " Mel Gorman
2010-02-17 16:30   ` Rik van Riel
2010-02-12 12:00 ` [PATCH 08/12] Direct compact when a high-order allocation fails Mel Gorman
2010-02-18  3:57   ` Rik van Riel
2010-02-12 12:00 ` [PATCH 09/12] Do not compact within a preferred zone after a compaction failure Mel Gorman
2010-02-18  4:09   ` Rik van Riel
2010-02-12 12:00 ` [PATCH 10/12] mm: Check for an empty VMA list in rmap_walk_anon Mel Gorman
2010-02-17 18:22   ` Mel Gorman
2010-02-12 12:00 ` [PATCH 11/12] mm: Take the RCU read lock " Mel Gorman
2010-02-12 12:00 ` [PATCH 12/12] mm: Check the anon_vma is still valid in rmap_walk_anon() Mel Gorman

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=20100219143310.GM30258@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=aarcange@redhat.com \
    --cc=agl@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=cl@linux-foundation.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    --cc=rientjes@google.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).