Commit e0ee463c authored by Juri Lelli's avatar Juri Lelli Committed by Ingo Molnar

sched/features: Distinguish between NORMAL and DEADLINE hrtick

The HRTICK feature has traditionally been servicing configurations that
need precise preemptions point for NORMAL tasks. More recently, the
feature has been extended to also service DEADLINE tasks with stringent
runtime enforcement needs (e.g., runtime < 1ms with HZ=1000).

Enabling HRTICK sched feature currently enables the additional timer and
task tick for both classes, which might introduced undesired overhead
for no additional benefit if one needed it only for one of the cases.

Separate HRTICK sched feature in two (and leave the traditional case
name unmodified) so that it can be selectively enabled when needed.

With:

  $ echo HRTICK > /sys/kernel/debug/sched_features

the NORMAL/fair hrtick gets enabled.

With:

  $ echo HRTICK_DL > /sys/kernel/debug/sched_features

the DEADLINE hrtick gets enabled.
Signed-off-by: default avatarJuri Lelli <juri.lelli@redhat.com>
Signed-off-by: default avatarLuis Claudio R. Goncalves <lgoncalv@redhat.com>
Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20210208073554.14629-3-juri.lelli@redhat.com
parent 156ec6f4
...@@ -4969,7 +4969,7 @@ static void __sched notrace __schedule(bool preempt) ...@@ -4969,7 +4969,7 @@ static void __sched notrace __schedule(bool preempt)
schedule_debug(prev, preempt); schedule_debug(prev, preempt);
if (sched_feat(HRTICK)) if (sched_feat(HRTICK) || sched_feat(HRTICK_DL))
hrtick_clear(rq); hrtick_clear(rq);
local_irq_disable(); local_irq_disable();
......
...@@ -1832,7 +1832,7 @@ static void set_next_task_dl(struct rq *rq, struct task_struct *p, bool first) ...@@ -1832,7 +1832,7 @@ static void set_next_task_dl(struct rq *rq, struct task_struct *p, bool first)
if (!first) if (!first)
return; return;
if (hrtick_enabled(rq)) if (hrtick_enabled_dl(rq))
start_hrtick_dl(rq, p); start_hrtick_dl(rq, p);
if (rq->curr->sched_class != &dl_sched_class) if (rq->curr->sched_class != &dl_sched_class)
...@@ -1895,7 +1895,7 @@ static void task_tick_dl(struct rq *rq, struct task_struct *p, int queued) ...@@ -1895,7 +1895,7 @@ static void task_tick_dl(struct rq *rq, struct task_struct *p, int queued)
* not being the leftmost task anymore. In that case NEED_RESCHED will * not being the leftmost task anymore. In that case NEED_RESCHED will
* be set and schedule() will start a new hrtick for the next task. * be set and schedule() will start a new hrtick for the next task.
*/ */
if (hrtick_enabled(rq) && queued && p->dl.runtime > 0 && if (hrtick_enabled_dl(rq) && queued && p->dl.runtime > 0 &&
is_leftmost(p, &rq->dl)) is_leftmost(p, &rq->dl))
start_hrtick_dl(rq, p); start_hrtick_dl(rq, p);
} }
......
...@@ -5429,7 +5429,7 @@ static void hrtick_update(struct rq *rq) ...@@ -5429,7 +5429,7 @@ static void hrtick_update(struct rq *rq)
{ {
struct task_struct *curr = rq->curr; struct task_struct *curr = rq->curr;
if (!hrtick_enabled(rq) || curr->sched_class != &fair_sched_class) if (!hrtick_enabled_fair(rq) || curr->sched_class != &fair_sched_class)
return; return;
if (cfs_rq_of(&curr->se)->nr_running < sched_nr_latency) if (cfs_rq_of(&curr->se)->nr_running < sched_nr_latency)
...@@ -7116,7 +7116,7 @@ done: __maybe_unused; ...@@ -7116,7 +7116,7 @@ done: __maybe_unused;
list_move(&p->se.group_node, &rq->cfs_tasks); list_move(&p->se.group_node, &rq->cfs_tasks);
#endif #endif
if (hrtick_enabled(rq)) if (hrtick_enabled_fair(rq))
hrtick_start_fair(rq, p); hrtick_start_fair(rq, p);
update_misfit_status(p, rq); update_misfit_status(p, rq);
......
...@@ -38,6 +38,7 @@ SCHED_FEAT(CACHE_HOT_BUDDY, true) ...@@ -38,6 +38,7 @@ SCHED_FEAT(CACHE_HOT_BUDDY, true)
SCHED_FEAT(WAKEUP_PREEMPTION, true) SCHED_FEAT(WAKEUP_PREEMPTION, true)
SCHED_FEAT(HRTICK, false) SCHED_FEAT(HRTICK, false)
SCHED_FEAT(HRTICK_DL, false)
SCHED_FEAT(DOUBLE_TICK, false) SCHED_FEAT(DOUBLE_TICK, false)
/* /*
......
...@@ -2105,17 +2105,39 @@ extern const_debug unsigned int sysctl_sched_migration_cost; ...@@ -2105,17 +2105,39 @@ extern const_debug unsigned int sysctl_sched_migration_cost;
*/ */
static inline int hrtick_enabled(struct rq *rq) static inline int hrtick_enabled(struct rq *rq)
{ {
if (!sched_feat(HRTICK))
return 0;
if (!cpu_active(cpu_of(rq))) if (!cpu_active(cpu_of(rq)))
return 0; return 0;
return hrtimer_is_hres_active(&rq->hrtick_timer); return hrtimer_is_hres_active(&rq->hrtick_timer);
} }
static inline int hrtick_enabled_fair(struct rq *rq)
{
if (!sched_feat(HRTICK))
return 0;
return hrtick_enabled(rq);
}
static inline int hrtick_enabled_dl(struct rq *rq)
{
if (!sched_feat(HRTICK_DL))
return 0;
return hrtick_enabled(rq);
}
void hrtick_start(struct rq *rq, u64 delay); void hrtick_start(struct rq *rq, u64 delay);
#else #else
static inline int hrtick_enabled_fair(struct rq *rq)
{
return 0;
}
static inline int hrtick_enabled_dl(struct rq *rq)
{
return 0;
}
static inline int hrtick_enabled(struct rq *rq) static inline int hrtick_enabled(struct rq *rq)
{ {
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment