* [PATCH] sched: fair scheduler should not resched rt tasks
@ 2008-10-11 7:01 Steven Rostedt
2008-10-11 11:02 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2008-10-11 7:01 UTC (permalink / raw)
To: LKML
Cc: Linus Torvalds, Andrew Morton, Ingo Molnar, Thomas Gleixner,
Clark Williams, Peter Zijlstra
Using ftrace, I noticed latencies in real-time tasks where they were
needlessly calling schedule due to sched_fair sending out time slices.
This patch prevents a call to resched_task by the sched fair class if
the task it wants to reschedule is an rt task.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/sched_fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-compile.git/kernel/sched_fair.c
===================================================================
--- linux-compile.git.orig/kernel/sched_fair.c 2008-10-11 02:54:01.000000000 -0400
+++ linux-compile.git/kernel/sched_fair.c 2008-10-11 02:55:52.000000000 -0400
@@ -889,7 +889,7 @@ static void hrtick_start_fair(struct rq
s64 delta = slice - ran;
if (delta < 0) {
- if (rq->curr == p)
+ if (rq->curr == p && !rt_task(p))
resched_task(p);
return;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] sched: fair scheduler should not resched rt tasks 2008-10-11 7:01 [PATCH] sched: fair scheduler should not resched rt tasks Steven Rostedt @ 2008-10-11 11:02 ` Peter Zijlstra 2008-10-11 13:55 ` Steven Rostedt 0 siblings, 1 reply; 3+ messages in thread From: Peter Zijlstra @ 2008-10-11 11:02 UTC (permalink / raw) To: Steven Rostedt Cc: LKML, Linus Torvalds, Andrew Morton, Ingo Molnar, Thomas Gleixner, Clark Williams On Sat, 2008-10-11 at 03:01 -0400, Steven Rostedt wrote: > Using ftrace, I noticed latencies in real-time tasks where they were > needlessly calling schedule due to sched_fair sending out time slices. > > This patch prevents a call to resched_task by the sched fair class if > the task it wants to reschedule is an rt task. Right, thats not a good thing, however this patch looks wrong, we should never call hrtick_start_fair() on a rt task to begin with. The way I can see that happening is through enqueue/dequeue_task_fair() where we want to re-programm the hrtick because nr_running changes (and thus the current tasks desired runtime). Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> --- diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 5d39d92..6bcceec 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -73,6 +73,8 @@ unsigned int sysctl_sched_wakeup_granularity = 5000000UL; const_debug unsigned int sysctl_sched_migration_cost = 500000UL; +static const struct sched_class fair_sched_class; + /************************************************************** * CFS operations on generic schedulable entities: */ @@ -849,11 +851,31 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p) hrtick_start(rq, delta); } } + +/* + * called from enqueue/dequeue and updates the hrtick when the + * current task is from our class and nr_running is low enough + * to matter. + */ +static void hrtick_update(struct rq *rq) +{ + struct task_struct *curr = rq->curr; + + if (curr->sched_class != &fair_sched_class) + return; + + if (cfs_rq_of(&curr->se)->nr_running < sched_nr_latency) + hrtick_start_fair(rq, curr); +} #else /* !CONFIG_SCHED_HRTICK */ static inline void hrtick_start_fair(struct rq *rq, struct task_struct *p) { } + +static inline void hrtick_update(struct rq *rq) +{ +} #endif /* @@ -874,7 +896,7 @@ static void enqueue_task_fair(struct rq *rq, struct task_struct *p, int wakeup) wakeup = 1; } - hrtick_start_fair(rq, rq->curr); + hrtick_update(rq); } /* @@ -896,7 +918,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int sleep) sleep = 1; } - hrtick_start_fair(rq, rq->curr); + hrtick_update(rq); } /* @@ -1002,8 +1024,6 @@ static inline int wake_idle(int cpu, struct task_struct *p) #ifdef CONFIG_SMP -static const struct sched_class fair_sched_class; - #ifdef CONFIG_FAIR_GROUP_SCHED /* * effective_load() calculates the load change as seen from the root_task_group ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched: fair scheduler should not resched rt tasks 2008-10-11 11:02 ` Peter Zijlstra @ 2008-10-11 13:55 ` Steven Rostedt 0 siblings, 0 replies; 3+ messages in thread From: Steven Rostedt @ 2008-10-11 13:55 UTC (permalink / raw) To: Peter Zijlstra Cc: LKML, Linus Torvalds, Andrew Morton, Ingo Molnar, Thomas Gleixner, Clark Williams On Sat, 11 Oct 2008, Peter Zijlstra wrote: > On Sat, 2008-10-11 at 03:01 -0400, Steven Rostedt wrote: > > Using ftrace, I noticed latencies in real-time tasks where they were > > needlessly calling schedule due to sched_fair sending out time slices. > > > > This patch prevents a call to resched_task by the sched fair class if > > the task it wants to reschedule is an rt task. > > Right, thats not a good thing, however this patch looks wrong, we should > never call hrtick_start_fair() on a rt task to begin with. Great! I don't care which way we fix this. This was making noticeable latencies against rt tasks. > > The way I can see that happening is through enqueue/dequeue_task_fair() > where we want to re-programm the hrtick because nr_running changes (and > thus the current tasks desired runtime). My original patch was more like this one, but I wasn't sure if I was skipping any calculations that were assumed to be made. Thus, I wrote the bare minimum and sent it out CC'ing the experts. Looks like my plan worked ;-) -- Steve > > Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: Steven Rostedt <srostedt@redhat.com> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-11 13:55 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-10-11 7:01 [PATCH] sched: fair scheduler should not resched rt tasks Steven Rostedt 2008-10-11 11:02 ` Peter Zijlstra 2008-10-11 13:55 ` Steven Rostedt
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.