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

Commit 2c320f2f authored by Olav Haugan's avatar Olav Haugan
Browse files

sched: Add temperature to cpu_load trace point



Add the current CPU temperature to the sched_cpu_load trace point.
This will allow us to track the CPU temperature.

CRs-Fixed: 764788
Change-Id: Ib2e3559bbbe3fe07a6b7c8115db606828bc36254
Signed-off-by: default avatarOlav Haugan <ohaugan@codeaurora.org>
parent 0c0d18bb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
+6 −4
Original line number Diff line number Diff line
@@ -159,9 +159,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			)
@@ -178,6 +178,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(
@@ -195,15 +196,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,
+22 −3
Original line number Diff line number Diff line
@@ -1775,7 +1775,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) {
@@ -1930,7 +1931,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;
@@ -2416,6 +2418,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
@@ -2477,6 +2489,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
@@ -5977,7 +5995,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));
		nr_running = rq->nr_running;

		/* Bias balancing toward cpus of our domain */
+1 −1
Original line number Diff line number Diff line
@@ -1555,7 +1555,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;
+1 −0
Original line number Diff line number Diff line
@@ -734,6 +734,7 @@ u64 scale_load_to_cpu(u64 load, 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)
{