linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"mgorman@suse.de" <mgorman@suse.de>,
	"minchan.kim@gmail.com" <minchan.kim@gmail.com>
Subject: Re: [patch 3/3]vmscan: cleanup kswapd_try_to_sleep
Date: Tue, 02 Aug 2011 09:03:24 +0800	[thread overview]
Message-ID: <1312247004.15392.451.camel@sli10-conroe> (raw)
In-Reply-To: <4E374637.20202@jp.fujitsu.com>

On Tue, 2011-08-02 at 08:35 +0800, KOSAKI Motohiro wrote:
> (2011/07/28 17:13), Shaohua Li wrote:
> > cleanup kswapd_try_to_sleep() a little bit. Sometimes kswapd doesn't
> > really sleep. In such case, don't call prepare_to_wait/finish_wait.
> > It just wastes CPU.
> > 
> > Signed-off-by: Shaohua Li <shaohua.li@intel.com>
> > ---
> >  mm/vmscan.c |    7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > Index: linux/mm/vmscan.c
> > ===================================================================
> > --- linux.orig/mm/vmscan.c	2011-07-28 15:52:35.000000000 +0800
> > +++ linux/mm/vmscan.c	2011-07-28 15:55:56.000000000 +0800
> > @@ -2709,13 +2709,11 @@ static void kswapd_try_to_sleep(pg_data_
> >  	if (freezing(current) || kthread_should_stop())
> >  		return;
> >  
> > -	prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
> > -
> >  	/* Try to sleep for a short interval */
> >  	if (!sleeping_prematurely(pgdat, order, remaining, classzone_idx)) {
> > +		prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
> >  		remaining = schedule_timeout(HZ/10);
> >  		finish_wait(&pgdat->kswapd_wait, &wait);
> > -		prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
> >  	}
> >  
> >  	/*
> > @@ -2734,7 +2732,9 @@ static void kswapd_try_to_sleep(pg_data_
> >  		 * them before going back to sleep.
> >  		 */
> >  		set_pgdat_percpu_threshold(pgdat, calculate_normal_threshold);
> > +		prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
> >  		schedule();
> > +		finish_wait(&pgdat->kswapd_wait, &wait);
> >  		set_pgdat_percpu_threshold(pgdat, calculate_pressure_threshold);
> >  	} else {
> >  		if (remaining)
> > @@ -2742,7 +2742,6 @@ static void kswapd_try_to_sleep(pg_data_
> >  		else
> >  			count_vm_event(KSWAPD_HIGH_WMARK_HIT_QUICKLY);
> >  	}
> > -	finish_wait(&pgdat->kswapd_wait, &wait);
> >  }
> >  
> >  /*
> 
> Prepare_to_wait/finish_wait basic usage is below. Briefly,
> 1) prepare_to_wait() is needed to call every sleeping
yes

> 2) finish_wait is only need to exit sleeping loop
> 
> So, 1) moving prepare_to_wait looks pretty good to me. but I doubt the worth
> of moving the finish_wait of function last.
so you are talking about leave the last finish_wait at the end of the
function, and delete other finish_wait, right? that is ok, but I'm
afraid it's not readable. a pair of prepare_to_wait/schedule/finish_wait
is more readable.

Thanks,
Shaohua

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-08-02  1:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28  8:13 Shaohua Li
2011-07-28 11:03 ` Mel Gorman
2011-07-29  0:17   ` Shaohua Li
2011-07-29  9:39 ` Minchan Kim
2011-07-29 10:46   ` Shaohua Li
2011-08-02  0:35 ` KOSAKI Motohiro
2011-08-02  1:03   ` Shaohua Li [this message]
2011-08-02  1:48     ` KOSAKI Motohiro
2011-08-19 23:56 ` Andrew Morton

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=1312247004.15392.451.camel@sli10-conroe \
    --to=shaohua.li@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=minchan.kim@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