From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Mike Galbraith <efault@gmx.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] sched: high-res preemption tick
Date: Sun, 14 Oct 2007 01:13:48 +0200 [thread overview]
Message-ID: <1192317228.5625.8.camel@lappy> (raw)
In-Reply-To: <1192267072.5897.5.camel@lappy>
On Sat, 2007-10-13 at 11:17 +0200, Peter Zijlstra wrote:
> > Ah, but HRTICK is not compatible with PREEMPT_RESTRICT, it will be
> > similar to !WAKEUP_PREEMPT.
>
> (I do plan to fix that eventually, just need to do it)
I guess something like this ought to do, but its a tad late so I'm quite
sure :-)
---
kernel/sched_fair.c | 44 +++++++++++++++++++++++++++++++++++++-------
1 file changed, 37 insertions(+), 7 deletions(-)
Index: linux-2.6/kernel/sched_fair.c
===================================================================
--- linux-2.6.orig/kernel/sched_fair.c
+++ linux-2.6/kernel/sched_fair.c
@@ -737,6 +737,24 @@ static inline struct sched_entity *paren
#endif /* CONFIG_FAIR_GROUP_SCHED */
+/*
+ * does pse (newly woken task) preempt se (current task)
+ */
+static int wakeup_preempt(struct sched_entity *se, struct sched_entity *pse)
+{
+ s64 delta, gran;
+
+ delta = se->vruntime - pse->vruntime;
+ gran = sysctl_sched_wakeup_granularity;
+ if (unlikely(se->load.weight != NICE_0_LOAD))
+ gran = calc_delta_fair(gran, &se->load);
+
+ if (delta > gran)
+ return 1;
+
+ return 0;
+}
+
#ifdef CONFIG_SCHED_HRTICK
static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
{
@@ -764,6 +782,24 @@ static void hrtick_start_fair(struct rq
if (!requeue)
delta = max(10000LL, delta);
+ /*
+ * if we delayed wakeup preemption, shorten the slice to at most
+ * 1 jiffy (does this call for yet another sysctl_sched_?)
+ */
+ if (sched_feat(PREEMPT_RESTRICT) && first_fair(cfs_rq)) {
+ struct sched_entity *next = __pick_next_entity(cfs_rq);
+
+ if (wakeup_preempt(se, next)) {
+ u64 wakeup = NSEC_PER_SEC / HZ;
+ s64 delta2 = wakeup - ran;
+
+ if (delta2 < 0)
+ resched_task(rq->curr);
+ else
+ delta = min(delta, delta2);
+ }
+ }
+
hrtick_start(rq, delta, requeue);
}
}
@@ -866,7 +902,6 @@ static void check_preempt_wakeup(struct
struct task_struct *curr = rq->curr;
struct cfs_rq *cfs_rq = task_cfs_rq(curr);
struct sched_entity *se = &curr->se, *pse = &p->se;
- s64 delta, gran;
if (unlikely(rt_prio(p->prio))) {
update_rq_clock(rq);
@@ -887,12 +922,7 @@ static void check_preempt_wakeup(struct
pse = parent_entity(pse);
}
- delta = se->vruntime - pse->vruntime;
- gran = sysctl_sched_wakeup_granularity;
- if (unlikely(se->load.weight != NICE_0_LOAD))
- gran = calc_delta_fair(gran, &se->load);
-
- if (delta > gran) {
+ if (wakeup_preempt(se, pse)) {
int now = !sched_feat(PREEMPT_RESTRICT);
if (now || p->prio < curr->prio || !se->peer_preempt++)
next prev parent reply other threads:[~2007-10-13 23:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 20:51 [PATCH] sched: high-res preemption tick Peter Zijlstra
2007-10-13 7:18 ` Mike Galbraith
2007-10-13 8:55 ` Peter Zijlstra
2007-10-13 9:17 ` Peter Zijlstra
2007-10-13 10:11 ` Mike Galbraith
2007-10-13 23:13 ` Peter Zijlstra [this message]
2007-10-13 23:16 ` Peter Zijlstra
2007-10-14 6:34 ` Mike Galbraith
2007-10-13 22:51 ` [RFC][PATCH] sched: SCHED_FIFO watchdog timer Peter Zijlstra
2007-10-15 13:26 ` Dmitry Adamushko
2007-10-15 13:57 ` Peter Zijlstra
2007-10-15 14:25 ` Lennart Poettering
2007-10-15 21:32 ` Kay Sievers
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=1192317228.5625.8.camel@lappy \
--to=a.p.zijlstra@chello.nl \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.