From: Mark Langsdorf <mark.langsdorf@amd.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Prevent immediate process rescheduling
Date: Fri, 18 Sep 2009 14:49:12 -0500 [thread overview]
Message-ID: <200909181449.12311.mark.langsdorf@amd.com> (raw)
Prevent the scheduler from immediately rescheduling a process
that just yielded if there is another process available.
Originally suggested by Mike Galbraith (efault@gmx.de).
Signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>
---
kernel/sched_fair.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 652e8bd..4fad08f 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -353,11 +353,25 @@ static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
static struct sched_entity *__pick_next_entity(struct cfs_rq *cfs_rq)
{
struct rb_node *left = cfs_rq->rb_leftmost;
+ struct sched_entity *se, *curr;
if (!left)
return NULL;
- return rb_entry(left, struct sched_entity, run_node);
+ se = rb_entry(left, struct sched_entity, run_node);
+ curr = ¤t->se;
+
+ /*
+ * Don't select the entity who just tried to schedule away
+ * if there's another entity available.
+ */
+ if (unlikely(se == curr && cfs_rq->nr_running > 1)) {
+ struct rb_node *next_node = rb_next(&curr->run_node);
+ if (next_node)
+ se = rb_entry(next_node, struct sched_entity, run_node);
+ }
+
+ return se;
}
static struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
--
1.6.0.2
next reply other threads:[~2009-09-18 19:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-18 19:49 Mark Langsdorf [this message]
2009-09-18 19:54 ` [PATCH] Prevent immediate process rescheduling Ingo Molnar
2009-09-18 20:00 ` Langsdorf, Mark
2009-09-18 20:03 ` Peter Zijlstra
2009-09-19 2:16 ` Mike Galbraith
2009-09-19 9:03 ` Mike Galbraith
2009-09-19 8:31 ` Avi Kivity
2009-09-20 21:03 ` Langsdorf, Mark
2009-09-20 21:55 ` Avi Kivity
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=200909181449.12311.mark.langsdorf@amd.com \
--to=mark.langsdorf@amd.com \
--cc=linux-kernel@vger.kernel.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