linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: Huang Shijie <shijie8@gmail.com>,
	akpm@linux-foundation.org, mel@csn.ul.ie,
	kosaki.motohiro@jp.fujitsu.com, linux-mm@kvack.org,
	Rik van Riel <riel@redhat.com>,
	Wu Fengguang <fengguang.wu@intel.com>
Subject: Re: [PATCH 4/4] mm/page_alloc : relieve zone->lock's pressure for memory free
Date: Tue, 12 Jan 2010 09:47:08 +0900	[thread overview]
Message-ID: <20100112094708.d09b01ea.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20100111153802.f3150117.minchan.kim@barrios-desktop>

On Mon, 11 Jan 2010 15:38:02 +0900
Minchan Kim <minchan.kim@gmail.com> wrote:

> On Mon, 11 Jan 2010 14:27:57 +0800
> Huang Shijie <shijie8@gmail.com> wrote:
> 
> >   Move the __mod_zone_page_state out the guard region of
> > the spinlock to relieve the pressure for memory free.
> > 
> >   Using the zone->lru_lock to replace the zone->lock for
> > zone->pages_scanned and zone's flag ZONE_ALL_UNRECLAIMABLE.
> > 
> > Signed-off-by: Huang Shijie <shijie8@gmail.com>
> > ---
> >  mm/page_alloc.c |   33 +++++++++++++++++++++++----------
> >  1 files changed, 23 insertions(+), 10 deletions(-)
> > 
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 290dfc3..dfd4be0 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -530,12 +530,9 @@ static void free_pcppages_bulk(struct zone *zone, int count,
> >  {
> >  	int migratetype = 0;
> >  	int batch_free = 0;
> > +	int free_ok = 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) {
> >  		struct page *page;
> >  		struct list_head *list;
> > @@ -558,23 +555,39 @@ static void free_pcppages_bulk(struct zone *zone, int count,
> >  			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);
> > +			free_ok += __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);
> > +
> > +	if (likely(free_ok)) {
> > +		spin_lock(&zone->lru_lock);
> > +		zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE);
> > +		zone->pages_scanned = 0;
> > +		spin_unlock(&zone->lru_lock);
> > +
> > +		__mod_zone_page_state(zone, NR_FREE_PAGES, free_ok);
> > +	}
> >  }
> >  
> >  static void free_one_page(struct zone *zone, struct page *page, int order,
> >  				int migratetype)
> >  {
> > -	spin_lock(&zone->lock);
> > -	zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE);
> > -	zone->pages_scanned = 0;
> > +	int free_ok;
> >  
> > -	__mod_zone_page_state(zone, NR_FREE_PAGES, 1 << order);
> > -	__free_one_page(page, zone, order, migratetype);
> > +	spin_lock(&zone->lock);
> > +	free_ok = __free_one_page(page, zone, order, migratetype);
> >  	spin_unlock(&zone->lock);
> > +
> > +	if (likely(free_ok)) {
> > +		spin_lock(&zone->lru_lock);
> > +		zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE);
> > +		zone->pages_scanned = 0;
> > +		spin_unlock(&zone->lru_lock);
> > +
> > +		__mod_zone_page_state(zone, NR_FREE_PAGES, free_ok << order);
> > +	}
> >  }
> >  
> >  static void __free_pages_ok(struct page *page, unsigned int order)
> > -- 
> > 1.6.5.2
> > 
> 
> Thanks, Huang. 
> 
> Frankly speaking, I am not sure this ir right way.
> This patch is adding to fine-grained locking overhead
> 
> As you know, this functions are one of hot pathes.
> In addition, we didn't see the any problem, until now.
> It means out of synchronization in ZONE_ALL_UNRECLAIMABLE 
> and pages_scanned are all right?
> 
> If it is, we can move them out of zone->lock, too.
> If it isn't, we need one more lock, then. 
> 
I don't want to see additional spin_lock, here. 

About ZONE_ALL_UNRECLAIMABLE, it's not necessary to be handled in atomic way.
If you have concerns with other flags, please modify this with single word,
instead of a bit field.

Thanks,
-Kame









--
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>

  parent reply	other threads:[~2010-01-12  0:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-11  4:37 [PATCH 1/4] mm/page_alloc : rename rmqueue_bulk to rmqueue_single Huang Shijie
2010-01-11  4:37 ` [PATCH 2/4] mm/page_alloc : relieve the zone->lock's pressure for allocation Huang Shijie
2010-01-11  4:37   ` [PATCH 3/4] mm/page_alloc : modify the return type of __free_one_page Huang Shijie
2010-01-11  4:37     ` [PATCH 4/4] mm/page_alloc : relieve zone->lock's pressure for memory free Huang Shijie
2010-01-11  5:20       ` Minchan Kim
2010-01-11  6:01         ` Huang Shijie
2010-01-11  6:27       ` Huang Shijie
2010-01-11  6:38         ` Minchan Kim
2010-01-11  6:59           ` Huang Shijie
2010-01-12  0:47           ` KAMEZAWA Hiroyuki [this message]
2010-01-12  2:02             ` Huang Shijie
2010-01-12  2:07               ` KAMEZAWA Hiroyuki
2010-01-12  2:32                 ` Huang Shijie
2010-01-12  2:27             ` Wu Fengguang
2010-01-12  2:56               ` KOSAKI Motohiro
2010-01-12  3:02                 ` Huang Shijie
2010-01-12  4:05               ` Minchan Kim
2010-01-12  4:21                 ` Wu Fengguang
2010-01-12  4:32                   ` KAMEZAWA Hiroyuki
2010-01-12  4:59                     ` Wu Fengguang
2010-01-12  5:09                       ` Wu Fengguang
2010-01-12  5:10                     ` KOSAKI Motohiro
2010-01-12  7:36                       ` David Rientjes
2010-01-12  8:56                         ` KOSAKI Motohiro
2010-01-12 21:39                           ` David Rientjes
2010-01-13  0:01                             ` KOSAKI Motohiro
2010-01-12  4:48                   ` Minchan Kim
2010-01-12  2:51       ` Huang Shijie
2010-01-12  3:03         ` Wu Fengguang
2010-01-12  3:05         ` KOSAKI Motohiro
2010-01-11  5:04     ` [PATCH 3/4] mm/page_alloc : modify the return type of __free_one_page Minchan Kim
2010-01-12  2:56     ` KOSAKI Motohiro
2010-01-18 11:25     ` Mel Gorman
2010-01-19  1:49       ` Huang Shijie
2010-01-11  5:02   ` [PATCH 2/4] mm/page_alloc : relieve the zone->lock's pressure for allocation Minchan Kim
2010-01-11  5:13     ` Huang Shijie
2010-01-12  2:54   ` KOSAKI Motohiro
2010-01-18 11:24   ` Mel Gorman
2010-01-11  5:00 ` [PATCH 1/4] mm/page_alloc : rename rmqueue_bulk to rmqueue_single Minchan Kim
2010-01-12  2:52 ` KOSAKI Motohiro
2010-01-18 11:21 ` 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=20100112094708.d09b01ea.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=minchan.kim@gmail.com \
    --cc=riel@redhat.com \
    --cc=shijie8@gmail.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