Skip to contentSkip to conversation

sched: stop hrtick timer if running task is switching from fair scheduling class to another

PATCH New Kirill Tkhai 1 participant 1 message Dec 17, 2011 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: stop hrtick timer if running task is switching from fair scheduling class to another

[PATCH]sched: stop hrtick timer if running task is switching from fair scheduling class to another

We have to stop hrtick timer to avoid excess interrupt. Not-fair tasks are not interested in fair's hrtick.

Kernel tree/version: next-20111216

---

kernel/sched/core.c +1 -5
index 211cdc5..7733ba7 100644
@@ -368,7 +368,7 @@ static struct rq *this_rq_lock(void)
  * rq->lock.
  */
 
-static void hrtick_clear(struct rq *rq)
+void hrtick_clear(struct rq *rq)
 {
 	if (hrtimer_active(&rq->hrtick_timer))
 		hrtimer_cancel(&rq->hrtick_timer);
@@ -480,10 +480,6 @@ static void init_rq_hrtick(struct rq *rq)
 	rq->hrtick_timer.function = hrtick;
 }
 #else	/* CONFIG_SCHED_HRTICK */
-static inline void hrtick_clear(struct rq *rq)
-{
-}
-
 static inline void init_rq_hrtick(struct rq *rq)
 {
 }
kernel/sched/fair.c +0 -0
index a4d2b7a..b083a91 100644
@@ -5271,6 +5271,13 @@ static void switched_from_fair(struct rq *rq,

struct task_struct *p)
place_entity(cfs_rq, se, 0); se->vruntime -= cfs_rq->min_vruntime;
}
+
+ /*
+ * Other scheduling classes are not interested in fair's hrtick timer.
+ */
+ if (task_current(rq, p) && sched_feat(HRTICK))
+ hrtick_clear(rq);
+
}

/*

kernel/sched/sched.h +6 -0
index d8d3613..f3c177c 100644
@@ -936,6 +936,8 @@ static inline int hrtick_enabled(struct rq *rq)
 	return hrtimer_is_hres_active(&rq->hrtick_timer);
 }
 
+void hrtick_clear(struct rq *rq);
+
 void hrtick_start(struct rq *rq, u64 delay);
 
 #else
@@ -945,6 +947,10 @@ static inline int hrtick_enabled(struct rq *rq)
 	return 0;
 }
 
+static inline void hrtick_clear(struct rq *rq)
+{
+}
+
 #endif /* CONFIG_SCHED_HRTICK */
 
 #ifdef CONFIG_SMP