Commit b62ce254 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull power management fixes from Rafael Wysocki:
 "These fix an error path memory leak in the energy model management
  code, fix a kerneldoc comment in it, and fix and revamp the energy
  model YNL specification added recently along with the new energy model
  management netlink interface (that received feedback after being
  added):

   - 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)"

* tag 'pm-6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  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
parents e547d4f7 d51e68b7
Loading
Loading
Loading
Loading
+175 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)

name: em
#
# Copyright (c) 2025 Valve Corporation.
#
---
name: dev-energymodel

doc: |
  Energy model netlink interface to notify its changes.

protocol: genetlink

uapi-header: linux/energy_model.h
uapi-header: linux/dev_energymodel.h

definitions:
  -
    type: flags
    name: perf-state-flags
    entries:
      -
        name: perf-state-inefficient
        doc: >-
          The performance state is inefficient. There is in this perf-domain,
          another performance state with a higher frequency but a lower or
          equal power cost.
  -
    type: flags
    name: perf-domain-flags
    entries:
      -
        name: perf-domain-microwatts
        doc: >-
          The power values are in micro-Watts or some other scale.
      -
        name: perf-domain-skip-inefficiencies
        doc: >-
          Skip inefficient states when estimating energy consumption.
      -
        name: perf-domain-artificial
        doc: >-
          The power values are artificial and might be created by platform
          missing real power information.

attribute-sets:
  -
    name: pds
    attributes:
      -
        name: pd
        type: nest
        nested-attributes: pd
        multi-attr: true
  -
    name: pd
    name: perf-domain
    doc: >-
      Information on a single performance domains.
    attributes:
      -
        name: pad
        type: pad
      -
        name: pd-id
        name: perf-domain-id
        type: u32
        doc: >-
          A unique ID number for each performance domain.
      -
        name: flags
        type: u64
        doc: >-
          Bitmask of performance domain flags.
        enum: perf-domain-flags
      -
        name: cpus
        type: string
        type: u64
        multi-attr: true
        doc: >-
          CPUs that belong to this performance domain.
  -
    name: pd-table
    name: perf-table
    doc: >-
      Performance states table.
    attributes:
      -
        name: pd-id
        name: perf-domain-id
        type: u32
        doc: >-
          A unique ID number for each performance domain.
      -
        name: ps
        name: perf-state
        type: nest
        nested-attributes: ps
        nested-attributes: perf-state
        multi-attr: true
  -
    name: ps
    name: perf-state
    doc: >-
      Performance state of a performance domain.
    attributes:
      -
        name: pad
@@ -53,58 +93,80 @@ attribute-sets:
      -
        name: performance
        type: u64
        doc: >-
          CPU performance (capacity) at a given frequency.
      -
        name: frequency
        type: u64
        doc: >-
          The frequency in KHz, for consistency with CPUFreq.
      -
        name: power
        type: u64
        doc: >-
          The power consumed at this level (by 1 CPU or by a registered
          device). It can be a total power: static and dynamic.
      -
        name: cost
        type: u64
        doc: >-
          The cost coefficient associated with this level, used during energy
          calculation. Equal to: power * max_frequency / frequency.
      -
        name: flags
        type: u64
        doc: >-
          Bitmask of performance state flags.
        enum: perf-state-flags

operations:
  list:
    -
      name: get-pds
      attribute-set: pds
      name: get-perf-domains
      attribute-set: perf-domain
      doc: Get the list of information for all performance domains.
      do:
        reply:
        request:
          attributes:
            - pd
            - perf-domain-id
        reply:
          attributes: &perf-domain-attrs
            - pad
            - perf-domain-id
            - flags
            - cpus
      dump:
        reply:
          attributes: *perf-domain-attrs
    -
      name: get-pd-table
      attribute-set: pd-table
      name: get-perf-table
      attribute-set: perf-table
      doc: Get the energy model table of a performance domain.
      do:
        request:
          attributes:
            - pd-id
            - perf-domain-id
        reply:
          attributes:
            - pd-id
            - ps
            - perf-domain-id
            - perf-state
    -
      name: pd-created
      name: perf-domain-created
      doc: A performance domain is created.
      notify: get-pd-table
      notify: get-perf-table
      mcgrp: event
    -
      name: pd-updated
      name: perf-domain-updated
      doc: A performance domain is updated.
      notify: get-pd-table
      notify: get-perf-table
      mcgrp: event
    -
      name: pd-deleted
      name: perf-domain-deleted
      doc: A performance domain is deleted.
      attribute-set: pd-table
      attribute-set: perf-table
      event:
        attributes:
            - pd-id
          - perf-domain-id
      mcgrp: event

mcast-groups:
+4 −4
Original line number Diff line number Diff line
@@ -9304,12 +9304,12 @@ M: Lukasz Luba <lukasz.luba@arm.com>
M:	"Rafael J. Wysocki" <rafael@kernel.org>
L:	linux-pm@vger.kernel.org
S:	Maintained
F:	kernel/power/energy_model.c
F:	include/linux/energy_model.h
F:	Documentation/netlink/specs/dev-energymodel.yaml
F:	Documentation/power/energy-model.rst
F:	Documentation/netlink/specs/em.yaml
F:	include/uapi/linux/energy_model.h
F:	include/linux/energy_model.h
F:	include/uapi/linux/dev_energymodel.h
F:	kernel/power/em_netlink*.*
F:	kernel/power/energy_model.c
EPAPR HYPERVISOR BYTE CHANNEL DEVICE DRIVER
M:	Laurentiu Tudor <laurentiu.tudor@nxp.com>
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
 * @power:	The power consumed at this level (by 1 CPU or by a registered
 *		device). It can be a total power: static and dynamic.
 * @cost:	The cost coefficient associated with this level, used during
 *		energy calculation. Equal to: power * max_frequency / frequency
 *		energy calculation. Equal to: 10 * power * max_frequency / frequency
 * @flags:	see "em_perf_state flags" description below.
 */
struct em_perf_state {
+82 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
/* Do not edit directly, auto-generated from: */
/*	Documentation/netlink/specs/dev-energymodel.yaml */
/* YNL-GEN uapi header */
/* To regenerate run: tools/net/ynl/ynl-regen.sh */

#ifndef _UAPI_LINUX_DEV_ENERGYMODEL_H
#define _UAPI_LINUX_DEV_ENERGYMODEL_H

#define DEV_ENERGYMODEL_FAMILY_NAME	"dev-energymodel"
#define DEV_ENERGYMODEL_FAMILY_VERSION	1

/**
 * enum dev_energymodel_perf_state_flags
 * @DEV_ENERGYMODEL_PERF_STATE_FLAGS_PERF_STATE_INEFFICIENT: The performance
 *   state is inefficient. There is in this perf-domain, another performance
 *   state with a higher frequency but a lower or equal power cost.
 */
enum dev_energymodel_perf_state_flags {
	DEV_ENERGYMODEL_PERF_STATE_FLAGS_PERF_STATE_INEFFICIENT = 1,
};

/**
 * enum dev_energymodel_perf_domain_flags
 * @DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_MICROWATTS: The power values
 *   are in micro-Watts or some other scale.
 * @DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_SKIP_INEFFICIENCIES: Skip
 *   inefficient states when estimating energy consumption.
 * @DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_ARTIFICIAL: The power values
 *   are artificial and might be created by platform missing real power
 *   information.
 */
enum dev_energymodel_perf_domain_flags {
	DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_MICROWATTS = 1,
	DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_SKIP_INEFFICIENCIES = 2,
	DEV_ENERGYMODEL_PERF_DOMAIN_FLAGS_PERF_DOMAIN_ARTIFICIAL = 4,
};

enum {
	DEV_ENERGYMODEL_A_PERF_DOMAIN_PAD = 1,
	DEV_ENERGYMODEL_A_PERF_DOMAIN_PERF_DOMAIN_ID,
	DEV_ENERGYMODEL_A_PERF_DOMAIN_FLAGS,
	DEV_ENERGYMODEL_A_PERF_DOMAIN_CPUS,

	__DEV_ENERGYMODEL_A_PERF_DOMAIN_MAX,
	DEV_ENERGYMODEL_A_PERF_DOMAIN_MAX = (__DEV_ENERGYMODEL_A_PERF_DOMAIN_MAX - 1)
};

enum {
	DEV_ENERGYMODEL_A_PERF_TABLE_PERF_DOMAIN_ID = 1,
	DEV_ENERGYMODEL_A_PERF_TABLE_PERF_STATE,

	__DEV_ENERGYMODEL_A_PERF_TABLE_MAX,
	DEV_ENERGYMODEL_A_PERF_TABLE_MAX = (__DEV_ENERGYMODEL_A_PERF_TABLE_MAX - 1)
};

enum {
	DEV_ENERGYMODEL_A_PERF_STATE_PAD = 1,
	DEV_ENERGYMODEL_A_PERF_STATE_PERFORMANCE,
	DEV_ENERGYMODEL_A_PERF_STATE_FREQUENCY,
	DEV_ENERGYMODEL_A_PERF_STATE_POWER,
	DEV_ENERGYMODEL_A_PERF_STATE_COST,
	DEV_ENERGYMODEL_A_PERF_STATE_FLAGS,

	__DEV_ENERGYMODEL_A_PERF_STATE_MAX,
	DEV_ENERGYMODEL_A_PERF_STATE_MAX = (__DEV_ENERGYMODEL_A_PERF_STATE_MAX - 1)
};

enum {
	DEV_ENERGYMODEL_CMD_GET_PERF_DOMAINS = 1,
	DEV_ENERGYMODEL_CMD_GET_PERF_TABLE,
	DEV_ENERGYMODEL_CMD_PERF_DOMAIN_CREATED,
	DEV_ENERGYMODEL_CMD_PERF_DOMAIN_UPDATED,
	DEV_ENERGYMODEL_CMD_PERF_DOMAIN_DELETED,

	__DEV_ENERGYMODEL_CMD_MAX,
	DEV_ENERGYMODEL_CMD_MAX = (__DEV_ENERGYMODEL_CMD_MAX - 1)
};

#define DEV_ENERGYMODEL_MCGRP_EVENT	"event"

#endif /* _UAPI_LINUX_DEV_ENERGYMODEL_H */

include/uapi/linux/energy_model.h

deleted100644 → 0
+0 −63
Original line number Diff line number Diff line
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
/* Do not edit directly, auto-generated from: */
/*	Documentation/netlink/specs/em.yaml */
/* YNL-GEN uapi header */
/* To regenerate run: tools/net/ynl/ynl-regen.sh */

#ifndef _UAPI_LINUX_ENERGY_MODEL_H
#define _UAPI_LINUX_ENERGY_MODEL_H

#define EM_FAMILY_NAME		"em"
#define EM_FAMILY_VERSION	1

enum {
	EM_A_PDS_PD = 1,

	__EM_A_PDS_MAX,
	EM_A_PDS_MAX = (__EM_A_PDS_MAX - 1)
};

enum {
	EM_A_PD_PAD = 1,
	EM_A_PD_PD_ID,
	EM_A_PD_FLAGS,
	EM_A_PD_CPUS,

	__EM_A_PD_MAX,
	EM_A_PD_MAX = (__EM_A_PD_MAX - 1)
};

enum {
	EM_A_PD_TABLE_PD_ID = 1,
	EM_A_PD_TABLE_PS,

	__EM_A_PD_TABLE_MAX,
	EM_A_PD_TABLE_MAX = (__EM_A_PD_TABLE_MAX - 1)
};

enum {
	EM_A_PS_PAD = 1,
	EM_A_PS_PERFORMANCE,
	EM_A_PS_FREQUENCY,
	EM_A_PS_POWER,
	EM_A_PS_COST,
	EM_A_PS_FLAGS,

	__EM_A_PS_MAX,
	EM_A_PS_MAX = (__EM_A_PS_MAX - 1)
};

enum {
	EM_CMD_GET_PDS = 1,
	EM_CMD_GET_PD_TABLE,
	EM_CMD_PD_CREATED,
	EM_CMD_PD_UPDATED,
	EM_CMD_PD_DELETED,

	__EM_CMD_MAX,
	EM_CMD_MAX = (__EM_CMD_MAX - 1)
};

#define EM_MCGRP_EVENT	"event"

#endif /* _UAPI_LINUX_ENERGY_MODEL_H */
Loading