Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\power\energy_model.c Create Date:2022-07-28 10:04:45
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:em_create_pd

Proto:static struct em_perf_domain *em_create_pd(cpumask_t *span, int nr_states, struct em_data_callback *cb)

Type:struct em_perf_domain

Parameter:

TypeParameterName
cpumask_t *span
intnr_states
struct em_data_callback *cb
84  prev_opp_eff = ULONG_MAX
85  prev_freq = 0
86  cpu = Uniprocessor. Assume all masks are "1".
91  If Not active_power Then Return NULL
94  pd = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
95  If Not pd Then Return NULL
98  table = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
99  If Not table Then Go to free_pd
103  When i < nr_states cycle
109  ret = active_power( & power, & freq, cpu)
110  If ret Then
111  pr_err("pd%d: invalid cap. state: %d\n", cpu, ret)
112  Go to free_cs_table
119  If freq <= prev_freq Then
120  pr_err("pd%d: non-increasing freq: %lu\n", cpu, freq)
121  Go to free_cs_table
128  If Not power || power > EM_CPU_MAX_POWER Then
129  pr_err("pd%d: invalid power: %lu\n", cpu, power)
130  Go to free_cs_table
133  power = power
134  frequency = prev_freq = freq
142  opp_eff = freq / power
143  If opp_eff >= prev_opp_eff Then pr_warn("pd%d: hertz/watts ratio non-monotonically decreasing: em_cap_state %d >= em_cap_state%d\n", cpu, i, i - 1)
146  prev_opp_eff = opp_eff
150  fmax = frequency
151  When i < nr_states cycle
152  cost = div64_u64 - unsigned 64bit divide with 64bit divisor*@dividend: 64bit dividend*@divisor: 64bit divisor* This implementation is a modified version of the algorithm proposed* by the book 'Hacker's Delight'. The original source and full proof
156  table = table
157  nr_cap_states = nr_states
158  pumask_copy - *dstp = *srcp*@dstp: the result*@srcp: the input cpumask
160  em_debug_create_pd(pd, cpu)
162  Return pd
164  free_cs_table :
165  kfree - free previously allocated memory*@objp: pointer returned by kmalloc.* If @objp is NULL, no operation is performed.* Don't free memory not originally allocated by kmalloc()* or you will run into trouble.
166  free_pd :
167  kfree - free previously allocated memory*@objp: pointer returned by kmalloc.* If @objp is NULL, no operation is performed.* Don't free memory not originally allocated by kmalloc()* or you will run into trouble.
169  Return NULL
Caller
NameDescribe
em_register_perf_domainm_register_perf_domain() - Register the Energy Model of a performance domain*@span : Mask of CPUs in the performance domain*@nr_states : Number of capacity states to register*@cb : Callback functions providing the data of the Energy Model* Create Energy