Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7560dad2 authored by Syed Rameez Mustafa's avatar Syed Rameez Mustafa
Browse files

sched/deadline: Add basic HMP extensions



Some HMP extensions have to be supported by all scheduling classes
irrespective of them using HMP task placement or not. Add these
basic extensions to make deadline scheduling work.

Also during the tick, if a deadline task gets throttled, its HMP
stats get decremented as part of the dequeue. However, the throttled
task does not update its on_rq flag causing HMP stats to be double
decremented when update_history() is called as part of a window rollover.
Avoid this by checking for throttled deadline tasks before subtracting
and adding the deadline tasks load from the rq cumulative runnable avg.

Change-Id: I9e2ed6675a730f2ec830f764f911e71c00a7d87a
Signed-off-by: default avatarSyed Rameez Mustafa <rameezmustafa@codeaurora.org>
parent 455c5e88
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1687,7 +1687,13 @@ static void update_history(struct rq *rq, struct task_struct *p,
	}

	p->ravg.sum = 0;
	if (p->on_rq)

	/*
	 * A throttled deadline sched class task gets dequeued without
	 * changing p->on_rq. Since the dequeue decrements hmp stats
	 * avoid decrementing it here again.
	 */
	if (p->on_rq && (!task_has_dl_policy(p) || !p->dl.dl_throttled))
		p->sched_class->dec_hmp_sched_stats(rq, p);

	avg = div64_u64(sum, sched_ravg_hist_size);
@@ -1703,7 +1709,7 @@ static void update_history(struct rq *rq, struct task_struct *p,

	p->ravg.demand = demand;

	if (p->on_rq)
	if (p->on_rq && (!task_has_dl_policy(p) || !p->dl.dl_throttled))
		p->sched_class->inc_hmp_sched_stats(rq, p);

done:
+30 −0
Original line number Diff line number Diff line
@@ -742,6 +742,30 @@ static inline void dec_dl_deadline(struct dl_rq *dl_rq, u64 deadline) {}

#endif /* CONFIG_SMP */

#ifdef CONFIG_SCHED_HMP

static void
inc_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p)
{
	inc_cumulative_runnable_avg(&rq->hmp_stats, p);
}

static void
dec_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p)
{
	dec_cumulative_runnable_avg(&rq->hmp_stats, p);
}

#else	/* CONFIG_SCHED_HMP */

static inline void
inc_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p) { }

static inline void
dec_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p) { }

#endif	/* CONFIG_SCHED_HMP */

static inline
void inc_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
{
@@ -751,6 +775,7 @@ void inc_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
	WARN_ON(!dl_prio(prio));
	dl_rq->dl_nr_running++;
	add_nr_running(rq_of_dl_rq(dl_rq), 1);
	inc_hmp_sched_stats_dl(rq_of_dl_rq(dl_rq), dl_task_of(dl_se));

	inc_dl_deadline(dl_rq, deadline);
	inc_dl_migration(dl_se, dl_rq);
@@ -765,6 +790,7 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
	WARN_ON(!dl_rq->dl_nr_running);
	dl_rq->dl_nr_running--;
	sub_nr_running(rq_of_dl_rq(dl_rq), 1);
	dec_hmp_sched_stats_dl(rq_of_dl_rq(dl_rq), dl_task_of(dl_se));

	dec_dl_deadline(dl_rq, dl_se->deadline);
	dec_dl_migration(dl_se, dl_rq);
@@ -1703,4 +1729,8 @@ const struct sched_class dl_sched_class = {
	.switched_to		= switched_to_dl,

	.update_curr		= update_curr_dl,
#ifdef CONFIG_SCHED_HMP
	.inc_hmp_sched_stats	= inc_hmp_sched_stats_dl,
	.dec_hmp_sched_stats	= dec_hmp_sched_stats_dl,
#endif
};