lkml.org 
[lkml]   [2009]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 8/8] Use hrtick when available
To have a more precise budget enforcement, use the hrtick when available.
This comes at the cost of additional overhead; anyway it is disabled by
default.
---
kernel/sched_rt.c | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index a9db16b..38a7be0 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1150,14 +1150,41 @@ static struct task_struct *_pick_next_task_rt(struct rq *rq)
return p;
}

+static void rt_start_hrtick(struct rq *rq, struct task_struct *p)
+{
+ struct sched_rt_entity *rt_se = &p->rt;
+ struct rt_rq *rt_rq;
+ s64 delta, expires = global_rt_period();
+
+ for_each_sched_rt_entity(rt_se) {
+ rt_rq = rt_rq_of_se(rt_se);
+ delta = rt_rq->rt_runtime - rt_rq->rt_time;
+ expires = min(expires, delta);
+ }
+
+ /*
+ * Given the current handling of hrtick in sched_fair, this
+ * may interfere with sched_fair tasks, generating a spurious
+ * tick when switching from an RT to a SCHED_OTHER task.
+ * This is due to the fact that sched_fair reprograms the
+ * hrtick only in its enqueue/dequeue codepaths.
+ */
+ if (expires > 10000)
+ hrtick_start(rq, expires);
+}
+
static struct task_struct *pick_next_task_rt(struct rq *rq)
{
struct task_struct *p = _pick_next_task_rt(rq);

/* The running task is never eligible for pushing */
- if (p)
+ if (p) {
dequeue_pushable_task(rq, p);

+ if (hrtick_enabled(rq))
+ rt_start_hrtick(rq, p);
+ }
+
return p;
}

@@ -1794,6 +1821,9 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued)
{
update_curr_rt(rq);

+ if (queued)
+ return;
+
watchdog(rq, p);

/*
--
1.6.2.2

\
 
 \ /
  Last update: 2009-06-15 21:11    [W:1.179 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site