summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/scheduler/sched-hmp.txt3
-rw-r--r--include/trace/events/sched.h10
-rw-r--r--kernel/sched/fair.c25
-rw-r--r--kernel/sched/rt.c2
-rw-r--r--kernel/sched/sched.h1
5 files changed, 32 insertions, 9 deletions
diff --git a/Documentation/scheduler/sched-hmp.txt b/Documentation/scheduler/sched-hmp.txt
index 947eae43e94b..aeecb0c15657 100644
--- a/Documentation/scheduler/sched-hmp.txt
+++ b/Documentation/scheduler/sched-hmp.txt
@@ -1321,7 +1321,7 @@ Logged when selecting the best CPU to run a task (select_best_cpu() for fair
class tasks, find_lowest_rq_hmp() for RT tasks) and load balancing
(update_sg_lb_stats()).
-<idle>-0 [004] d.h3 12700.711541: sched_cpu_load: cpu 0 idle 1 mostly_idle 1 nr_run 0 nr_big 0 nr_small 0 lsf 1945 capacity 1045 cr_avg 0 irqload 4456 fcur 199200 fmax 940800 power_cost 1045 cstate 1
+<idle>-0 [004] d.h3 12700.711541: sched_cpu_load: cpu 0 idle 1 mostly_idle 1 nr_run 0 nr_big 0 nr_small 0 lsf 1945 capacity 1045 cr_avg 0 irqload 4456 fcur 199200 fmax 940800 power_cost 1045 cstate 1 temp 73
- cpu: the CPU being described
- idle: boolean indicating whether the CPU is idle
@@ -1339,6 +1339,7 @@ class tasks, find_lowest_rq_hmp() for RT tasks) and load balancing
- fmax: max CPU frequency (but not maximum _possible_ frequency) (KHz)
- power_cost: cost of running this CPU at the current frequency
- cstate: current cstate of CPU
+- temp: current temperature of the CPU
The power_cost value above differs in how it is calculated depending on the
callsite of this tracepoint. The select_best_cpu() call to this tracepoint
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 7294f44da319..6f4a8f0d45e3 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -158,9 +158,9 @@ TRACE_EVENT(sched_task_load,
TRACE_EVENT(sched_cpu_load,
TP_PROTO(struct rq *rq, int idle, int mostly_idle, u64 irqload,
- unsigned int power_cost),
+ unsigned int power_cost, int temp),
- TP_ARGS(rq, idle, mostly_idle, irqload, power_cost),
+ TP_ARGS(rq, idle, mostly_idle, irqload, power_cost, temp),
TP_STRUCT__entry(
__field(unsigned int, cpu )
@@ -177,6 +177,7 @@ TRACE_EVENT(sched_cpu_load,
__field(unsigned int, max_freq )
__field(unsigned int, power_cost )
__field( int, cstate )
+ __field( int, temp )
),
TP_fast_assign(
@@ -194,15 +195,16 @@ TRACE_EVENT(sched_cpu_load,
__entry->max_freq = rq->max_freq;
__entry->power_cost = power_cost;
__entry->cstate = rq->cstate;
+ __entry->temp = temp;
),
- TP_printk("cpu %u idle %d mostly_idle %d nr_run %u nr_big %u nr_small %u lsf %u capacity %u cr_avg %llu irqload %llu fcur %u fmax %u power_cost %u cstate %d",
+ TP_printk("cpu %u idle %d mostly_idle %d nr_run %u nr_big %u nr_small %u lsf %u capacity %u cr_avg %llu irqload %llu fcur %u fmax %u power_cost %u cstate %d temp %d",
__entry->cpu, __entry->idle, __entry->mostly_idle, __entry->nr_running,
__entry->nr_big_tasks, __entry->nr_small_tasks,
__entry->load_scale_factor, __entry->capacity,
__entry->cumulative_runnable_avg, __entry->irqload,
__entry->cur_freq, __entry->max_freq,
- __entry->power_cost, __entry->cstate)
+ __entry->power_cost, __entry->cstate, __entry->temp)
);
TRACE_EVENT(sched_set_boost,
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 262c8528e775..3204ca2a9619 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3089,7 +3089,8 @@ static int best_small_task_cpu(struct task_struct *p, int sync)
trace_sched_cpu_load(cpu_rq(i), idle_cpu(i),
mostly_idle_cpu_sync(i, sync),
- sched_irqload(i), power_cost(p, i));
+ sched_irqload(i), power_cost(p, i),
+ cpu_temp(i));
cpu_cost = power_cost(p, i);
if (cpu_cost < min_cost) {
@@ -3244,7 +3245,8 @@ static int select_best_cpu(struct task_struct *p, int target, int reason,
trace_sched_cpu_load(cpu_rq(i), idle_cpu(i),
mostly_idle_cpu_sync(i, sync),
- sched_irqload(i), power_cost(p, i));
+ sched_irqload(i), power_cost(p, i),
+ cpu_temp(i));
if (skip_cpu(p, i, reason))
continue;
@@ -3731,6 +3733,16 @@ static inline int is_cpu_throttling_imminent(int cpu)
return throttling;
}
+unsigned int cpu_temp(int cpu)
+{
+ struct cpu_pwr_stats *per_cpu_info = get_cpu_pwr_stats();
+ if (per_cpu_info)
+ return per_cpu_info[cpu].temp;
+ else
+ return 0;
+}
+
+
#else /* CONFIG_SCHED_HMP */
#define sched_enable_power_aware 0
@@ -3792,6 +3804,12 @@ static inline int is_cpu_throttling_imminent(int cpu)
return 0;
}
+unsigned int cpu_temp(int cpu)
+{
+ return 0;
+}
+
+
#endif /* CONFIG_SCHED_HMP */
#ifdef CONFIG_SCHED_HMP
@@ -7797,7 +7815,8 @@ static inline void update_sg_lb_stats(struct lb_env *env,
trace_sched_cpu_load(cpu_rq(i), idle_cpu(i),
mostly_idle_cpu(i),
sched_irqload(i),
- power_cost_at_freq(i, 0));
+ power_cost_at_freq(i, 0),
+ cpu_temp(i));
/* Bias balancing toward cpus of our domain */
if (local_group)
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 3d4da64c91f6..f20b6711a1bb 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1658,7 +1658,7 @@ static int find_lowest_rq_hmp(struct task_struct *task)
struct rq *rq = cpu_rq(i);
cpu_cost = power_cost_at_freq(i, ACCESS_ONCE(rq->min_freq));
trace_sched_cpu_load(rq, idle_cpu(i), mostly_idle_cpu(i),
- sched_irqload(i), cpu_cost);
+ sched_irqload(i), cpu_cost, cpu_temp(i));
if (sched_boost() && capacity(rq) != max_capacity)
continue;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index a53383d6bf6c..2307b7cea12c 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -998,6 +998,7 @@ extern void fixup_nr_big_small_task(int cpu);
unsigned int max_task_load(void);
extern void sched_account_irqtime(int cpu, struct task_struct *curr,
u64 delta, u64 wallclock);
+unsigned int cpu_temp(int cpu);
static inline int capacity(struct rq *rq)
{