Commit d4dbc991 authored by Vincent Guittot's avatar Vincent Guittot Committed by Ingo Molnar
Browse files

sched/cpufreq: Rename arch_update_thermal_pressure() => arch_update_hw_pressure()



Now that cpufreq provides a pressure value to the scheduler, rename
arch_update_thermal_pressure into HW pressure to reflect that it returns
a pressure applied by HW (i.e. with a high frequency change) and not
always related to thermal mitigation but also generated by max current
limitation as an example. Such high frequency signal needs filtering to be
smoothed and provide an value that reflects the average available capacity
into the scheduler time scale.

Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Tested-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Reviewed-by: default avatarQais Yousef <qyousef@layalina.io>
Reviewed-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Link: https://lore.kernel.org/r/20240326091616.3696851-5-vincent.guittot@linaro.org
parent c281afe2
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -22,9 +22,9 @@
/* Enable topology flag updates */
#define arch_update_cpu_topology topology_update_cpu_topology

/* Replace task scheduler's default thermal pressure API */
#define arch_scale_thermal_pressure topology_get_thermal_pressure
#define arch_update_thermal_pressure	topology_update_thermal_pressure
/* Replace task scheduler's default HW pressure API */
#define arch_scale_hw_pressure topology_get_hw_pressure
#define arch_update_hw_pressure	topology_update_hw_pressure

#else

+3 −3
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ void update_freq_counters_refs(void);
/* Enable topology flag updates */
#define arch_update_cpu_topology topology_update_cpu_topology

/* Replace task scheduler's default thermal pressure API */
#define arch_scale_thermal_pressure topology_get_thermal_pressure
#define arch_update_thermal_pressure	topology_update_thermal_pressure
/* Replace task scheduler's default HW pressure API */
#define arch_scale_hw_pressure topology_get_hw_pressure
#define arch_update_hw_pressure	topology_update_hw_pressure

#include <asm-generic/topology.h>

+13 −13
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include <linux/units.h>

#define CREATE_TRACE_POINTS
#include <trace/events/thermal_pressure.h>
#include <trace/events/hw_pressure.h>

static DEFINE_PER_CPU(struct scale_freq_data __rcu *, sft_data);
static struct cpumask scale_freq_counters_mask;
@@ -160,26 +160,26 @@ void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity)
	per_cpu(cpu_scale, cpu) = capacity;
}

DEFINE_PER_CPU(unsigned long, thermal_pressure);
DEFINE_PER_CPU(unsigned long, hw_pressure);

/**
 * topology_update_thermal_pressure() - Update thermal pressure for CPUs
 * topology_update_hw_pressure() - Update HW pressure for CPUs
 * @cpus        : The related CPUs for which capacity has been reduced
 * @capped_freq : The maximum allowed frequency that CPUs can run at
 *
 * Update the value of thermal pressure for all @cpus in the mask. The
 * Update the value of HW pressure for all @cpus in the mask. The
 * cpumask should include all (online+offline) affected CPUs, to avoid
 * operating on stale data when hot-plug is used for some CPUs. The
 * @capped_freq reflects the currently allowed max CPUs frequency due to
 * thermal capping. It might be also a boost frequency value, which is bigger
 * HW capping. It might be also a boost frequency value, which is bigger
 * than the internal 'capacity_freq_ref' max frequency. In such case the
 * pressure value should simply be removed, since this is an indication that
 * there is no thermal throttling. The @capped_freq must be provided in kHz.
 * there is no HW throttling. The @capped_freq must be provided in kHz.
 */
void topology_update_thermal_pressure(const struct cpumask *cpus,
void topology_update_hw_pressure(const struct cpumask *cpus,
				      unsigned long capped_freq)
{
	unsigned long max_capacity, capacity, th_pressure;
	unsigned long max_capacity, capacity, hw_pressure;
	u32 max_freq;
	int cpu;

@@ -189,21 +189,21 @@ void topology_update_thermal_pressure(const struct cpumask *cpus,

	/*
	 * Handle properly the boost frequencies, which should simply clean
	 * the thermal pressure value.
	 * the HW pressure value.
	 */
	if (max_freq <= capped_freq)
		capacity = max_capacity;
	else
		capacity = mult_frac(max_capacity, capped_freq, max_freq);

	th_pressure = max_capacity - capacity;
	hw_pressure = max_capacity - capacity;

	trace_thermal_pressure_update(cpu, th_pressure);
	trace_hw_pressure_update(cpu, hw_pressure);

	for_each_cpu(cpu, cpus)
		WRITE_ONCE(per_cpu(thermal_pressure, cpu), th_pressure);
		WRITE_ONCE(per_cpu(hw_pressure, cpu), hw_pressure);
}
EXPORT_SYMBOL_GPL(topology_update_thermal_pressure);
EXPORT_SYMBOL_GPL(topology_update_hw_pressure);

static ssize_t cpu_capacity_show(struct device *dev,
				 struct device_attribute *attr,
+2 −2
Original line number Diff line number Diff line
@@ -347,8 +347,8 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)

	throttled_freq = freq_hz / HZ_PER_KHZ;

	/* Update thermal pressure (the boost frequencies are accepted) */
	arch_update_thermal_pressure(policy->related_cpus, throttled_freq);
	/* Update HW pressure (the boost frequencies are accepted) */
	arch_update_hw_pressure(policy->related_cpus, throttled_freq);

	/*
	 * In the unlikely case policy is unregistered do not enable
+4 −4
Original line number Diff line number Diff line
@@ -60,14 +60,14 @@ void topology_scale_freq_tick(void);
void topology_set_scale_freq_source(struct scale_freq_data *data, const struct cpumask *cpus);
void topology_clear_scale_freq_source(enum scale_freq_source source, const struct cpumask *cpus);

DECLARE_PER_CPU(unsigned long, thermal_pressure);
DECLARE_PER_CPU(unsigned long, hw_pressure);

static inline unsigned long topology_get_thermal_pressure(int cpu)
static inline unsigned long topology_get_hw_pressure(int cpu)
{
	return per_cpu(thermal_pressure, cpu);
	return per_cpu(hw_pressure, cpu);
}

void topology_update_thermal_pressure(const struct cpumask *cpus,
void topology_update_hw_pressure(const struct cpumask *cpus,
				      unsigned long capped_freq);

struct cpu_topology {
Loading