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: Andrew Morton <akpm@linux-foundation.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Christoph Lameter <cl@linux-foundation.org>,
	Nick Piggin <npiggin@suse.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] page-allocator: Maintain rolling count of pages to free from the PCP
Date: Mon, 31 Aug 2009 13:11:53 +0100	[thread overview]
Message-ID: <20090831121153.GD29627@csn.ul.ie> (raw)
In-Reply-To: <28c262360908280804r4c40c7baw7bb535dd8c275960@mail.gmail.com>

On Sat, Aug 29, 2009 at 12:04:48AM +0900, Minchan Kim wrote:
> 
> On Fri, Aug 28, 2009 at 5:44 PM, Mel Gorman<mel@csn.ul.ie> wrote:
> > When round-robin freeing pages from the PCP lists, empty lists may be
> > encountered. In the event one of the lists has more pages than another,
> > there may be numerous checks for list_empty() which is undesirable. This
> > patch maintains a count of pages to free which is incremented when empty
> > lists are encountered. The intention is that more pages will then be freed
> > from fuller lists than the empty ones reducing the number of empty list
> > checks in the free path.
> >
> > Signed-off-by: Mel Gorman <mel@csn.ul.ie>
> > ---
> >  mm/page_alloc.c |   23 ++++++++++++++---------
> >  1 files changed, 14 insertions(+), 9 deletions(-)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 65eedb5..9b86977 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -536,32 +536,37 @@ static void free_pcppages_bulk(struct zone *zone, int count,
> >                                        struct per_cpu_pages *pcp)
> >  {
> >        int migratetype = 0;
> > +       int batch_free = 0;
> >
> >        spin_lock(&zone->lock);
> >        zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE);
> >        zone->pages_scanned = 0;
> >
> >        __mod_zone_page_state(zone, NR_FREE_PAGES, count);
> > -       while (count--) {
> > +       while (count) {
> >                struct page *page;
> >                struct list_head *list;
> >
> >                /*
> > -                * Remove pages from lists in a round-robin fashion. This spinning
> > -                * around potentially empty lists is bloody awful, alternatives that
> > -                * don't suck are welcome
> > +                * Remove pages from lists in a round-robin fashion. A batch_free
> > +                * count is maintained that is incremented when an empty list is
> > +                * encountered. This is so more pages are freed off fuller lists
> > +                * instead of spinning excessively around empty lists
> >                 */
> >                do {
> > +                       batch_free++;
> >                        if (++migratetype == MIGRATE_PCPTYPES)
> >                                migratetype = 0;
> >                        list = &pcp->lists[migratetype];
> >                } while (list_empty(list));
> 
> How about increasing the weight by batch_free ?
> 
> batch_free = 1 << (batch_free - 1);
> 
> It's assumed that if batch_free is big, it means
> there are contiguous empty lists.
> Then it is likely to need more time to refill empty lists than
> one list refill. So I think it can decrease spinning empty list
> a little more.
> 

Maybe. As it is, the list spinning is not too bad and significant
amounts of time are no longer being spent in there. I've taken note to
follow-up and investigate your suggestion to see if it works out and if
it makes a difference.

Thanks

> >
> > -               page = list_entry(list->prev, struct page, lru);
> > -               /* have to delete it as __free_one_page list manipulates */
> > -               list_del(&page->lru);
> > -               trace_mm_page_pcpu_drain(page, 0, migratetype);
> > -               __free_one_page(page, zone, 0, migratetype);
> > +               do {
> > +                       page = list_entry(list->prev, struct page, lru);
> > +                       /* must delete as __free_one_page list manipulates */
> > +                       list_del(&page->lru);
> > +                       __free_one_page(page, zone, 0, migratetype);
> > +                       trace_mm_page_pcpu_drain(page, 0, migratetype);
> > +               } while (--count && --batch_free && !list_empty(list));
> >        }
> >        spin_unlock(&zone->lock);
> >  }
> > --
> > 1.6.3.3
> >
> > --
> > 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>
> >
> 
> 
> 
> -- 
> Kind regards,
> Minchan Kim
> 

-- 
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:[~2009-08-31 12:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-28  8:44 [PATCH 0/3] Reduce searching in the page allocator fast-path Mel Gorman
2009-08-28  8:44 ` [PATCH 1/2] page-allocator: Split per-cpu list into one-list-per-migrate-type Mel Gorman
2009-08-28 11:52   ` Minchan Kim
2009-08-28 12:00     ` Minchan Kim
2009-08-28 12:56       ` Mel Gorman
2009-08-28 13:46         ` Minchan Kim
2009-08-28  8:44 ` [PATCH 2/2] page-allocator: Maintain rolling count of pages to free from the PCP Mel Gorman
2009-08-28 12:16   ` Pekka Enberg
2009-08-28 12:57     ` Mel Gorman
2009-08-28 13:02       ` Pekka Enberg
2009-08-28 13:36         ` Mel Gorman
2009-08-28 13:43           ` Pekka Enberg
2009-08-28 13:49   ` Minchan Kim
2009-08-28 15:04   ` Minchan Kim
2009-08-31 12:11     ` Mel Gorman [this message]
2009-08-28  8:47 ` [PATCH 0/3] Reduce searching in the page allocator fast-path 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=20090831121153.GD29627@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    --cc=npiggin@suse.de \
    /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