public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Mike Galbraith <efault@gmx.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Tony Lindgren <tony@atomide.com>
Subject: Re: [RFC PATCH] sched: START_NICE feature (temporarily niced forks) (v3)
Date: Mon, 20 Sep 2010 13:43:46 +0200	[thread overview]
Message-ID: <1284983026.2275.695.camel@laptop> (raw)
In-Reply-To: <20100914202503.GA1496@Krystal>

On Tue, 2010-09-14 at 16:25 -0400, Mathieu Desnoyers wrote:


> Index: linux-2.6-lttng.git/include/linux/sched.h
> ===================================================================
> --- linux-2.6-lttng.git.orig/include/linux/sched.h
> +++ linux-2.6-lttng.git/include/linux/sched.h
> @@ -1132,6 +1132,8 @@ struct sched_entity {
>  	u64			prev_sum_exec_runtime;
>  
>  	u64			nr_migrations;
> +	u64			fork_nice_timeout;
> +	unsigned int		fork_nice_penality;
>  
>  #ifdef CONFIG_SCHEDSTATS
>  	struct sched_statistics statistics;
> Index: linux-2.6-lttng.git/kernel/sched.c
> ===================================================================
> --- linux-2.6-lttng.git.orig/kernel/sched.c
> +++ linux-2.6-lttng.git/kernel/sched.c
> @@ -2421,6 +2421,8 @@ static void __sched_fork(struct task_str
>  	p->se.sum_exec_runtime		= 0;
>  	p->se.prev_sum_exec_runtime	= 0;
>  	p->se.nr_migrations		= 0;
> +	p->se.fork_nice_timeout		= 0;
> +	p->se.fork_nice_penality	= 0;
>  
>  #ifdef CONFIG_SCHEDSTATS
>  	memset(&p->se.statistics, 0, sizeof(p->se.statistics));
> Index: linux-2.6-lttng.git/kernel/sched_fair.c
> ===================================================================
> --- linux-2.6-lttng.git.orig/kernel/sched_fair.c
> +++ linux-2.6-lttng.git/kernel/sched_fair.c
> @@ -433,6 +433,14 @@ calc_delta_fair(unsigned long delta, str
>  	if (unlikely(se->load.weight != NICE_0_LOAD))
>  		delta = calc_delta_mine(delta, NICE_0_LOAD, &se->load);
>  
> +	if (se->fork_nice_penality) {
> +		delta <<= se->fork_nice_penality;
> +		if ((s64)(se->sum_exec_runtime - se->fork_nice_timeout) > 0) {
> +			se->fork_nice_penality = 0;
> +			se->fork_nice_timeout = 0;
> +		}
> +	}
> +
>  	return delta;
>  }

Something like this ought to live at every place where you use se->load,
including sched_slice(), possibly wakeup_gran(), although that's more
heuristic, so you could possibly leave it out there.

> @@ -832,6 +840,11 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
>  	 */
>  	if (!(flags & DEQUEUE_SLEEP))
>  		se->vruntime -= cfs_rq->min_vruntime;
> +
> +	if (se->fork_nice_penality) {
> +		se->fork_nice_penality = 0;
> +		se->fork_nice_timeout = 0;
> +	}
>  }
>  
>  /*

So you want to reset this penalty on each de-schedule, not only sleep
(but also preemptions)?

> @@ -3544,8 +3557,27 @@ static void task_fork_fair(struct task_s
>  
>  	update_curr(cfs_rq);
>  
> -	if (curr)
> +	if (curr) {
>  		se->vruntime = curr->vruntime;
> +		if (sched_feat(START_NICE)) {
> +			if (curr->fork_nice_penality &&
> +			    (s64)(curr->sum_exec_runtime
> +				  - curr->fork_nice_timeout) > 0) {
> +				curr->fork_nice_penality = 0;
> +				curr->fork_nice_timeout = 0;
> +			}
> +
> +			if (!curr->fork_nice_timeout)
> +				curr->fork_nice_timeout =
> +					curr->sum_exec_runtime;
> +			curr->fork_nice_timeout += sched_slice(cfs_rq, curr);
> +			curr->fork_nice_penality = min_t(unsigned int,
> +							 curr->fork_nice_penality + 1, 8);
> +			se->fork_nice_timeout = curr->fork_nice_timeout
> +						- curr->sum_exec_runtime;
> +			se->fork_nice_penality = curr->fork_nice_penality;
> +		}
> +	}
>  	place_entity(cfs_rq, se, 1);
>  
>  	if (sysctl_sched_child_runs_first && curr && entity_before(curr, se)) {

If you stick than in a separate function you can loose 2 indent levels,
which would help with readability.

  parent reply	other threads:[~2010-09-20 11:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-14 20:25 [RFC PATCH] sched: START_NICE feature (temporarily niced forks) (v3) Mathieu Desnoyers
2010-09-15  8:37 ` Mike Galbraith
2010-09-15  9:03   ` Mike Galbraith
2010-09-15  9:22     ` Ingo Molnar
2010-09-15 13:12       ` Mike Galbraith
2010-09-15 14:02         ` Ingo Molnar
2010-09-16 10:30           ` Mike Galbraith
2010-09-20 11:43 ` Peter Zijlstra [this message]
2010-09-20 16:02   ` Mathieu Desnoyers
2010-09-20 16:15     ` Peter Zijlstra
2010-09-20 18:49       ` Mathieu Desnoyers

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=1284983026.2275.695.camel@laptop \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tony@atomide.com \
    --cc=torvalds@linux-foundation.org \
    /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