Skip to content

Commit d51e68b

Browse files
committed
Merge branch 'pm-em'
Merge fixes related to the energy model management for 6.19-rc6: - Fix a memory leak in em_create_pd() error path (Malaya Kumar Rout) - Fix stale description of the cost field in struct em_perf_state to reflect the current code (Yaxiong Tian) - Fix and revamp the energy model YNL specification added recently along with the energy model netlink interface (Changwoo Min) * pm-em: PM: EM: Add dump to get-perf-domains in the EM YNL spec PM: EM: Change cpus' type from string to u64 array in the EM YNL spec PM: EM: Rename em.yaml to dev-energymodel.yaml PM: EM: Fix yamllint warnings in the EM YNL spec PM: EM: Fix memory leak in em_create_pd() error path PM: EM: Fix incorrect description of the cost field in struct em_perf_state
2 parents 0f61b18 + 380ff27 commit d51e68b

10 files changed

Lines changed: 454 additions & 288 deletions

File tree

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2+
#
3+
# Copyright (c) 2025 Valve Corporation.
4+
#
5+
---
6+
name: dev-energymodel
7+
8+
doc: |
9+
Energy model netlink interface to notify its changes.
10+
11+
protocol: genetlink
12+
13+
uapi-header: linux/dev_energymodel.h
14+
15+
definitions:
16+
-
17+
type: flags
18+
name: perf-state-flags
19+
entries:
20+
-
21+
name: perf-state-inefficient
22+
doc: >-
23+
The performance state is inefficient. There is in this perf-domain,
24+
another performance state with a higher frequency but a lower or
25+
equal power cost.
26+
-
27+
type: flags
28+
name: perf-domain-flags
29+
entries:
30+
-
31+
name: perf-domain-microwatts
32+
doc: >-
33+
The power values are in micro-Watts or some other scale.
34+
-
35+
name: perf-domain-skip-inefficiencies
36+
doc: >-
37+
Skip inefficient states when estimating energy consumption.
38+
-
39+
name: perf-domain-artificial
40+
doc: >-
41+
The power values are artificial and might be created by platform
42+
missing real power information.
43+
44+
attribute-sets:
45+
-
46+
name: perf-domain
47+
doc: >-
48+
Information on a single performance domains.
49+
attributes:
50+
-
51+
name: pad
52+
type: pad
53+
-
54+
name: perf-domain-id
55+
type: u32
56+
doc: >-
57+
A unique ID number for each performance domain.
58+
-
59+
name: flags
60+
type: u64
61+
doc: >-
62+
Bitmask of performance domain flags.
63+
enum: perf-domain-flags
64+
-
65+
name: cpus
66+
type: u64
67+
multi-attr: true
68+
doc: >-
69+
CPUs that belong to this performance domain.
70+
-
71+
name: perf-table
72+
doc: >-
73+
Performance states table.
74+
attributes:
75+
-
76+
name: perf-domain-id
77+
type: u32
78+
doc: >-
79+
A unique ID number for each performance domain.
80+
-
81+
name: perf-state
82+
type: nest
83+
nested-attributes: perf-state
84+
multi-attr: true
85+
-
86+
name: perf-state
87+
doc: >-
88+
Performance state of a performance domain.
89+
attributes:
90+
-
91+
name: pad
92+
type: pad
93+
-
94+
name: performance
95+
type: u64
96+
doc: >-
97+
CPU performance (capacity) at a given frequency.
98+
-
99+
name: frequency
100+
type: u64
101+
doc: >-
102+
The frequency in KHz, for consistency with CPUFreq.
103+
-
104+
name: power
105+
type: u64
106+
doc: >-
107+
The power consumed at this level (by 1 CPU or by a registered
108+
device). It can be a total power: static and dynamic.
109+
-
110+
name: cost
111+
type: u64
112+
doc: >-
113+
The cost coefficient associated with this level, used during energy
114+
calculation. Equal to: power * max_frequency / frequency.
115+
-
116+
name: flags
117+
type: u64
118+
doc: >-
119+
Bitmask of performance state flags.
120+
enum: perf-state-flags
121+
122+
operations:
123+
list:
124+
-
125+
name: get-perf-domains
126+
attribute-set: perf-domain
127+
doc: Get the list of information for all performance domains.
128+
do:
129+
request:
130+
attributes:
131+
- perf-domain-id
132+
reply:
133+
attributes: &perf-domain-attrs
134+
- pad
135+
- perf-domain-id
136+
- flags
137+
- cpus
138+
dump:
139+
reply:
140+
attributes: *perf-domain-attrs
141+
-
142+
name: get-perf-table
143+
attribute-set: perf-table
144+
doc: Get the energy model table of a performance domain.
145+
do:
146+
request:
147+
attributes:
148+
- perf-domain-id
149+
reply:
150+
attributes:
151+
- perf-domain-id
152+
- perf-state
153+
-
154+
name: perf-domain-created
155+
doc: A performance domain is created.
156+
notify: get-perf-table
157+
mcgrp: event
158+
-
159+
name: perf-domain-updated
160+
doc: A performance domain is updated.
161+
notify: get-perf-table
162+
mcgrp: event
163+
-
164+
name: perf-domain-deleted
165+
doc: A performance domain is deleted.
166+
attribute-set: perf-table
167+
event:
168+
attributes:
169+
- perf-domain-id
170+
mcgrp: event
171+
172+
mcast-groups:
173+
list:
174+
-
175+
name: event

Documentation/netlink/specs/em.yaml

Lines changed: 0 additions & 113 deletions
This file was deleted.

MAINTAINERS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9303,12 +9303,12 @@ M: Lukasz Luba <lukasz.luba@arm.com>
93039303
M: "Rafael J. Wysocki" <rafael@kernel.org>
93049304
L: linux-pm@vger.kernel.org
93059305
S: Maintained
9306-
F: kernel/power/energy_model.c
9307-
F: include/linux/energy_model.h
9306+
F: Documentation/netlink/specs/dev-energymodel.yaml
93089307
F: Documentation/power/energy-model.rst
9309-
F: Documentation/netlink/specs/em.yaml
9310-
F: include/uapi/linux/energy_model.h
9308+
F: include/linux/energy_model.h
9309+
F: include/uapi/linux/dev_energymodel.h
93119310
F: kernel/power/em_netlink*.*
9311+
F: kernel/power/energy_model.c
93129312

93139313
EPAPR HYPERVISOR BYTE CHANNEL DEVICE DRIVER
93149314
M: Laurentiu Tudor <laurentiu.tudor@nxp.com>

include/linux/energy_model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* @power: The power consumed at this level (by 1 CPU or by a registered
1919
* device). It can be a total power: static and dynamic.
2020
* @cost: The cost coefficient associated with this level, used during
21-
* energy calculation. Equal to: power * max_frequency / frequency
21+
* energy calculation. Equal to: 10 * power * max_frequency / frequency
2222
* @flags: see "em_perf_state flags" description below.
2323
*/
2424
struct em_perf_state {
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2+
/* Do not edit directly, auto-generated from: */
3+
/* Documentation/netlink/specs/dev-energymodel.yaml */
4+
/* YNL-GEN uapi header */
5+
/* To regenerate run: tools/net/ynl/ynl-regen.sh */
6+
7+
#ifndef _UAPI_LINUX_DEV_ENERGYMODEL_H
8+
#define _UAPI_LINUX_DEV_ENERGYMODEL_H
9+
10+
#define DEV_ENERGYMODEL_FAMILY_NAME "dev-energymodel"
11+
#define DEV_ENERGYMODEL_FAMILY_VERSION 1
12+
13+
/**
14+
* enum dev_energymodel_perf_state_flags
15+
* @DEV_ENERGYMODEL_PERF_STATE_FLAGS_PERF_STATE_INEFFICIENT: The performance
16+
* state is inefficient. There is in this perf-domain, another performance
17+
* state with a higher frequency but a lower or equal power cost.
18+
*/
19+
enum dev_energymodel_perf_state_flags {
20+
DEV_ENERGYMODEL_PERF_STATE_FLAGS_PERF_STATE_INEFFICIENT = 1,
21+
};
22+
23+
/**
24+
* enum dev_energymodel_perf_domain_flags
25+
* @DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_MICROWATTS: The power values
26+
* are in micro-Watts or some other scale.
27+
* @DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_SKIP_INEFFICIENCIES: Skip
28+
* inefficient states when estimating energy consumption.
29+
* @DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_ARTIFICIAL: The power values
30+
* are artificial and might be created by platform missing real power
31+
* information.
32+
*/
33+
enum dev_energymodel_perf_domain_flags {
34+
DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_MICROWATTS = 1,
35+
DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_SKIP_INEFFICIENCIES = 2,
36+
DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_ARTIFICIAL = 4,
37+
};
38+
39+
enum {
40+
DEV_ENERGYMODEL_A_PERF_DOMAIN_PAD = 1,
41+
DEV_ENERGYMODEL_A_PERF_DOMAIN_PERF_DOMAIN_ID,
42+
DEV_ENERGYMODEL_A_PERF_DOMAIN_FLAGS,
43+
DEV_ENERGYMODEL_A_PERF_DOMAIN_CPUS,
44+
45+
__DEV_ENERGYMODEL_A_PERF_DOMAIN_MAX,
46+
DEV_ENERGYMODEL_A_PERF_DOMAIN_MAX = (__DEV_ENERGYMODEL_A_PERF_DOMAIN_MAX - 1)
47+
};
48+
49+
enum {
50+
DEV_ENERGYMODEL_A_PERF_TABLE_PERF_DOMAIN_ID = 1,
51+
DEV_ENERGYMODEL_A_PERF_TABLE_PERF_STATE,
52+
53+
__DEV_ENERGYMODEL_A_PERF_TABLE_MAX,
54+
DEV_ENERGYMODEL_A_PERF_TABLE_MAX = (__DEV_ENERGYMODEL_A_PERF_TABLE_MAX - 1)
55+
};
56+
57+
enum {
58+
DEV_ENERGYMODEL_A_PERF_STATE_PAD = 1,
59+
DEV_ENERGYMODEL_A_PERF_STATE_PERFORMANCE,
60+
DEV_ENERGYMODEL_A_PERF_STATE_FREQUENCY,
61+
DEV_ENERGYMODEL_A_PERF_STATE_POWER,
62+
DEV_ENERGYMODEL_A_PERF_STATE_COST,
63+
DEV_ENERGYMODEL_A_PERF_STATE_FLAGS,
64+
65+
__DEV_ENERGYMODEL_A_PERF_STATE_MAX,
66+
DEV_ENERGYMODEL_A_PERF_STATE_MAX = (__DEV_ENERGYMODEL_A_PERF_STATE_MAX - 1)
67+
};
68+
69+
enum {
70+
DEV_ENERGYMODEL_CMD_GET_PERF_DOMAINS = 1,
71+
DEV_ENERGYMODEL_CMD_GET_PERF_TABLE,
72+
DEV_ENERGYMODEL_CMD_PERF_DOMAIN_CREATED,
73+
DEV_ENERGYMODEL_CMD_PERF_DOMAIN_UPDATED,
74+
DEV_ENERGYMODEL_CMD_PERF_DOMAIN_DELETED,
75+
76+
__DEV_ENERGYMODEL_CMD_MAX,
77+
DEV_ENERGYMODEL_CMD_MAX = (__DEV_ENERGYMODEL_CMD_MAX - 1)
78+
};
79+
80+
#define DEV_ENERGYMODEL_MCGRP_EVENT "event"
81+
82+
#endif /* _UAPI_LINUX_DEV_ENERGYMODEL_H */

0 commit comments

Comments
 (0)