mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: "'Con Kolivas'" <kernel@kolivas.org>
Cc: "Mike Galbraith" <efault@gmx.de>, <tim.c.chen@linux.intel.com>,
	<linux-kernel@vger.kernel.org>, <mingo@elte.hu>,
	"Andrew Morton" <akpm@osdl.org>, <mbligh@mbligh.org>
Subject: RE: [PATCH] sched: fix interactive ceiling code
Date: Fri, 19 May 2006 07:37:44 -0700	[thread overview]
Message-ID: <4t16i2$14qld0@orsmga001.jf.intel.com> (raw)
In-Reply-To: <200605191130.59282.kernel@kolivas.org>

Con Kolivas wrote on Thursday, May 18, 2006 6:31 PM
> Ingo, Andrew, I think these are minor logic fixes and comments that correct 
> a patch that has already been pushed to 2.6.17- and I would like them short
> circuited to mainline if everyone is comfortable with it.
>  
> Ken, Mike can I ask you to put a signed off on this patch for your 
> contributions please?

Yup, looks good. Thanks for all the explanation and certainly your patience.

Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>



> ---
> The relationship between INTERACTIVE_SLEEP and the ceiling is not perfect
> and not explicit enough. The sleep boost is not supposed to be any larger
> than without this code and the comment is not clear enough about what exactly
> it does, just the reason it does it. Fix it.
> 
> There is a ceiling to the priority beyond which tasks that only ever sleep
> for very long periods cannot surpass. Fix it.
> 
> Prevent the on-runqueue bonus logic from defeating the idle sleep logic.
> 
> Opportunity to micro-optimise.
> 
> Signed-off-by: Con Kolivas <kernel@kolivas.org>
> 
> ---
>  kernel/sched.c |   52 +++++++++++++++++++++++++++-------------------------
>  1 files changed, 27 insertions(+), 25 deletions(-)
> 
> Index: linux-2.6.17-rc4/kernel/sched.c
> ===================================================================
> --- linux-2.6.17-rc4.orig/kernel/sched.c	2006-05-19 11:25:01.000000000 +1000
> +++ linux-2.6.17-rc4/kernel/sched.c	2006-05-19 11:25:14.000000000 +1000
> @@ -731,33 +731,35 @@ static inline void __activate_idle_task(
>  static int recalc_task_prio(task_t *p, unsigned long long now)
>  {
>  	/* Caller must always ensure 'now >= p->timestamp' */
> -	unsigned long long __sleep_time = now - p->timestamp;
> -	unsigned long sleep_time;
> +	unsigned long sleep_time = now - p->timestamp;
>  
>  	if (batch_task(p))
>  		sleep_time = 0;
> -	else {
> -		if (__sleep_time > NS_MAX_SLEEP_AVG)
> -			sleep_time = NS_MAX_SLEEP_AVG;
> -		else
> -			sleep_time = (unsigned long)__sleep_time;
> -	}
>  
>  	if (likely(sleep_time > 0)) {
>  		/*
> -		 * User tasks that sleep a long time are categorised as
> -		 * idle. They will only have their sleep_avg increased to a
> -		 * level that makes them just interactive priority to stay
> -		 * active yet prevent them suddenly becoming cpu hogs and
> -		 * starving other processes.
> +		 * This ceiling is set to the lowest priority that would allow
> +		 * a task to be reinserted into the active array on timeslice
> +		 * completion.
>  		 */
> -		if (p->mm && sleep_time > INTERACTIVE_SLEEP(p)) {
> -				unsigned long ceiling;
> +		unsigned long ceiling = INTERACTIVE_SLEEP(p);
>  
> -				ceiling = JIFFIES_TO_NS(MAX_SLEEP_AVG -
> -					DEF_TIMESLICE);
> -				if (p->sleep_avg < ceiling)
> -					p->sleep_avg = ceiling;
> +		if (p->mm && sleep_time > ceiling && p->sleep_avg < ceiling) {
> +			/*
> +			 * Prevents user tasks from achieving best priority
> +			 * with one single large enough sleep.
> +			 */
> +			p->sleep_avg = ceiling;
> +			/*
> +			 * Using INTERACTIVE_SLEEP() as a ceiling places a
> +			 * nice(0) task 1ms sleep away from promotion, and
> +			 * gives it 700ms to round-robin with no chance of
> +			 * being demoted.  This is more than generous, so
> +			 * mark this sleep as non-interactive to prevent the
> +			 * on-runqueue bonus logic from intervening should
> +			 * this task not receive cpu immediately.
> +			 */
> +			p->sleep_type = SLEEP_NONINTERACTIVE;
>  		} else {
>  			/*
>  			 * Tasks waking from uninterruptible sleep are
> @@ -765,12 +767,12 @@ static int recalc_task_prio(task_t *p, u
>  			 * are likely to be waiting on I/O
>  			 */
>  			if (p->sleep_type == SLEEP_NONINTERACTIVE && p->mm) {
> -				if (p->sleep_avg >= INTERACTIVE_SLEEP(p))
> +				if (p->sleep_avg >= ceiling)
>  					sleep_time = 0;
>  				else if (p->sleep_avg + sleep_time >=
> -						INTERACTIVE_SLEEP(p)) {
> -					p->sleep_avg = INTERACTIVE_SLEEP(p);
> -					sleep_time = 0;
> +					 ceiling) {
> +						p->sleep_avg = ceiling;
> +						sleep_time = 0;
>  				}
>  			}
>  
> @@ -784,9 +786,9 @@ static int recalc_task_prio(task_t *p, u
>  			 */
>  			p->sleep_avg += sleep_time;
>  
> -			if (p->sleep_avg > NS_MAX_SLEEP_AVG)
> -				p->sleep_avg = NS_MAX_SLEEP_AVG;
>  		}
> +		if (p->sleep_avg > NS_MAX_SLEEP_AVG)
> +			p->sleep_avg = NS_MAX_SLEEP_AVG;
>  	}
>  
>  	return effective_prio(p);
> -- 
> -ck

  parent reply	other threads:[~2006-05-19 14:37 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-08 23:18 Regression seen for patch "sched:dont decrease idle sleep avg" Tim Chen
2006-05-09  0:43 ` Con Kolivas
2006-05-09  1:07   ` Martin Bligh
2006-05-12  0:04   ` Chen, Kenneth W
2006-05-13 12:27     ` Andrew Morton
2006-05-13 13:07       ` Mike Galbraith
2006-05-14 16:03     ` Con Kolivas
2006-05-15 19:01       ` Chen, Kenneth W
2006-05-15 23:45         ` Con Kolivas
2006-05-16  1:22           ` Chen, Kenneth W
2006-05-16  1:44             ` Con Kolivas
2006-05-16  4:10           ` Mike Galbraith
2006-05-16 23:32           ` Tim Chen
2006-05-17  4:25             ` Mike Galbraith
2006-05-17  4:45               ` Peter Williams
2006-05-17  5:24                 ` Mike Galbraith
2006-05-17  8:23             ` Con Kolivas
2006-05-17  9:49               ` Mike Galbraith
2006-05-17 10:25                 ` Con Kolivas
2006-05-17 11:42                   ` Mike Galbraith
2006-05-17 12:46                     ` Con Kolivas
2006-05-17 13:41                       ` Mike Galbraith
2006-05-17 15:10                         ` Con Kolivas
2006-05-17 17:21                           ` Ray Lee
2006-05-17 19:33               ` Chen, Kenneth W
2006-05-18  0:35                 ` Con Kolivas
2006-05-18  1:10                   ` Chen, Kenneth W
2006-05-18  1:38                     ` Con Kolivas
2006-05-18  5:44                       ` Mike Galbraith
2006-05-18  5:52                         ` Con Kolivas
2006-05-18  7:04                           ` Mike Galbraith
2006-05-18 12:59                             ` Mike Galbraith
2006-05-19  1:10                               ` Con Kolivas
2006-05-18 23:17                           ` Chen, Kenneth W
2006-05-19  1:30                             ` [PATCH] sched: fix interactive ceiling code Con Kolivas
2006-05-19  2:02                               ` Mike Galbraith
2006-05-19  9:40                               ` Ingo Molnar
2006-05-19 14:37                               ` Chen, Kenneth W [this message]
2006-05-19 16:19                                 ` tim_c_chen
2006-05-18 23:34                           ` Regression seen for patch "sched:dont decrease idle sleep avg" Chen, Kenneth W
2006-05-19  1:07                             ` Con Kolivas
2006-05-16  4:07         ` Mike Galbraith

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='4t16i2$14qld0@orsmga001.jf.intel.com' \
    --to=kenneth.w.chen@intel.com \
    --cc=akpm@osdl.org \
    --cc=efault@gmx.de \
    --cc=kernel@kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbligh@mbligh.org \
    --cc=mingo@elte.hu \
    --cc=tim.c.chen@linux.intel.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

Powered by JetHome