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

Commit bc4cef7b authored by Pavankumar Kondeti's avatar Pavankumar Kondeti
Browse files

sched: walt: fix cumulative window demand update bugs



When a task is exiting, its demand is reset before subtracting
from the cumulative window demand. Fix this by swapping these
two operations.

If the window is rolled over during a task dequeue, the task's
demand is added separately to the cumulative window demand. If
the task is still on the runqueue, this is not necessary as
the task's demand is included in cumulative runnable average.

Type cast rq->cum_window_demand from u64 to s64 when checking
for a negative value. Currently we are printing a warning when
this metric becomes zero. As this is a harmless condition, handle
it by resetting it to 0.

Change-Id: I9317b1959ee3ba068a2b94a9fd5d713da598fabc
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent d3370500
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9577,8 +9577,8 @@ void sched_exit(struct task_struct *p)
	wallclock = sched_ktime_clock();
	update_task_ravg(rq->curr, rq, TASK_UPDATE, wallclock, 0);
	dequeue_task(rq, p, 0);
	reset_task_stats(p);
	dec_cum_window_demand(rq, p);
	reset_task_stats(p);
	p->ravg.mark_start = wallclock;
	p->ravg.sum_history[0] = EXITING_TASK_MARKER;
	free_task_load_ptrs(p);
+2 −1
Original line number Diff line number Diff line
@@ -2635,7 +2635,8 @@ static inline void
dec_cum_window_demand(struct rq *rq, struct task_struct *p)
{
	rq->cum_window_demand -= p->ravg.demand;
	WARN_ON_ONCE(rq->cum_window_demand < 0);
	if (unlikely((s64)rq->cum_window_demand < 0))
		rq->cum_window_demand = 0;
}

static inline void
+6 −1
Original line number Diff line number Diff line
@@ -295,7 +295,12 @@ update_window_start(struct rq *rq, u64 wallclock, int event)
	rq->window_start += (u64)nr_windows * (u64)sched_ravg_window;

	rq->cum_window_demand = rq->walt_stats.cumulative_runnable_avg;
	if (event == PUT_PREV_TASK)
	/*
	 * If the window is rolled over when the task is dequeued, this
	 * task demand is not included in cumulative_runnable_avg. So
	 * add it separately to the cumulative window demand.
	 */
	if (!rq->curr->on_rq && event == PUT_PREV_TASK)
		rq->cum_window_demand += rq->curr->ravg.demand;

	return old_window_start;