Skip to content

Commit f0b5694

Browse files
lukaszluba-armrafaeljw
authored andcommitted
PM / EM: change name of em_pd_energy to em_cpu_energy
Energy Model framework now supports other devices than CPUs. Refactor some of the functions in order to prevent wrong usage. The old function em_pd_energy has to generic name. It must not be used without proper cpumask pointer, which is possible only for CPU devices. Thus, rename it and add proper description to warn of potential wrong usage for other devices. Acked-by: Daniel Lezcano <[email protected]> Acked-by: Quentin Perret <[email protected]> Signed-off-by: Lukasz Luba <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 07891f1 commit f0b5694

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

include/linux/energy_model.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,20 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
8383
void em_dev_unregister_perf_domain(struct device *dev);
8484

8585
/**
86-
* em_pd_energy() - Estimates the energy consumed by the CPUs of a perf. domain
86+
* em_cpu_energy() - Estimates the energy consumed by the CPUs of a
87+
performance domain
8788
* @pd : performance domain for which energy has to be estimated
8889
* @max_util : highest utilization among CPUs of the domain
8990
* @sum_util : sum of the utilization of all CPUs in the domain
9091
*
92+
* This function must be used only for CPU devices. There is no validation,
93+
* i.e. if the EM is a CPU type and has cpumask allocated. It is called from
94+
* the scheduler code quite frequently and that is why there is not checks.
95+
*
9196
* Return: the sum of the energy consumed by the CPUs of the domain assuming
9297
* a capacity state satisfying the max utilization of the domain.
9398
*/
94-
static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
99+
static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
95100
unsigned long max_util, unsigned long sum_util)
96101
{
97102
unsigned long freq, scale_cpu;
@@ -196,7 +201,7 @@ static inline struct em_perf_domain *em_pd_get(struct device *dev)
196201
{
197202
return NULL;
198203
}
199-
static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
204+
static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
200205
unsigned long max_util, unsigned long sum_util)
201206
{
202207
return 0;

kernel/sched/fair.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6497,7 +6497,7 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
64976497
max_util = max(max_util, cpu_util);
64986498
}
64996499

6500-
return em_pd_energy(pd->em_pd, max_util, sum_util);
6500+
return em_cpu_energy(pd->em_pd, max_util, sum_util);
65016501
}
65026502

65036503
/*

0 commit comments

Comments
 (0)