mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suresh Jayaraman <sjayaraman@suse.de>
To: Ingo Molnar <mingo@elte.hu>, Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-kernel@vger.kernel.org, Suresh Jayaraman <sjayaraman@suse.de>
Subject: [RFC][PATCH] sched: avoid huge bonus to sleepers on busy machines
Date: Mon,  4 Jan 2010 14:50:42 +0530	[thread overview]
Message-ID: <1262596842-17392-1-git-send-email-sjayaraman@suse.de> (raw)

As I understand the idea of sleeper fairness is to consider sleeping tasks
similar to the ones on the runqueue and credit the sleepers in a way that it
would get CPU as if it were running.

Currently, when fair sleepers are enabled, the task that was sleeping seem to
get a bonus of cfs_rq->min_vruntime - sched_latency (in most cases). While with
gentle fair sleepers this effect was reduced to half, there still remains a
chance that on busy machines with more number of tasks, the sleepers might get
a huge undue bonus.

Here's a patch to avoid this by computing the entitled CPU time for the
sleeping task during the period taking into account only the current
cfs_rq->nr_running and thus tries to make it adaptive.
Compile-tested only.

Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
---
 kernel/sched_fair.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 42ac3c9..d81fcb3 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -739,6 +739,15 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
 	/* sleeps up to a single latency don't count. */
 	if (!initial && sched_feat(FAIR_SLEEPERS)) {
 		unsigned long thresh = sysctl_sched_latency;
+		unsigned long delta_exec = (unsigned long)
+					(rq_of(cfs_rq)->clock - se->exec_start);
+		unsigned long sleeper_bonus;
+
+		/* entitled share of CPU time adapted to current nr_running */
+		if (likely(cfs_rq->nr_running > 1))
+			sleeper_bonus = delta_exec/cfs_rq->nr_running;
+		else
+			sleeper_bonus = delta_exec;
 
 		/*
 		 * Convert the sleeper threshold into virtual time.
@@ -757,7 +766,7 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
 		if (sched_feat(GENTLE_FAIR_SLEEPERS))
 			thresh >>= 1;
 
-		vruntime -= thresh;
+		vruntime -= min(thresh, sleeper_bonus);
 	}
 
 	/* ensure we never gain time by being placed backwards. */

             reply	other threads:[~2010-01-04  9:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-04  9:20 Suresh Jayaraman [this message]
2010-01-04 11:14 ` Mike Galbraith
2010-01-04 12:02   ` Suresh Jayaraman
2010-01-04 12:30     ` Mike Galbraith
2010-01-04 12:36       ` Peter Zijlstra
2010-01-04 12:49         ` 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=1262596842-17392-1-git-send-email-sjayaraman@suse.de \
    --to=sjayaraman@suse.de \
    --cc=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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

all inboxes | Powered by JetHome®