Skip to content

Commit

Permalink
sched: cpufreq: HMP load reporting changes
Browse files Browse the repository at this point in the history
Since HMP uses WALT, ensure that load is reported just once per window,
with the exception of intercluster migrations. Further, try to report load
whenever WALT stats are updated.

Change-Id: I6539f8c916f6f271cf26f03249de7f953d5b12c2
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
  • Loading branch information
Vikram Mulukutla authored and rr-mario committed Jun 9, 2019
1 parent fe23c69 commit 976bc75
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -3714,6 +3714,7 @@ static inline unsigned long rlimit_max(unsigned int limit)
#define SCHED_CPUFREQ_RT (1U << 0)
#define SCHED_CPUFREQ_DL (1U << 1)
#define SCHED_CPUFREQ_IOWAIT (1U << 2)
#define SCHED_CPUFREQ_INTERCLUSTER_MIG (1U << 3)

#ifdef CONFIG_CPU_FREQ
struct update_util_data {
Expand Down
6 changes: 6 additions & 0 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags,
wallclock = sched_ktime_clock();
update_task_ravg(rq->curr, rq, TASK_UPDATE, wallclock, 0);
update_task_ravg(p, rq, TASK_WAKE, wallclock, 0);
cpufreq_update_util(rq, 0);
raw_spin_unlock(&rq->lock);

rcu_read_lock();
Expand Down Expand Up @@ -2225,6 +2226,7 @@ static void try_to_wake_up_local(struct task_struct *p)

update_task_ravg(rq->curr, rq, TASK_UPDATE, wallclock, 0);
update_task_ravg(p, rq, TASK_WAKE, wallclock, 0);
cpufreq_update_util(rq, 0);
ttwu_activate(rq, p, ENQUEUE_WAKEUP);
note_task_waking(p, wallclock);
}
Expand Down Expand Up @@ -3208,6 +3210,8 @@ void scheduler_tick(void)
calc_global_load_tick(rq);
wallclock = sched_ktime_clock();
update_task_ravg(rq->curr, rq, TASK_UPDATE, wallclock, 0);

cpufreq_update_util(rq, 0);
early_notif = early_detection_notify(rq, wallclock);
raw_spin_unlock(&rq->lock);

Expand Down Expand Up @@ -3576,6 +3580,7 @@ static void __sched notrace __schedule(bool preempt)
if (likely(prev != next)) {
update_task_ravg(prev, rq, PUT_PREV_TASK, wallclock, 0);
update_task_ravg(next, rq, PICK_NEXT_TASK, wallclock, 0);
cpufreq_update_util(rq, 0);
if (!is_idle_task(prev) && !prev->on_rq)
update_avg_burst(prev);

Expand All @@ -3594,6 +3599,7 @@ static void __sched notrace __schedule(bool preempt)
cpu = cpu_of(rq);
} else {
update_task_ravg(prev, rq, TASK_UPDATE, wallclock, 0);
cpufreq_update_util(rq, 0);
lockdep_unpin_lock(&rq->lock);
raw_spin_unlock_irq(&rq->lock);
}
Expand Down
5 changes: 5 additions & 0 deletions kernel/sched/hmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3652,6 +3652,11 @@ void fixup_busy_time(struct task_struct *p, int new_cpu)

migrate_top_tasks(p, src_rq, dest_rq);

if (!same_freq_domain(new_cpu, task_cpu(p))) {
cpufreq_update_util(dest_rq, SCHED_CPUFREQ_INTERCLUSTER_MIG);
cpufreq_update_util(src_rq, SCHED_CPUFREQ_INTERCLUSTER_MIG);
}

if (p == src_rq->ed_task) {
src_rq->ed_task = NULL;
if (!dest_rq->ed_task)
Expand Down
14 changes: 14 additions & 0 deletions kernel/sched/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ struct cpu_cycle {
#define for_each_sched_cluster(cluster) \
list_for_each_entry_rcu(cluster, &cluster_head, list)

extern unsigned int sched_disable_window_stats;
#endif /* CONFIG_SCHED_HMP */

/* CFS-related fields in a runqueue */
Expand Down Expand Up @@ -792,6 +793,7 @@ struct rq {

int cstate, wakeup_latency, wakeup_energy;
u64 window_start;
u64 load_reported_window;
unsigned long hmp_flags;

u64 cur_irqload;
Expand Down Expand Up @@ -2852,6 +2854,18 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags)
{
struct update_util_data *data;

#ifdef CONFIG_SCHED_HMP
/*
* Skip if we've already reported, but not if this is an inter-cluster
* migration
*/
if (!sched_disable_window_stats &&
(rq->load_reported_window == rq->window_start) &&
!(flags & SCHED_CPUFREQ_INTERCLUSTER_MIG))
return;
rq->load_reported_window = rq->window_start;
#endif

data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
if (data)
data->func(data, rq_clock(rq), flags);
Expand Down

0 comments on commit 976bc75

Please sign in to comment.