power: refactor power management library
PATCH v9 1/6 power: refactor core power management library
In reply to Sivaprasad TummalaThis patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v8:
- marked rte_power_logtype as internal
- removed c++ guards for internal header files
- renamed rte_power_cpufreq_api.h for naming convention
- renamed rte_power_register_ops for naming convention
v6:
- fixed compilation error with symbol export in API
- exported power_get_lcore_mapped_cpu_id as internal API to be used in drivers/power/*
v5:
- fixed code style warning
v4:
- fixed build error with RTE_ASSERT
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/rte_power.c | 355 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/version.map | 14 +
26 files changed, 650 insertions(+), 270 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -587,3 +587,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -710,3 +710,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +5 -5
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if amd p-state power management is supported.
@@ -216,4 +216,4 @@ int power_amd_pstate_disable_turbo(unsigned int lcore_id);int power_amd_pstate_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_AMD_PSTATET_CPUFREQ_H */ +#endif /* _AMD_PSTATET_CPUFREQ_H */
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -695,3 +695,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +1 -1
@@ -13,7 +13,7 @@#include <rte_log.h> -#include <rte_power.h> +#include <rte_power_guest_channel.h> #include "guest_channel.h"
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_cpufreq_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -898,3 +898,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,19 +12,14 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( + 'power_cpufreq.h', 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h',
lib/power/power_common.c +1 -1
@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +16 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,14 +24,27 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */
lib/power/power_cpufreq.h new file +191 -0
191 lines not on this page · raw message
lib/power/rte_power.c +164 -191
408 lines not on this page · raw message
lib/power/rte_power.h +71 -45
199 lines not on this page · raw message
lib/power/version.map +14 -0
@@ -52,3 +52,17 @@ EXPERIMENTAL { rte_power_uncore_freqs; rte_power_unset_uncore_env; }; + +INTERNAL { + global: + + rte_power_register_cpufreq_ops; + rte_power_logtype; + cpufreq_check_scaling_driver; + power_get_lcore_mapped_cpu_id; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; +};
Signature · 1 line
2.34.1
Re: [PATCH v9 1/6] power: refactor core power management library
Hi Sivaprasad,
LGTM except for some trivial comments inline, With belows to change, you can add
/Huisong
Quoted 40 lines · Sivaprasad Tummala
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within '
drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v8:
- markedrte_power_logtypeas internal
- removed c++ guards for internal header files
- renamedrte_power_cpufreq_api.hfor naming convention
- renamedrte_power_register_opsfor naming conventionv6:
- fixed compilation error with symbol export in API
- exportedpower_get_lcore_mapped_cpu_idas internal API to be used indrivers/power/*v5:
- fixed code style warningv4:
- fixed build error withRTE_ASSERTv3:
- renamedrte_power_core_ops.hasrte_power_cpufreq_api.h
- re-worked on auto detection logicv2:
- added NULL check forglobal_core_opsinrte_power_get_core_opsSigned-off-by Sivaprasad Tummala <[email protected]>---
<snip>
lib/power/power_cpufreq.h line 177
Quoted 9 lines
lib/power/power_cpufreq.h new file +9
-0+ +/** +* Register power cpu frequency operations. +* +* @param ops +* Pointer to an ops structure to register. +* @return +* - >=0: Success; return the index of the ops struct in the table. +* - -EINVAL - error while registering ops struct.
Not the index in the table, need to fix it. BTW, this API always success now. so no return value.
Quoted 54 lines
+ */
lib/power/power_cpufreq.h new file +13
-0+__rte_internal +int rte_power_register_cpufreq_ops(struct rte_power_cpufreq_ops *ops); + +/** +* Macro to statically register the ops of a cpufreq driver. +*/ +#define RTE_POWER_REGISTER_CPUFREQ_OPS (ops) \ +RTE_INIT(power_hdlr_init_##ops) \ +{ \ + rte_power_register_cpufreq_ops(&ops); \ +} + +#endif lib/power/rte_power.c +4
-22@@ -6,155 +6,88 @@#include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_debug.h> #include "rte_power.h" -#include "power_acpi_cpufreq.h" -#include "power_cppc_cpufreq.h" #include "power_common.h" -#include "power_kvm_vm.h" -#include "power_pstate_cpufreq.h" -#include "power_amd_pstate_cpufreq.h" -enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static struct rte_power_cpufreq_ops *global_cpufreq_ops;static rte_spinlock_t global_env_cfg_lock =RTE_SPINLOCK_INITIALIZER ; - -/* function pointers */ -rte_power_freqs_t rte_power_freqs =NULL ; -rte_power_get_freq_t rte_power_get_freq =NULL ; -rte_power_set_freq_t rte_power_set_freq =NULL ; -rte_power_freq_change_t rte_power_freq_up =NULL ; -rte_power_freq_change_t rte_power_freq_down =NULL ; -rte_power_freq_change_t rte_power_freq_max =NULL ; -rte_power_freq_change_t rte_power_freq_min =NULL ; -rte_power_freq_change_t rte_power_turbo_status; -rte_power_freq_change_t rte_power_freq_enable_turbo; -rte_power_freq_change_t rte_power_freq_disable_turbo; -rte_power_get_capabilities_t rte_power_get_capabilities; - -static void -reset_power_function_ptrs (void ) +static RTE_TAILQ_HEAD(, rte_power_cpufreq_ops) cpufreq_ops_list =
lib/power/rte_power.c line 28
Quoted 10 lines
lib/power/rte_power.c +10
-0+TAILQ_HEAD_INITIALIZER (cpufreq_ops_list); + +const char *power_env_str[] = { +"not set" , +"acpi" , +"kvm-vm" , +"pstate" , +"cppc" , +"amd-pstate" +};
How use the "not set"? I don't know what its usage is. Do we need to consider removing it later?
Quoted 21 lines
lib/power/rte_power.c +9
-11+ +/* register the ops struct in rte_power_cpufreq_ops, return 0 on success. */ +int +rte_power_register_cpufreq_ops (struct rte_power_cpufreq_ops *driver_ops) { - rte_power_freqs =NULL ; - rte_power_get_freq =NULL ; - rte_power_set_freq =NULL ; - rte_power_freq_up =NULL ; - rte_power_freq_down =NULL ; - rte_power_freq_max =NULL ; - rte_power_freq_min =NULL ; - rte_power_turbo_status =NULL ; - rte_power_freq_enable_turbo =NULL ; - rte_power_freq_disable_turbo =NULL ; - rte_power_get_capabilities =NULL ; + if (!driver_ops->init || !driver_ops->exit || + !driver_ops->check_env_support || !driver_ops->get_avail_freqs || + !driver_ops->get_freq || !driver_ops->set_freq || + !driver_ops->freq_up || !driver_ops->freq_down || + !driver_ops->freq_max || !driver_ops->freq_min ||
lib/power/rte_power.c line 48
Quoted 10 lines
lib/power/rte_power.c +9
-0+ !driver_ops->turbo_status || !driver_ops->enable_turbo || + !driver_ops->disable_turbo || !driver_ops->get_caps) { +POWER_LOG (ERR ,"Missing callbacks while registering cpufreq ops" ); +return -EINVAL ; + } + +TAILQ_INSERT_TAIL (&cpufreq_ops_list, driver_ops, next); + +return 0 ; }
suggest that change function return value as above mention.
Quoted 32 lines
lib/power/rte_power.c +11
-15int rte_power_check_env_supported (enum power_management_env env) { -switch (env) { -case PM_ENV_ACPI_CPUFREQ : -return power_acpi_cpufreq_check_supported (); -case PM_ENV_PSTATE_CPUFREQ : -return power_pstate_cpufreq_check_supported (); -case PM_ENV_KVM_VM : -return power_kvm_vm_check_supported (); -case PM_ENV_CPPC_CPUFREQ : -return power_cppc_cpufreq_check_supported (); -case PM_ENV_AMD_PSTATE_CPUFREQ : -return power_amd_pstate_cpufreq_check_supported (); -default : - rte_errno =EINVAL ; -return -1 ; - } +struct rte_power_cpufreq_ops *ops; + +if (env >=RTE_DIM (power_env_str)) +return 0 ; + + RTE_TAILQ_FOREACH(ops, &cpufreq_ops_list, next) +if (strncmp (ops->name, power_env_str[env], +RTE_POWER_DRIVER_NAMESZ ) ==0 ) +return ops->check_env_support (); + +return 0 ; }
<snip>
RE: [PATCH v9 1/6] power: refactor core power management library
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Huisong,
Quoted 62 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Saturday, October 26, 2024 8:37 AM
To: Tummala, Sivaprasad <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Subject: Re: [PATCH v9 1/6] power: refactor core power management libraryCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi Sivaprasad,
LGTM except for some trivial comments inline, With belows to change, you can add
Acked-by Huisong Li <[email protected]>/Huisong
Quoted 40 lines · Sivaprasad Tummala
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within '
drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v8:
- markedrte_power_logtypeas internal
- removed c++ guards for internal header files
- renamedrte_power_cpufreq_api.hfor naming convention
- renamedrte_power_register_opsfor naming conventionv6:
- fixed compilation error with symbol export in API
- exportedpower_get_lcore_mapped_cpu_idas internal API to be used indrivers/power/*v5:
- fixed code style warningv4:
- fixed build error withRTE_ASSERTv3:
- renamedrte_power_core_ops.hasrte_power_cpufreq_api.h
- re-worked on auto detection logicv2:
- added NULL check forglobal_core_opsinrte_power_get_core_opsSigned-off-by Sivaprasad Tummala <[email protected]>---
<snip>
Quoted 11 lines
lib/power/power_cpufreq.h line 177
Quoted 9 lines
lib/power/power_cpufreq.h new file +9
-0+ +/** +* Register power cpu frequency operations. +* +* @param ops +* Pointer to an ops structure to register. +* @return +* - >=0: Success; return the index of the ops struct in the table. +* - -EINVAL - error while registering ops struct. Not the index in the table, need to fix it. BTW, this API always success now. so no return value.
API now consistently returns 0 on success, rather than an index in the table. It will return a negative value on error. I'll update the documentation to reflect this change and avoid any confusion.
Quoted 60 lines
Quoted 24 lines
+ */
lib/power/power_cpufreq.h new file +13
-0+__rte_internal +int rte_power_register_cpufreq_ops(struct rte_power_cpufreq_ops +*ops); + +/** +* Macro to statically register the ops of a cpufreq driver. +*/ +#define RTE_POWER_REGISTER_CPUFREQ_OPS (ops) \ +RTE_INIT(power_hdlr_init_##ops) \ +{ \ + rte_power_register_cpufreq_ops(&ops); \ } + +#endif lib/power/rte_power.c index renamed from lib/power/rte_power.c +0
-0
36c3f3da98..3168b6d301100644lib/power/rte_power.c +1
-0@@ -6,155 +6,88 @@#include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_debug.h> lib/power/rte_power.c line 14
Quoted 10 lines
lib/power/rte_power.c +1
-6#include "rte_power.h" -#include "power_acpi_cpufreq.h" -#include "power_cppc_cpufreq.h" #include "power_common.h" -#include "power_kvm_vm.h" -#include "power_pstate_cpufreq.h" -#include "power_amd_pstate_cpufreq.h" -enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static enum power_management_env global_default_env =
PM_ENV_NOT_SET;Quoted 25 lines
lib/power/rte_power.c +1
-3+static struct rte_power_cpufreq_ops *global_cpufreq_ops;static rte_spinlock_t global_env_cfg_lock =RTE_SPINLOCK_INITIALIZER ; - -/* function pointers */ -rte_power_freqs_t rte_power_freqs =NULL ; -rte_power_get_freq_t
rte_power_get_freq= NULL; -rte_power_set_freq_trte_power_set_freq= NULL; -rte_power_freq_change_trte_power_freq_up= NULL;lib/power/rte_power.c +6
-10-rte_power_freq_change_t rte_power_freq_down =NULL ; -rte_power_freq_change_t rte_power_freq_max =NULL ; -rte_power_freq_change_t rte_power_freq_min =NULL ; -rte_power_freq_change_t rte_power_turbo_status; -rte_power_freq_change_t rte_power_freq_enable_turbo; -rte_power_freq_change_t rte_power_freq_disable_turbo; -rte_power_get_capabilities_t rte_power_get_capabilities; - -static void -reset_power_function_ptrs (void ) +static RTE_TAILQ_HEAD(, rte_power_cpufreq_ops) cpufreq_ops_list = +TAILQ_HEAD_INITIALIZER (cpufreq_ops_list); + +const char *power_env_str[] = { +"not set" , +"acpi" ,
Quoted 8 lines
lib/power/rte_power.c line 28
Quoted 5 lines
lib/power/rte_power.c +5
-0+"kvm-vm" , +"pstate" , +"cppc" , + "amd-pstate" +};How use the "not set"? I don't know what its usage is. Do we need to consider removing it later?
The "not set" is default state and indicates no specific cpufreq management driver is active. If the specific driver (located in drivers/power/*) is disabled during the build process, the API will fail to configure the environment, leaving it in the "not set" state.
Quoted 25 lines
Quoted 25 lines
lib/power/rte_power.c +12
-11+ +/* register the ops struct in rte_power_cpufreq_ops, return 0 on +success. */ int rte_power_register_cpufreq_ops (struct +rte_power_cpufreq_ops *driver_ops) { - rte_power_freqs =NULL ; - rte_power_get_freq =NULL ; - rte_power_set_freq =NULL ; - rte_power_freq_up =NULL ; - rte_power_freq_down =NULL ; - rte_power_freq_max =NULL ; - rte_power_freq_min =NULL ; - rte_power_turbo_status =NULL ; - rte_power_freq_enable_turbo =NULL ; - rte_power_freq_disable_turbo =NULL ; - rte_power_get_capabilities =NULL ; +if (!driver_ops->init || !driver_ops->exit || + !driver_ops->check_env_support || !driver_ops->get_avail_freqs || + !driver_ops->get_freq || !driver_ops->set_freq || + !driver_ops->freq_up || !driver_ops->freq_down || + !driver_ops->freq_max || !driver_ops->freq_min || + !driver_ops->turbo_status || !driver_ops->enable_turbo || + !driver_ops->disable_turbo || !driver_ops->get_caps) { +POWER_LOG (ERR ,"Missing callbacks while registering cpufreq ops" );
Quoted 8 lines
lib/power/rte_power.c line 48
Quoted 7 lines
lib/power/rte_power.c +6
-0+return -EINVAL ; + } + +TAILQ_INSERT_TAIL (&cpufreq_ops_list, driver_ops, next); + +return 0 ; }suggest that change function return value as above mention.
Same as above.
Quoted 33 lines
Quoted 32 lines
int rte_power_check_env_supported(enum power_management_env env) {lib/power/rte_power.c +11
-15-switch (env) { -case PM_ENV_ACPI_CPUFREQ : -return power_acpi_cpufreq_check_supported (); -case PM_ENV_PSTATE_CPUFREQ : -return power_pstate_cpufreq_check_supported (); -case PM_ENV_KVM_VM : -return power_kvm_vm_check_supported (); -case PM_ENV_CPPC_CPUFREQ : -return power_cppc_cpufreq_check_supported (); -case PM_ENV_AMD_PSTATE_CPUFREQ : -return power_amd_pstate_cpufreq_check_supported (); -default : - rte_errno =EINVAL ; -return -1 ; - } +struct rte_power_cpufreq_ops *ops; + +if (env >=RTE_DIM (power_env_str)) +return 0 ; + + RTE_TAILQ_FOREACH(ops, &cpufreq_ops_list, next) +if (strncmp (ops->name, power_env_str[env], +RTE_POWER_DRIVER_NAMESZ ) ==0 ) +return ops->check_env_support (); + +return 0 ; }<snip>
Re: [PATCH v9 1/6] power: refactor core power management library
Quoted 77 lines · Sivaprasad
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Huisong,
Quoted 62 lines
-----Original Message-----
From: lihuisong (C) <[email protected]>
Sent: Saturday, October 26, 2024 8:37 AM
To: Tummala, Sivaprasad <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Subject: Re: [PATCH v9 1/6] power: refactor core power management libraryCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi Sivaprasad,
LGTM except for some trivial comments inline, With belows to change, you can add
Acked-by Huisong Li <[email protected]>/Huisong
Quoted 40 lines · Sivaprasad Tummala
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within '
drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v8:
- markedrte_power_logtypeas internal
- removed c++ guards for internal header files
- renamedrte_power_cpufreq_api.hfor naming convention
- renamedrte_power_register_opsfor naming conventionv6:
- fixed compilation error with symbol export in API
- exportedpower_get_lcore_mapped_cpu_idas internal API to be used indrivers/power/*v5:
- fixed code style warningv4:
- fixed build error withRTE_ASSERTv3:
- renamedrte_power_core_ops.hasrte_power_cpufreq_api.h
- re-worked on auto detection logicv2:
- added NULL check forglobal_core_opsinrte_power_get_core_opsSigned-off-by Sivaprasad Tummala <[email protected]>---
<snip>
Quoted 11 lines
lib/power/power_cpufreq.h line 177
Quoted 9 lines
lib/power/power_cpufreq.h new file +9
-0+ +/** +* Register power cpu frequency operations. +* +* @param ops +* Pointer to an ops structure to register. +* @return +* - >=0: Success; return the index of the ops struct in the table. +* - -EINVAL - error while registering ops struct. Not the index in the table, need to fix it. BTW, this API always success now. so no return value.
Quoted 2 lines
API now consistently returns 0 on success, rather than an index in the table. It will return a negative value on error. I'll update the documentation to reflect this change and avoid any confusion.
Ack
Quoted 67 lines
Quoted 59 lines
Quoted 24 lines
+ */
lib/power/power_cpufreq.h new file +13
-0+__rte_internal +int rte_power_register_cpufreq_ops(struct rte_power_cpufreq_ops +*ops); + +/** +* Macro to statically register the ops of a cpufreq driver. +*/ +#define RTE_POWER_REGISTER_CPUFREQ_OPS (ops) \ +RTE_INIT(power_hdlr_init_##ops) \ +{ \ + rte_power_register_cpufreq_ops(&ops); \ } + +#endif lib/power/rte_power.c index renamed from lib/power/rte_power.c +0
-0
36c3f3da98..3168b6d301100644lib/power/rte_power.c +1
-0@@ -6,155 +6,88 @@#include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_debug.h> lib/power/rte_power.c line 14
Quoted 10 lines
lib/power/rte_power.c +1
-6#include "rte_power.h" -#include "power_acpi_cpufreq.h" -#include "power_cppc_cpufreq.h" #include "power_common.h" -#include "power_kvm_vm.h" -#include "power_pstate_cpufreq.h" -#include "power_amd_pstate_cpufreq.h" -enum power_management_env global_default_env =PM_ENV_NOT_SET ; +static enum power_management_env global_default_env =
PM_ENV_NOT_SET;Quoted 24 lines
lib/power/rte_power.c +1
-3+static struct rte_power_cpufreq_ops *global_cpufreq_ops;static rte_spinlock_t global_env_cfg_lock =RTE_SPINLOCK_INITIALIZER ; - -/* function pointers */ -rte_power_freqs_t rte_power_freqs =NULL ; -rte_power_get_freq_t
rte_power_get_freq= NULL; -rte_power_set_freq_trte_power_set_freq= NULL; -rte_power_freq_change_trte_power_freq_up= NULL;lib/power/rte_power.c +5
-10-rte_power_freq_change_t rte_power_freq_down =NULL ; -rte_power_freq_change_t rte_power_freq_max =NULL ; -rte_power_freq_change_t rte_power_freq_min =NULL ; -rte_power_freq_change_t rte_power_turbo_status; -rte_power_freq_change_t rte_power_freq_enable_turbo; -rte_power_freq_change_t rte_power_freq_disable_turbo; -rte_power_get_capabilities_t rte_power_get_capabilities; - -static void -reset_power_function_ptrs (void ) +static RTE_TAILQ_HEAD(, rte_power_cpufreq_ops) cpufreq_ops_list = +TAILQ_HEAD_INITIALIZER (cpufreq_ops_list); + +const char *power_env_str[] = { +"not set" ,Quoted 8 lines
lib/power/rte_power.c line 28
Quoted 6 lines
lib/power/rte_power.c +6
-0+"acpi" , +"kvm-vm" , +"pstate" , +"cppc" , + "amd-pstate" +};How use the "not set"? I don't know what its usage is. Do we need to consider removing it later?
Quoted 3 lines
The "not set" is default state and indicates no specific cpufreq management driver is active. If the specific driver (located in
drivers/power/*) is disabled during the build process, the API will fail to configure the environment, leaving it in the "not set" state.
ok
Quoted 65 lines
Quoted 24 lines
Quoted 24 lines
lib/power/rte_power.c +12
-11+ +/* register the ops struct in rte_power_cpufreq_ops, return 0 on +success. */ int rte_power_register_cpufreq_ops (struct +rte_power_cpufreq_ops *driver_ops) { - rte_power_freqs =NULL ; - rte_power_get_freq =NULL ; - rte_power_set_freq =NULL ; - rte_power_freq_up =NULL ; - rte_power_freq_down =NULL ; - rte_power_freq_max =NULL ; - rte_power_freq_min =NULL ; - rte_power_turbo_status =NULL ; - rte_power_freq_enable_turbo =NULL ; - rte_power_freq_disable_turbo =NULL ; - rte_power_get_capabilities =NULL ; +if (!driver_ops->init || !driver_ops->exit || + !driver_ops->check_env_support || !driver_ops->get_avail_freqs || + !driver_ops->get_freq || !driver_ops->set_freq || + !driver_ops->freq_up || !driver_ops->freq_down || + !driver_ops->freq_max || !driver_ops->freq_min || + !driver_ops->turbo_status || !driver_ops->enable_turbo || + !driver_ops->disable_turbo || !driver_ops->get_caps) { +POWER_LOG (ERR ,"Missing callbacks while registering cpufreq ops" );Quoted 8 lines
lib/power/rte_power.c line 48
Quoted 7 lines
lib/power/rte_power.c +6
-0+return -EINVAL ; + } + +TAILQ_INSERT_TAIL (&cpufreq_ops_list, driver_ops, next); + +return 0 ; }suggest that change function return value as above mention.
Same as above.
Quoted 32 lines
Quoted 31 lines
int rte_power_check_env_supported(enum power_management_env env) {lib/power/rte_power.c +11
-15-switch (env) { -case PM_ENV_ACPI_CPUFREQ : -return power_acpi_cpufreq_check_supported (); -case PM_ENV_PSTATE_CPUFREQ : -return power_pstate_cpufreq_check_supported (); -case PM_ENV_KVM_VM : -return power_kvm_vm_check_supported (); -case PM_ENV_CPPC_CPUFREQ : -return power_cppc_cpufreq_check_supported (); -case PM_ENV_AMD_PSTATE_CPUFREQ : -return power_amd_pstate_cpufreq_check_supported (); -default : - rte_errno =EINVAL ; -return -1 ; - } +struct rte_power_cpufreq_ops *ops; + +if (env >=RTE_DIM (power_env_str)) +return 0 ; + + RTE_TAILQ_FOREACH(ops, &cpufreq_ops_list, next) +if (strncmp (ops->name, power_env_str[env], +RTE_POWER_DRIVER_NAMESZ ) ==0 ) +return ops->check_env_support (); + +return 0 ; }<snip>
PATCH v9 2/6 power: refactor uncore power management library
In reply to Sivaprasad TummalaThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v9:
- documentation update
v8:
- removed c++ guards for internal header files
- renamed rte_power_uncore_ops.h for naming convention
v7:
- fixed build error with aarch32 gcc cross compilation
v6:
- fixed compilation error with symbol export in API
v5:
- fixed build errors for risc-v/ppc targets
v4:
- fixed build error with RTE_ASSERT
--- doc/guides/prog_guide/power_man.rst | 10 +- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 9 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/power_uncore_ops.h | 244 +++++++++++++++++ lib/power/rte_power_uncore.c | 256 +++++++++--------- lib/power/rte_power_uncore.h | 61 ++--- lib/power/version.map | 1 + 10 files changed, 440 insertions(+), 170 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/power_uncore_ops.h
doc/guides/prog_guide/power_man.rst +5 -5
@@ -191,8 +191,8 @@ API Overview for Ethernet PMD Power Management * **Set Scaling Max Freq**: Set the maximum frequency (kHz) to be used in Frequency Scaling mode. -Intel Uncore API ----------------- +Uncore API +---------- Abstract ~~~~~~~~
@@ -211,10 +211,10 @@ which was added in 5.6. This manipulates the context of MSR 0x620, which sets min/max of the uncore for the SKU. -API Overview for Intel Uncore -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Uncore API Overview +~~~~~~~~~~~~~~~~~~~ -Overview of each function in the Intel Uncore API, +Overview of each function in the Uncore API, with explanation of what they do. Each function should not be called in the fast path.
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -5
@@ -2,16 +2,15 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef _INTEL_UNCORE_H +#define _INTEL_UNCORE_H /** * @file * RTE Intel Uncore Frequency Management */ -#include "rte_power.h" -#include "rte_power_uncore.h" +#include "power_uncore_ops.h" #ifdef __cplusplus extern "C" {
@@ -223,4 +222,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* _INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,13 +13,13 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'power_cpufreq.h', + 'power_uncore_ops.h', 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h',
lib/power/power_uncore_ops.h new file +244 -0
244 lines not on this page · raw message
lib/power/rte_power_uncore.c +132 -124
313 lines not on this page · raw message
lib/power/rte_power_uncore.h +28 -33
125 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -57,6 +57,7 @@ INTERNAL { global: rte_power_register_cpufreq_ops; + rte_power_register_uncore_ops; rte_power_logtype; cpufreq_check_scaling_driver; power_get_lcore_mapped_cpu_id;
Signature · 1 line
2.34.1
Re: [PATCH v9 2/6] power: refactor uncore power management library
Already reviewed before.
Quoted 47 lines · Sivaprasad Tummala
This patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v9:
- documentation updatev8:
- removed c++ guards for internal header files
- renamedrte_power_uncore_ops.hfor naming conventionv7:
- fixed build error with aarch32 gcc cross compilationv6:
- fixed compilation error with symbol export in APIv5:
- fixed build errors for risc-v/ppc targetsv4:
- fixed build error withRTE_ASSERTSigned-off-by Sivaprasad Tummala <[email protected]>--- doc/guides/prog_guide/power_man.rst | 10 +- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 9 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/power_uncore_ops.h | 244 +++++++++++++++++ lib/power/rte_power_uncore.c | 256 +++++++++--------- lib/power/rte_power_uncore.h | 61 ++--- lib/power/version.map | 1 + 10 files changed, 440 insertions(+), 170 deletions(-)rename
lib/power/power_intel_uncore.c=>drivers/power/intel_uncore/intel_uncore.c(95%) renamelib/power/power_intel_uncore.h=>drivers/power/intel_uncore/intel_uncore.h(97%) create mode 100644drivers/power/intel_uncore/meson.build
create mode 100644lib/power/power_uncore_ops.h
<snip>
PATCH v9 3/6 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
PATCH v9 4/6 drivers/power: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v9:
- documentation update
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- doc/guides/prog_guide/power_man.rst | 14 ++ drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 5 files changed, 589 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
doc/guides/prog_guide/power_man.rst +14 -0
@@ -203,6 +203,8 @@ to achieve high performance: L3 cache, on-die memory controller, etc. Significant power savings can be achieved by reducing the uncore frequency to its lowest value. +Intel Uncore +~~~~~~~~~~~~ The Linux kernel provides the driver "intel-uncore-frequency" to control the uncore frequency limits for x86 platform. The driver is available from kernel version 5.6 and above.
@@ -211,6 +213,18 @@ which was added in 5.6. This manipulates the context of MSR 0x620, which sets min/max of the uncore for the SKU. +AMD EPYC Uncore +~~~~~~~~~~~~~~~ +On AMD EPYC platforms, the Host System Management Port (HSMP) kernel module +facilitates user-level access to HSMP mailboxes, which are implemented by +the firmware in the System Management Unit (SMU). +The AMD HSMP driver is available starting from kernel version 5.18. +Please ensure that CONFIG_AMD_HSMP is enabled in your kernel configuration. + +Additionally, the EPYC System Management Interface In-band Library for Linux +offers essential APIs, enabling user-space software to effectively manage +system functions. + Uncore API Overview ~~~~~~~~~~~~~~~~~~~
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
329 lines not on this page · raw message
drivers/power/amd_uncore/amd_uncore.h new file +225 -0
225 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
PATCH v9 5/6 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1743,6 +1743,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
PATCH v9 6/6 power: rename library sources for cpu frequency management
In reply to Sivaprasad TummalaThis patch renames the existing core power library source files from rte_power.* to rte_power_cpufreq.* for better clarity
v9:
- documentation update
---
app/test/test_power.c | 2 +-
app/test/test_power_cpufreq.c | 2 +-
app/test/test_power_kvm_vm.c | 2 +-
doc/api/doxy-api-index.md | 2 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 2 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 4 ++--
lib/power/{rte_power.c => rte_power_cpufreq.c} | 2 +-
lib/power/{rte_power.h => rte_power_cpufreq.h} | 4 ++--
lib/power/rte_power_pmd_mgmt.h | 2 +-
16 files changed, 18 insertions(+), 18 deletions(-)
rename lib/power/{rte_power.c => rte_power_cpufreq.c} (99%)
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (99%)app/test/test_power.c +1 -1
@@ -22,7 +22,7 @@ test_power(void)#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> static int test_power (void )
app/test/test_power_cpufreq.c +1 -1
@@ -30,7 +30,7 @@ test_power_caps(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_LCORE_ID 2U#define TEST_POWER_LCORE_INVALID ((unsigned)RTE_MAX_LCORE)
app/test/test_power_kvm_vm.c +1 -1
@@ -20,7 +20,7 @@ test_power_kvm_vm(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_VM_LCORE_ID 0U#define TEST_POWER_VM_LCORE_OUT_OF_BOUNDS (RTE_MAX_LCORE+1)
doc/api/doxy-api-index.md +1 -1
@@ -102,7 +102,7 @@ The public API headers are grouped by topics: [per-lcore](@ref rte_per_lcore.h), [service cores](@ref rte_service.h), [keepalive](@ref rte_keepalive.h), - [power/freq](@ref rte_power.h), + [power/freq](@ref rte_power_cpufreq.h), [power/uncore](@ref rte_power_uncore.h), [PMD power](@ref rte_power_pmd_mgmt.h)
examples/distributor/main.c +1 -1
@@ -17,7 +17,7 @@#include <rte_prefetch.h> #include <rte_distributor.h> #include <rte_pause.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define RX_RING_SIZE 1024#define TX_RING_SIZE 1024
examples/l3fwd-power/main.c +1 -1
@@ -41,7 +41,7 @@#include <rte_udp.h> #include <rte_string_fns.h> #include <rte_timer.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include <rte_metrics.h> #include <rte_telemetry.h>
examples/l3fwd-power/perf_core.c +1 -1
@@ -10,7 +10,7 @@#include <rte_common.h> #include <rte_memory.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_string_fns.h> #include "perf_core.h"
examples/vm_power_manager/channel_monitor.c +1 -1
@@ -31,7 +31,7 @@#ifdef RTE_NET_I40E #include <rte_pmd_i40e.h> #endif -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <libvirt/libvirt.h> #include "channel_monitor.h"
examples/vm_power_manager/channel_monitor.h +1 -1
@@ -5,7 +5,7 @@#ifndef CHANNEL_MONITOR_H_ #define CHANNEL_MONITOR_H_ -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "channel_manager.h"
examples/vm_power_manager/guest_cli/main.c +1 -1
@@ -9,7 +9,7 @@#include <string.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_debug.h> #include <rte_eal.h> #include <rte_log.h>
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +1 -1
@@ -18,7 +18,7 @@#include <rte_lcore.h> #include <rte_ethdev.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "vm_power_cli_guest.h"
examples/vm_power_manager/power_manager.c +1 -1
@@ -15,7 +15,7 @@#include <sys/types.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include "channel_manager.h"
lib/power/meson.build +2 -2
@@ -13,14 +13,14 @@ if not is_linux endif sources = files( 'power_common.c', - 'rte_power.c', + 'rte_power_cpufreq.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'power_cpufreq.h', 'power_uncore_ops.h', - 'rte_power.h', + 'rte_power_cpufreq.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/rte_power_cpufreq.c renamed from lib/power/rte_power.c +1 -1
@@ -8,7 +8,7 @@#include <rte_spinlock.h> #include <rte_debug.h> -#include "rte_power.h" +#include "rte_power_cpufreq.h" #include "power_common.h" static enum power_management_env global_default_env =PM_ENV_NOT_SET ;
lib/power/rte_power_cpufreq.h renamed from lib/power/rte_power.h +2 -2
@@ -3,8 +3,8 @@* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _RTE_POWER_H -#define _RTE_POWER_H +#ifndef _RTE_POWER_CPUFREQ_H +#define _RTE_POWER_CPUFREQ_H/** * @file
lib/power/rte_power_pmd_mgmt.h +1 -1
@@ -13,7 +13,7 @@#include <stdint.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #ifdef __cplusplusextern "C" {
Signature · 1 line
2.34.1
Re: [PATCH v9 6/6] power: rename library sources for cpu frequency management
Hi Sivaprasad,
Quoted 2 lines · Sivaprasad Tummala
This patch renames the existing core power library source files from rte_power.* to rte_power_cpufreq.* for better clarity
Now it is more clarity for cpufeq and uncore. Thank you for this work.
But I have another question, pmd_mgmt component also depands on the initialization of cpufreq layer.
So I guess pmd_mgmt is also releated to core dvfs.
As Stephen mentioned in other place, if all configurations about core can be extracted one API, it is very good to use for application. I am still not sure if we can do that. But that's okay, we can do this later if possiable.
I just worried about whether the current name of rte_power_init() which is external interface is good for what's going on. Now that we rename the core power library source file, the rte_power_init() in rte_power_cpufreq.c may need to rename. How about add the following points?
1> rename rte_power_init() to rte_power_cpufreq_init() just for the initialization of cpufreq library.
2> create a new file rte_power_core.c and rte_power_core_init() which is used to do what Stephen said.
3> applications use rte_power_core_init() to take place of rte_power_init().
/Huisong
Quoted 250 lines
v9:
- documentation updateSigned-off-by Sivaprasad Tummala <[email protected]>--- app/test/test_power.c | 2 +- app/test/test_power_cpufreq.c | 2 +- app/test/test_power_kvm_vm.c | 2 +- doc/api/doxy-api-index.md | 2 +- examples/distributor/main.c | 2 +- examples/l3fwd-power/main.c | 2 +- examples/l3fwd-power/perf_core.c | 2 +- examples/vm_power_manager/channel_monitor.c | 2 +- examples/vm_power_manager/channel_monitor.h | 2 +- examples/vm_power_manager/guest_cli/main.c | 2 +- examples/vm_power_manager/guest_cli/vm_power_cli_guest.c | 2 +- examples/vm_power_manager/power_manager.c | 2 +- lib/power/meson.build | 4 ++-- lib/power/{rte_power.c => rte_power_cpufreq.c} | 2 +- lib/power/{rte_power.h => rte_power_cpufreq.h} | 4 ++-- lib/power/rte_power_pmd_mgmt.h | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-)rename
lib/power/{rte_power.c=>rte_power_cpufreq.c} (99%) renamelib/power/{rte_power.h=>rte_power_cpufreq.h} (99%)app/test/test_power.c +1
-1@@ -22,7 +22,7 @@ test_power(void)#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> static int test_power (void )app/test/test_power_cpufreq.c +1
-1@@ -30,7 +30,7 @@ test_power_caps(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_LCORE_ID 2U#define TEST_POWER_LCORE_INVALID ((unsigned)RTE_MAX_LCORE)app/test/test_power_kvm_vm.c +1
-1@@ -20,7 +20,7 @@ test_power_kvm_vm(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_VM_LCORE_ID 0U#define TEST_POWER_VM_LCORE_OUT_OF_BOUNDS (RTE_MAX_LCORE+1)doc/api/doxy-api-index.md +1
-1@@ -102,7 +102,7 @@ The public API headers are grouped by topics: [per-lcore](@ref rte_per_lcore.h), [service cores](@ref rte_service.h), [keepalive](@ref rte_keepalive.h), - [power/freq](@ref rte_power.h), + [power/freq](@ref rte_power_cpufreq.h), [power/uncore](@ref rte_power_uncore.h), [PMD power](@ref rte_power_pmd_mgmt.h)examples/distributor/main.c +1
-1@@ -17,7 +17,7 @@#include <rte_prefetch.h> #include <rte_distributor.h> #include <rte_pause.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define RX_RING_SIZE 1024#define TX_RING_SIZE 1024examples/l3fwd-power/main.c +1
-1@@ -41,7 +41,7 @@#include <rte_udp.h> #include <rte_string_fns.h> #include <rte_timer.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include <rte_metrics.h> #include <rte_telemetry.h> examples/l3fwd-power/perf_core.c +1
-1@@ -10,7 +10,7 @@#include <rte_common.h> #include <rte_memory.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_string_fns.h> #include "perf_core.h" examples/vm_power_manager/channel_monitor.c +1
-1@@ -31,7 +31,7 @@#ifdef RTE_NET_I40E #include <rte_pmd_i40e.h> #endif -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <libvirt/libvirt.h> #include "channel_monitor.h" examples/vm_power_manager/channel_monitor.h +1
-1@@ -5,7 +5,7 @@#ifndef CHANNEL_MONITOR_H_ #define CHANNEL_MONITOR_H_ -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "channel_manager.h" examples/vm_power_manager/guest_cli/main.c +1
-1@@ -9,7 +9,7 @@#include <string.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_debug.h> #include <rte_eal.h> #include <rte_log.h> examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +1
-1@@ -18,7 +18,7 @@#include <rte_lcore.h> #include <rte_ethdev.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "vm_power_cli_guest.h" examples/vm_power_manager/power_manager.c +1
-1@@ -15,7 +15,7 @@#include <sys/types.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include "channel_manager.h" lib/power/meson.build +2
-2@@ -13,14 +13,14 @@ if not is_linux endif sources = files( 'power_common.c', - 'rte_power.c', + 'rte_power_cpufreq.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'power_cpufreq.h', 'power_uncore_ops.h', - 'rte_power.h', + 'rte_power_cpufreq.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',lib/power/rte_power_cpufreq.c renamed from lib/power/rte_power.c +1
-1@@ -8,7 +8,7 @@#include <rte_spinlock.h> #include <rte_debug.h> -#include "rte_power.h" +#include "rte_power_cpufreq.h" #include "power_common.h" static enum power_management_env global_default_env =PM_ENV_NOT_SET ;lib/power/rte_power_cpufreq.h renamed from lib/power/rte_power.h +2
-2@@ -3,8 +3,8 @@* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _RTE_POWER_H -#define _RTE_POWER_H +#ifndef _RTE_POWER_CPUFREQ_H +#define _RTE_POWER_CPUFREQ_H/** * @file lib/power/rte_power_pmd_mgmt.h +1
-1@@ -13,7 +13,7 @@#include <stdint.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #ifdef __cplusplusextern "C" {
v9 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
power: rename library sources for cpu frequency management
MAINTAINERS | 1 +
app/test/test_power.c | 97 +-----
app/test/test_power_cpufreq.c | 54 +--
app/test/test_power_kvm_vm.c | 38 +-
doc/api/doxy-api-index.md | 2 +-
doc/guides/prog_guide/power_man.rst | 24 +-
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 9 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 14 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
.../guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 13 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/power_uncore_ops.h | 244 +++++++++++++
lib/power/rte_power.c | 257 --------------
lib/power/rte_power_cpufreq.c | 230 ++++++++++++
.../{rte_power.h => rte_power_cpufreq.h} | 120 ++++---
lib/power/rte_power_pmd_mgmt.h | 2 +-
lib/power/rte_power_uncore.c | 256 +++++++-------
lib/power/rte_power_uncore.h | 61 ++--
lib/power/version.map | 15 +
51 files changed, 1766 insertions(+), 713 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.h
create mode 100644 lib/power/power_uncore_ops.h
delete mode 100644 lib/power/rte_power.c
create mode 100644 lib/power/rte_power_cpufreq.c
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (73%)Signature · 1 line
2.34.1
v10 cover power: refactor power management library
In reply to Sivaprasad TummalaThis patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/core/*' and 'drivers/power/uncore/*'.
This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validations drivers/power: uncore support for AMD EPYC processors
maintainers: update for drivers/power
power: rename library sources for cpu frequency management
MAINTAINERS | 1 +
app/test/test_power.c | 97 +-----
app/test/test_power_cpufreq.c | 54 +--
app/test/test_power_kvm_vm.c | 38 +-
doc/api/doxy-api-index.md | 2 +-
doc/guides/prog_guide/power_man.rst | 24 +-
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++
drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++
drivers/power/amd_uncore/meson.build | 20 ++
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/intel_uncore/intel_uncore.c | 18 +-
.../power/intel_uncore/intel_uncore.h | 9 +-
drivers/power/intel_uncore/meson.build | 6 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 14 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 14 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
.../guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 13 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/power_uncore_ops.h | 244 +++++++++++++
lib/power/rte_power.c | 257 --------------
lib/power/rte_power_cpufreq.c | 227 ++++++++++++
.../{rte_power.h => rte_power_cpufreq.h} | 120 ++++---
lib/power/rte_power_pmd_mgmt.h | 2 +-
lib/power/rte_power_uncore.c | 259 +++++++-------
lib/power/rte_power_uncore.h | 61 ++--
lib/power/version.map | 15 +
51 files changed, 1763 insertions(+), 716 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
create mode 100644 drivers/power/amd_uncore/amd_uncore.c
create mode 100644 drivers/power/amd_uncore/amd_uncore.h
create mode 100644 drivers/power/amd_uncore/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%)
rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%)
create mode 100644 drivers/power/intel_uncore/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.h
create mode 100644 lib/power/power_uncore_ops.h
delete mode 100644 lib/power/rte_power.c
create mode 100644 lib/power/rte_power_cpufreq.c
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (73%)Signature · 1 line
2.34.1
PATCH v10 1/6 power: refactor core power management library
This patch introduces a comprehensive refactor to the core power management library. The primary focus is on improving modularity and organization by relocating specific driver implementations from the 'lib/power' directory to dedicated directories within 'drivers/power/core/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
These changes contribute to a significant enhancement in code organization, providing a clearer structure for driver implementations. The refactor aims to improve overall code clarity and boost maintainability. Additionally, it establishes a foundation for future development, allowing for more focused work on individual drivers and seamless integration of forthcoming enhancements.
v10:
- fixed rte_power_register_cpufreq_ops API description
- removed unused header inclusion
v8:
- marked rte_power_logtype as internal
- removed c++ guards for internal header files
- renamed rte_power_cpufreq_api.h for naming convention
- renamed rte_power_register_ops for naming convention
v6:
- fixed compilation error with symbol export in API
- exported power_get_lcore_mapped_cpu_id as internal API to be used in drivers/power/*
v5:
- fixed code style warning
v4:
- fixed build error with RTE_ASSERT
v3:
- renamed rte_power_core_ops.h as rte_power_cpufreq_api.h
- re-worked on auto detection logic
v2:
- added NULL check for global_core_ops in rte_power_get_core_ops
---
drivers/meson.build | 1 +
.../power/acpi/acpi_cpufreq.c | 22 +-
.../power/acpi/acpi_cpufreq.h | 6 +-
drivers/power/acpi/meson.build | 10 +
.../power/amd_pstate/amd_pstate_cpufreq.c | 24 +-
.../power/amd_pstate/amd_pstate_cpufreq.h | 10 +-
drivers/power/amd_pstate/meson.build | 10 +
.../power/cppc/cppc_cpufreq.c | 22 +-
.../power/cppc/cppc_cpufreq.h | 8 +-
drivers/power/cppc/meson.build | 10 +
.../power/kvm_vm}/guest_channel.c | 2 +-
.../power/kvm_vm}/guest_channel.h | 0
.../power/kvm_vm/kvm_vm.c | 22 +-
.../power/kvm_vm/kvm_vm.h | 6 +-
drivers/power/kvm_vm/meson.build | 14 +
drivers/power/meson.build | 12 +
drivers/power/pstate/meson.build | 10 +
.../power/pstate/pstate_cpufreq.c | 22 +-
.../power/pstate/pstate_cpufreq.h | 6 +-
lib/power/meson.build | 7 +-
lib/power/power_common.c | 2 +-
lib/power/power_common.h | 18 +-
lib/power/power_cpufreq.h | 191 ++++++++++
lib/power/rte_power.c | 358 ++++++++----------
lib/power/rte_power.h | 116 +++---
lib/power/version.map | 14 +
26 files changed, 650 insertions(+), 273 deletions(-)
rename lib/power/power_acpi_cpufreq.c => drivers/power/acpi/acpi_cpufreq.c (95%)
rename lib/power/power_acpi_cpufreq.h => drivers/power/acpi/acpi_cpufreq.h (98%)
create mode 100644 drivers/power/acpi/meson.build
rename lib/power/power_amd_pstate_cpufreq.c => drivers/power/amd_pstate/amd_pstate_cpufreq.c (95%)
rename lib/power/power_amd_pstate_cpufreq.h => drivers/power/amd_pstate/amd_pstate_cpufreq.h (96%)
create mode 100644 drivers/power/amd_pstate/meson.build
rename lib/power/power_cppc_cpufreq.c => drivers/power/cppc/cppc_cpufreq.c (95%)
rename lib/power/power_cppc_cpufreq.h => drivers/power/cppc/cppc_cpufreq.h (97%)
create mode 100644 drivers/power/cppc/meson.build
rename {lib/power => drivers/power/kvm_vm}/guest_channel.c (99%)
rename {lib/power => drivers/power/kvm_vm}/guest_channel.h (100%)
rename lib/power/power_kvm_vm.c => drivers/power/kvm_vm/kvm_vm.c (82%)
rename lib/power/power_kvm_vm.h => drivers/power/kvm_vm/kvm_vm.h (98%)
create mode 100644 drivers/power/kvm_vm/meson.build
create mode 100644 drivers/power/meson.build
create mode 100644 drivers/power/pstate/meson.build
rename lib/power/power_pstate_cpufreq.c => drivers/power/pstate/pstate_cpufreq.c (96%)
rename lib/power/power_pstate_cpufreq.h => drivers/power/pstate/pstate_cpufreq.h (98%)
create mode 100644 lib/power/power_cpufreq.hdrivers/meson.build +1 -0
@@ -29,6 +29,7 @@ subdirs = [ 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. 'gpu', # depends on common and bus. + 'power', # depends on common (in future). ] if meson.is_cross_build()
drivers/power/acpi/acpi_cpufreq.c renamed from lib/power/power_acpi_cpufreq.c +21 -1
@@ -10,7 +10,7 @@#include <rte_stdatomic.h> #include <rte_string_fns.h> -#include "power_acpi_cpufreq.h" +#include "acpi_cpufreq.h" #include "power_common.h" #define STR_SIZE 1024
@@ -587,3 +587,23 @@ int power_acpi_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops acpi_ops = { + .name ="acpi" , + .init = power_acpi_cpufreq_init, + .exit = power_acpi_cpufreq_exit, + .check_env_support = power_acpi_cpufreq_check_supported, + .get_avail_freqs = power_acpi_cpufreq_freqs, + .get_freq = power_acpi_cpufreq_get_freq, + .set_freq = power_acpi_cpufreq_set_freq, + .freq_down = power_acpi_cpufreq_freq_down, + .freq_up = power_acpi_cpufreq_freq_up, + .freq_max = power_acpi_cpufreq_freq_max, + .freq_min = power_acpi_cpufreq_freq_min, + .turbo_status = power_acpi_turbo_status, + .enable_turbo = power_acpi_enable_turbo, + .disable_turbo = power_acpi_disable_turbo, + .get_caps = power_acpi_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (acpi_ops);
drivers/power/acpi/acpi_cpufreq.h renamed from lib/power/power_acpi_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_ACPI_CPUFREQ_H -#define _POWER_ACPI_CPUFREQ_H +#ifndef _ACPI_CPUFREQ_H +#define _ACPI_CPUFREQ_H/** * @file * RTE Power Management via userspace ACPI cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if ACPI power management is supported.
drivers/power/acpi/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('acpi_cpufreq.c') + +deps += ['power']
drivers/power/amd_pstate/amd_pstate_cpufreq.c renamed from lib/power/power_amd_pstate_cpufreq.c +22 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ #include <stdlib.h>
@@ -9,7 +9,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_amd_pstate_cpufreq.h" +#include "amd_pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 1000 */
@@ -710,3 +710,23 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops amd_pstate_ops = { + .name ="amd-pstate" , + .init = power_amd_pstate_cpufreq_init, + .exit = power_amd_pstate_cpufreq_exit, + .check_env_support = power_amd_pstate_cpufreq_check_supported, + .get_avail_freqs = power_amd_pstate_cpufreq_freqs, + .get_freq = power_amd_pstate_cpufreq_get_freq, + .set_freq = power_amd_pstate_cpufreq_set_freq, + .freq_down = power_amd_pstate_cpufreq_freq_down, + .freq_up = power_amd_pstate_cpufreq_freq_up, + .freq_max = power_amd_pstate_cpufreq_freq_max, + .freq_min = power_amd_pstate_cpufreq_freq_min, + .turbo_status = power_amd_pstate_turbo_status, + .enable_turbo = power_amd_pstate_enable_turbo, + .disable_turbo = power_amd_pstate_disable_turbo, + .get_caps = power_amd_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (amd_pstate_ops);
drivers/power/amd_pstate/amd_pstate_cpufreq.h renamed from lib/power/power_amd_pstate_cpufreq.h +5 -5
@@ -1,18 +1,18 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2021 Intel Corporation * Copyright(c) 2021 Arm Limited -* Copyright(c) 2023 Amd Limited +* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _POWER_AMD_PSTATE_CPUFREQ_H -#define _POWER_AMD_PSTATE_CPUFREQ_H +#ifndef _AMD_PSTATE_CPUFREQ_H +#define _AMD_PSTATE_CPUFREQ_H/** * @file * RTE Power Management via userspace AMD pstate cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if amd p-state power management is supported.
@@ -216,4 +216,4 @@ int power_amd_pstate_disable_turbo(unsigned int lcore_id);int power_amd_pstate_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_AMD_PSTATET_CPUFREQ_H */ +#endif /* _AMD_PSTATET_CPUFREQ_H */
drivers/power/amd_pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('amd_pstate_cpufreq.c') + +deps += ['power']
drivers/power/cppc/cppc_cpufreq.c renamed from lib/power/power_cppc_cpufreq.c +21 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> #include <rte_stdatomic.h> -#include "power_cppc_cpufreq.h" +#include "cppc_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -695,3 +695,23 @@ power_cppc_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops cppc_ops = { + .name ="cppc" , + .init = power_cppc_cpufreq_init, + .exit = power_cppc_cpufreq_exit, + .check_env_support = power_cppc_cpufreq_check_supported, + .get_avail_freqs = power_cppc_cpufreq_freqs, + .get_freq = power_cppc_cpufreq_get_freq, + .set_freq = power_cppc_cpufreq_set_freq, + .freq_down = power_cppc_cpufreq_freq_down, + .freq_up = power_cppc_cpufreq_freq_up, + .freq_max = power_cppc_cpufreq_freq_max, + .freq_min = power_cppc_cpufreq_freq_min, + .turbo_status = power_cppc_turbo_status, + .enable_turbo = power_cppc_enable_turbo, + .disable_turbo = power_cppc_disable_turbo, + .get_caps = power_cppc_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (cppc_ops);
drivers/power/cppc/cppc_cpufreq.h renamed from lib/power/power_cppc_cpufreq.h +4 -4
@@ -3,15 +3,15 @@* Copyright(c) 2021 Arm Limited */ -#ifndef _POWER_CPPC_CPUFREQ_H -#define _POWER_CPPC_CPUFREQ_H +#ifndef _CPPC_CPUFREQ_H +#define _CPPC_CPUFREQ_H/** * @file * RTE Power Management via userspace CPPC cpufreq */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if CPPC power management is supported.
@@ -215,4 +215,4 @@ int power_cppc_disable_turbo(unsigned int lcore_id);int power_cppc_get_capabilities (unsigned int lcore_id,struct rte_power_core_capabilities *caps); -#endif /* _POWER_CPPC_CPUFREQ_H */ +#endif /* _CPPC_CPUFREQ_H */
drivers/power/cppc/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('cppc_cpufreq.c') + +deps += ['power']
drivers/power/kvm_vm/guest_channel.c renamed from lib/power/guest_channel.c +1 -1
@@ -13,7 +13,7 @@#include <rte_log.h> -#include <rte_power.h> +#include <rte_power_guest_channel.h> #include "guest_channel.h"
drivers/power/kvm_vm/guest_channel.h renamed from lib/power/guest_channel.h +0 -0
drivers/power/kvm_vm/kvm_vm.c renamed from lib/power/power_kvm_vm.c +21 -1
@@ -9,7 +9,7 @@#include "rte_power_guest_channel.h" #include "guest_channel.h" #include "power_common.h" -#include "power_kvm_vm.h" +#include "kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -137,3 +137,23 @@ int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,POWER_LOG (ERR ,"rte_power_get_capabilities is not implemented for Virtual Machine Power Management" );return -ENOTSUP ; } + +static struct rte_power_cpufreq_ops kvm_vm_ops = { + .name ="kvm-vm" , + .init = power_kvm_vm_init, + .exit = power_kvm_vm_exit, + .check_env_support = power_kvm_vm_check_supported, + .get_avail_freqs = power_kvm_vm_freqs, + .get_freq = power_kvm_vm_get_freq, + .set_freq = power_kvm_vm_set_freq, + .freq_down = power_kvm_vm_freq_down, + .freq_up = power_kvm_vm_freq_up, + .freq_max = power_kvm_vm_freq_max, + .freq_min = power_kvm_vm_freq_min, + .turbo_status = power_kvm_vm_turbo_status, + .enable_turbo = power_kvm_vm_enable_turbo, + .disable_turbo = power_kvm_vm_disable_turbo, + .get_caps = power_kvm_vm_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (kvm_vm_ops);
drivers/power/kvm_vm/kvm_vm.h renamed from lib/power/power_kvm_vm.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2010-2014 Intel Corporation */ -#ifndef _POWER_KVM_VM_H -#define _POWER_KVM_VM_H +#ifndef _KVM_VM_H +#define _KVM_VM_H/** * @file * RTE Power Management KVM VM */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if KVM power management is supported.
drivers/power/kvm_vm/meson.build new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif +sources = files( + 'guest_channel.c', + 'kvm_vm.c', +) + +deps += ['power']
drivers/power/meson.build new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +drivers = [ + 'acpi', + 'amd_pstate', + 'cppc', + 'kvm_vm', + 'pstate' +] + +std_deps = ['power']
drivers/power/pstate/meson.build new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif +sources = files('pstate_cpufreq.c') + +deps += ['power']
drivers/power/pstate/pstate_cpufreq.c renamed from lib/power/power_pstate_cpufreq.c +21 -1
@@ -15,7 +15,7 @@#include <rte_stdatomic.h> #include "rte_power_pmd_mgmt.h" -#include "power_pstate_cpufreq.h" +#include "pstate_cpufreq.h" #include "power_common.h" /* macros used for rounding frequency to nearest 100000 */
@@ -898,3 +898,23 @@ int power_pstate_get_capabilities(unsigned int lcore_id,return 0 ; } + +static struct rte_power_cpufreq_ops pstate_ops = { + .name ="pstate" , + .init = power_pstate_cpufreq_init, + .exit = power_pstate_cpufreq_exit, + .check_env_support = power_pstate_cpufreq_check_supported, + .get_avail_freqs = power_pstate_cpufreq_freqs, + .get_freq = power_pstate_cpufreq_get_freq, + .set_freq = power_pstate_cpufreq_set_freq, + .freq_down = power_pstate_cpufreq_freq_down, + .freq_up = power_pstate_cpufreq_freq_up, + .freq_max = power_pstate_cpufreq_freq_max, + .freq_min = power_pstate_cpufreq_freq_min, + .turbo_status = power_pstate_turbo_status, + .enable_turbo = power_pstate_enable_turbo, + .disable_turbo = power_pstate_disable_turbo, + .get_caps = power_pstate_get_capabilities +}; + +RTE_POWER_REGISTER_CPUFREQ_OPS (pstate_ops);
drivers/power/pstate/pstate_cpufreq.h renamed from lib/power/power_pstate_cpufreq.h +3 -3
@@ -2,15 +2,15 @@* Copyright(c) 2018 Intel Corporation */ -#ifndef _POWER_PSTATE_CPUFREQ_H -#define _POWER_PSTATE_CPUFREQ_H +#ifndef _PSTATE_CPUFREQ_H +#define _PSTATE_CPUFREQ_H/** * @file * RTE Power Management via Intel Pstate driver */ -#include "rte_power.h" +#include "power_cpufreq.h" /** * Check if pstate power management is supported.
lib/power/meson.build +1 -6
@@ -12,19 +12,14 @@ if not is_linux reason = 'only supported on Linux' endif sources = files( - 'guest_channel.c', - 'power_acpi_cpufreq.c', - 'power_amd_pstate_cpufreq.c', 'power_common.c', - 'power_cppc_cpufreq.c', - 'power_kvm_vm.c', 'power_intel_uncore.c', - 'power_pstate_cpufreq.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( + 'power_cpufreq.h', 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h',
lib/power/power_common.c +1 -1
@@ -13,7 +13,7 @@#include "power_common.h" -RTE_LOG_REGISTER_DEFAULT (power_logtype,INFO ); +RTE_LOG_REGISTER_DEFAULT (rte_power_logtype,INFO );#define POWER_SYSFILE_SCALING_DRIVER \ "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
lib/power/power_common.h +16 -2
@@ -6,12 +6,13 @@#define _POWER_COMMON_H_#include <rte_common.h> +#include <rte_compat.h> #include <rte_log.h> #define RTE_POWER_INVALID_FREQ_INDEX (~0) -extern int power_logtype; -#define RTE_LOGTYPE_POWER power_logtype +extern int rte_power_logtype; +#define RTE_LOGTYPE_POWER rte_power_logtype#define POWER_LOG (level, ...) \ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)
@@ -23,14 +24,27 @@ extern int power_logtype;#endif /* check if scaling driver matches one we want */ +__rte_internal int cpufreq_check_scaling_driver(const char *driver); + +__rte_internal int power_set_governor(unsigned int lcore_id, const char *new_governor,char *orig_governor,size_t orig_governor_len); + +__rte_internal int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...) __rte_format_printf(3, 4); + +__rte_internal int read_core_sysfs_u32(FILE *f, uint32_t *val); + +__rte_internal int read_core_sysfs_s(FILE *f, char *buf, unsigned int len); + +__rte_internal int write_core_sysfs_s(FILE *f, const char *str); + +__rte_internal int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);#endif /* _POWER_COMMON_H_ */
lib/power/power_cpufreq.h new file +191 -0
191 lines not on this page · raw message
lib/power/rte_power.c +164 -194
412 lines not on this page · raw message
lib/power/rte_power.h +71 -45
199 lines not on this page · raw message
lib/power/version.map +14 -0
@@ -52,3 +52,17 @@ EXPERIMENTAL { rte_power_uncore_freqs; rte_power_unset_uncore_env; }; + +INTERNAL { + global: + + rte_power_register_cpufreq_ops; + rte_power_logtype; + cpufreq_check_scaling_driver; + power_get_lcore_mapped_cpu_id; + power_set_governor; + open_core_sysfs_file; + read_core_sysfs_u32; + read_core_sysfs_s; + write_core_sysfs_s; +};
Signature · 1 line
2.34.1
Re: [PATCH v10 1/6] power: refactor core power management library
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 11 lines
drivers/meson.build | 1 + .../power/acpi/acpi_cpufreq.c | 22 +- .../power/acpi/acpi_cpufreq.h | 6 +- drivers/power/acpi/meson.build | 10 + .../power/amd_pstate/amd_pstate_cpufreq.c | 24 +- .../power/amd_pstate/amd_pstate_cpufreq.h | 10 +- drivers/power/amd_pstate/meson.build | 10 + .../power/cppc/cppc_cpufreq.c | 22 +- .../power/cppc/cppc_cpufreq.h | 8 +- drivers/power/cppc/meson.build | 10 + .../power/kvm_vm}/guest_channel.c | 2 +-
Quoted 8 lines
.../power/kvm_vm}/guest_channel.h | 0 .../power/kvm_vm/kvm_vm.c | 22 +- .../power/kvm_vm/kvm_vm.h | 6 +- drivers/power/kvm_vm/meson.build | 14 + drivers/power/meson.build | 12 + drivers/power/pstate/meson.build | 10 + .../power/pstate/pstate_cpufreq.c | 22 +- .../power/pstate/pstate_cpufreq.h | 6 +-
For consistency, we must name it intel_pstate, not just "pstate".
PATCH v10 2/6 power: refactor uncore power management library
In reply to Sivaprasad TummalaThis patch refactors the power management library, addressing uncore power management. The primary changes involve the creation of dedicated directories for each driver within 'drivers/power/uncore/*'. The adjustment of meson.build files enables the selective activation of individual drivers.
This refactor significantly improves code organization, enhances clarity and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
v10:
- removed unused header inclusions
- fixed rte_power_register_uncore_ops API description
v9:
- documentation update
v8:
- removed c++ guards for internal header files
- renamed rte_power_uncore_ops.h for naming convention
v7:
- fixed build error with aarch32 gcc cross compilation
v6:
- fixed compilation error with symbol export in API
v5:
- fixed build errors for risc-v/ppc targets
v4:
- fixed build error with RTE_ASSERT
--- doc/guides/prog_guide/power_man.rst | 10 +- .../power/intel_uncore/intel_uncore.c | 18 +- .../power/intel_uncore/intel_uncore.h | 9 +- drivers/power/intel_uncore/meson.build | 6 + drivers/power/meson.build | 3 +- lib/power/meson.build | 2 +- lib/power/power_uncore_ops.h | 244 +++++++++++++++++ lib/power/rte_power_uncore.c | 259 +++++++++--------- lib/power/rte_power_uncore.h | 61 ++--- lib/power/version.map | 1 + 10 files changed, 440 insertions(+), 173 deletions(-) rename lib/power/power_intel_uncore.c => drivers/power/intel_uncore/intel_uncore.c (95%) rename lib/power/power_intel_uncore.h => drivers/power/intel_uncore/intel_uncore.h (97%) create mode 100644 drivers/power/intel_uncore/meson.build create mode 100644 lib/power/power_uncore_ops.h
doc/guides/prog_guide/power_man.rst +5 -5
@@ -191,8 +191,8 @@ API Overview for Ethernet PMD Power Management * **Set Scaling Max Freq**: Set the maximum frequency (kHz) to be used in Frequency Scaling mode. -Intel Uncore API ----------------- +Uncore API +---------- Abstract ~~~~~~~~
@@ -211,10 +211,10 @@ which was added in 5.6. This manipulates the context of MSR 0x620, which sets min/max of the uncore for the SKU. -API Overview for Intel Uncore -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Uncore API Overview +~~~~~~~~~~~~~~~~~~~ -Overview of each function in the Intel Uncore API, +Overview of each function in the Uncore API, with explanation of what they do. Each function should not be called in the fast path.
drivers/power/intel_uncore/intel_uncore.c renamed from lib/power/power_intel_uncore.c +17 -1
@@ -8,7 +8,7 @@#include <rte_memcpy.h> -#include "power_intel_uncore.h" +#include "intel_uncore.h" #include "power_common.h" #define MAX_NUMA_DIE 8
@@ -475,3 +475,19 @@ power_intel_uncore_get_num_dies(unsigned int pkg)return count; } + +static struct rte_power_uncore_ops intel_uncore_ops = { + .name ="intel-uncore" , + .init = power_intel_uncore_init, + .exit = power_intel_uncore_exit, + .get_avail_freqs = power_intel_uncore_freqs, + .get_num_pkgs = power_intel_uncore_get_num_pkgs, + .get_num_dies = power_intel_uncore_get_num_dies, + .get_num_freqs = power_intel_uncore_get_num_freqs, + .get_freq = power_get_intel_uncore_freq, + .set_freq = power_set_intel_uncore_freq, + .freq_max = power_intel_uncore_freq_max, + .freq_min = power_intel_uncore_freq_min, +}; + +RTE_POWER_REGISTER_UNCORE_OPS (intel_uncore_ops);
drivers/power/intel_uncore/intel_uncore.h renamed from lib/power/power_intel_uncore.h +4 -5
@@ -2,16 +2,15 @@* Copyright(c) 2022 Intel Corporation */ -#ifndef POWER_INTEL_UNCORE_H -#define POWER_INTEL_UNCORE_H +#ifndef _INTEL_UNCORE_H +#define _INTEL_UNCORE_H /** * @file * RTE Intel Uncore Frequency Management */ -#include "rte_power.h" -#include "rte_power_uncore.h" +#include "power_uncore_ops.h" #ifdef __cplusplus extern "C" {
@@ -223,4 +222,4 @@ power_intel_uncore_get_num_dies(unsigned int pkg); }#endif -#endif /* POWER_INTEL_UNCORE_H */ +#endif /* _INTEL_UNCORE_H */
drivers/power/intel_uncore/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +sources = files('intel_uncore.c') +deps += ['power']
drivers/power/meson.build +2 -1
@@ -6,7 +6,8 @@ drivers = [ 'amd_pstate', 'cppc', 'kvm_vm', - 'pstate' + 'pstate', + 'intel_uncore' ] std_deps = ['power']
lib/power/meson.build +1 -1
@@ -13,13 +13,13 @@ if not is_linux endif sources = files( 'power_common.c', - 'power_intel_uncore.c', 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'power_cpufreq.h', + 'power_uncore_ops.h', 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h',
lib/power/power_uncore_ops.h new file +244 -0
244 lines not on this page · raw message
lib/power/rte_power_uncore.c +132 -127
317 lines not on this page · raw message
lib/power/rte_power_uncore.h +28 -33
125 lines not on this page · raw message
lib/power/version.map +1 -0
@@ -57,6 +57,7 @@ INTERNAL { global: rte_power_register_cpufreq_ops; + rte_power_register_uncore_ops; rte_power_logtype; cpufreq_check_scaling_driver; power_get_lcore_mapped_cpu_id;
Signature · 1 line
2.34.1
Re: [PATCH v10 2/6] power: refactor uncore power management library
Quoted 7 lines · On Mon, 28 Oct 2024 19:55:52 +0000 Sivaprasad Tummala…
lib/power/rte_power_uncore.c +7
-0+/* Auto Detect Environment */ + RTE_TAILQ_FOREACH(ops, &uncore_ops_list, next) +if (ops) { +POWER_LOG (INFO , +"Attempting to initialise %s power management..." , + ops->name); + ret = ops->init (pkg, die);
lib/power/rte_power_uncore.c void · line 127
Quoted 10 lines
lib/power/rte_power_uncore.c +9
-0+if (ret ==0 ) { +for (env =0 ; env <RTE_DIM (uncore_env_str); env++) +if (strncmp (ops->name, uncore_env_str[env], +RTE_POWER_UNCORE_DRIVER_NAMESZ ) ==0 ) { +rte_power_set_uncore_env (env); + goto out; + } + } + } out:
Static analyzer complains:lib/power/rte_power_uncore.c:113:1: warning: V547 Expression 'ops' is always true.
Since the macro RTE_TAILQ_FOREACH() iterates until ops is NULL, that whole if() part can be removed.
PATCH v10 3/6 test/power: removed function pointer validations
In reply to Sivaprasad TummalaAfter refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.
--- app/test/test_power.c | 95 ----------------------------------- app/test/test_power_cpufreq.c | 52 ------------------- app/test/test_power_kvm_vm.c | 36 ------------- examples/l3fwd-power/main.c | 12 ++--- 4 files changed, 4 insertions(+), 191 deletions(-)
app/test/test_power.c +0 -95
@@ -24,86 +24,6 @@ test_power(void)#include <rte_power.h> -static int -check_function_ptrs (void ) -{ -enum power_management_env env =rte_power_get_env (); - -const bool not_null_expected = !(env ==PM_ENV_NOT_SET ); - -const char *inject_not_string1 = not_null_expected ?" not" :"" ; -const char *inject_not_string2 = not_null_expected ?"" :" not" ; - -if ((rte_power_freqs ==NULL ) == not_null_expected) { -printf ("rte_power_freqs should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_freq ==NULL ) == not_null_expected) { -printf ("rte_power_get_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_set_freq ==NULL ) == not_null_expected) { -printf ("rte_power_set_freq should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_up ==NULL ) == not_null_expected) { -printf ("rte_power_freq_up should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_down ==NULL ) == not_null_expected) { -printf ("rte_power_freq_down should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_max ==NULL ) == not_null_expected) { -printf ("rte_power_freq_max should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_min ==NULL ) == not_null_expected) { -printf ("rte_power_freq_min should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_turbo_status ==NULL ) == not_null_expected) { -printf ("rte_power_turbo_status should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_enable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_enable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_freq_disable_turbo ==NULL ) == not_null_expected) { -printf ("rte_power_freq_disable_turbo should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } -if ((rte_power_get_capabilities ==NULL ) == not_null_expected) { -printf ("rte_power_get_capabilities should%s be NULL, environment has%s been " -"initialised\n" , inject_not_string1, - inject_not_string2); -return -1 ; - } - -return 0 ; -} -static int test_power (void ) {
@@ -124,10 +44,6 @@ test_power(void)return -1 ; } -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env ();/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void) return -1; } -/* Verify that function pointers are NOT NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; -rte_power_unset_env (); -/* Verify that function pointers are NULL */ -if (check_function_ptrs () <0 ) - goto fail_all; - }return 0 ; -fail_all: -rte_power_unset_env (); -return -1 ; }#endif
app/test/test_power_cpufreq.c +0 -52
58 lines not on this page · raw message
app/test/test_power_kvm_vm.c +0 -36
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)return -1 ; } -/* verify that function pointers are not NULL */ -if (rte_power_freqs ==NULL ) { -printf ("rte_power_freqs should not be NULL, environment has not been " -"initialised\n" ); -return -1 ; - } -if (rte_power_get_freq ==NULL ) { -printf ("rte_power_get_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_set_freq ==NULL ) { -printf ("rte_power_set_freq should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_up ==NULL ) { -printf ("rte_power_freq_up should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_down ==NULL ) { -printf ("rte_power_freq_down should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_max ==NULL ) { -printf ("rte_power_freq_max should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - } -if (rte_power_freq_min ==NULL ) { -printf ("rte_power_freq_min should not be NULL, environment has not " -"been initialised\n" ); -return -1 ; - }/* Test initialisation of an out of bounds lcore */ ret =rte_power_init (TEST_POWER_VM_LCORE_OUT_OF_BOUNDS );if (ret !=-1 ) {
examples/l3fwd-power/main.c +4 -8
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* check whether need to scale down frequency a step if it sleep a lot. */ if (sleep_time_ratio >=SCALING_DOWN_TIME_RATIO_THRESHOLD ) { -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }else if ( (unsigned )(stats[lcore_id].nb_rx_processed / stats[lcore_id].nb_iteration_looped) <MAX_PKT_BURST ) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,* scale down a step if average packet per iteration less * than expectation. */ -if (rte_power_freq_down) -rte_power_freq_down (lcore_id); +rte_power_freq_down (lcore_id); }/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy) }if (lcore_scaleup_hint ==FREQ_HIGHEST ) { -if (rte_power_freq_max) -rte_power_freq_max (lcore_id); +rte_power_freq_max (lcore_id); }else if (lcore_scaleup_hint ==FREQ_HIGHER ) { -if (rte_power_freq_up) -rte_power_freq_up (lcore_id); +rte_power_freq_up (lcore_id); } }else {/**
Signature · 1 line
2.34.1
Re: [PATCH v10 3/6] test/power: removed function pointer validations
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 8 lines
After refactoring the power library, power management operations are now consistently supported regardless of the operating environment, making function pointer checks unnecessary and thus removed from applications.
v2:
- removed function pointer validation in l3fwd-power app.Signed-off-by Sivaprasad Tummala <[email protected]>
This patch must be first, because the rework makes the compiler stops on this test.
PATCH v10 4/6 drivers/power: uncore support for AMD EPYC processors
In reply to Sivaprasad TummalaThis patch introduces driver support for power management of uncore components in AMD EPYC processors.
v9:
- documentation update
v2:
- fixed typo in comments section.
- added fabric frequency get support for legacy platforms.
--- doc/guides/prog_guide/power_man.rst | 14 ++ drivers/power/amd_uncore/amd_uncore.c | 329 ++++++++++++++++++++++++++ drivers/power/amd_uncore/amd_uncore.h | 225 ++++++++++++++++++ drivers/power/amd_uncore/meson.build | 20 ++ drivers/power/meson.build | 1 + 5 files changed, 589 insertions(+) create mode 100644 drivers/power/amd_uncore/amd_uncore.c create mode 100644 drivers/power/amd_uncore/amd_uncore.h create mode 100644 drivers/power/amd_uncore/meson.build
doc/guides/prog_guide/power_man.rst +14 -0
@@ -203,6 +203,8 @@ to achieve high performance: L3 cache, on-die memory controller, etc. Significant power savings can be achieved by reducing the uncore frequency to its lowest value. +Intel Uncore +~~~~~~~~~~~~ The Linux kernel provides the driver "intel-uncore-frequency" to control the uncore frequency limits for x86 platform. The driver is available from kernel version 5.6 and above.
@@ -211,6 +213,18 @@ which was added in 5.6. This manipulates the context of MSR 0x620, which sets min/max of the uncore for the SKU. +AMD EPYC Uncore +~~~~~~~~~~~~~~~ +On AMD EPYC platforms, the Host System Management Port (HSMP) kernel module +facilitates user-level access to HSMP mailboxes, which are implemented by +the firmware in the System Management Unit (SMU). +The AMD HSMP driver is available starting from kernel version 5.18. +Please ensure that CONFIG_AMD_HSMP is enabled in your kernel configuration. + +Additionally, the EPYC System Management Interface In-band Library for Linux +offers essential APIs, enabling user-space software to effectively manage +system functions. + Uncore API Overview ~~~~~~~~~~~~~~~~~~~
drivers/power/amd_uncore/amd_uncore.c new file +329 -0
329 lines not on this page · raw message
drivers/power/amd_uncore/amd_uncore.h new file +225 -0
225 lines not on this page · raw message
drivers/power/amd_uncore/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +ESMI_header = '#include<e_smi/e_smi.h>' +lib = cc.find_library('e_smi64', required: false) +if not lib.found() + build = false + reason = 'missing dependency, "libe_smi"' +else + ext_deps += lib +endif + +sources = files('amd_uncore.c') +deps += ['power']
drivers/power/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'cppc', 'kvm_vm', 'pstate', + 'amd_uncore', 'intel_uncore' ]
Signature · 1 line
2.34.1
Re: [PATCH v10 4/6] drivers/power: uncore support for AMD EPYC processors
28/10/2024 20:55, Sivaprasad Tummala:
drivers/power/amd_uncore/amd_uncore.h line 17
Quoted 5 lines
drivers/power/amd_uncore/amd_uncore.h new file +3
-0+#ifdef __cplusplus +extern "C" { +#endif
As said in previous versions, you don't need this in an internal header.
[...]
drivers/power/amd_uncore/amd_uncore.h line 225
Quoted 6 lines
drivers/power/amd_uncore/amd_uncore.h new file +6
-0+ +#ifdef __cplusplus +} +#endif + +#endif /* POWER_INTEL_UNCORE_H */
ah ah :)
PATCH v10 5/6 maintainers: update for drivers/power
In reply to Sivaprasad TummalaUpdate maintainers for drivers/power/*.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1753,6 +1753,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/* F: doc/guides/prog_guide/power_man.rst F: app/test/test_power* F: examples/l3fwd-power/
Signature · 1 line
2.34.1
Re: [PATCH v10 5/6] maintainers: update for drivers/power
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 12 lines
Update maintainers for
drivers/power/*.Signed-off-by Sivaprasad Tummala <[email protected]>--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)MAINTAINERS +0
-0
MAINTAINERS M: Anatoly Burakov <[email protected]> · line 1756
Quoted 4 lines
MAINTAINERS +1
-0@@ -1753,6 +1753,7 @@ M: Anatoly Burakov <[email protected]> M: David Hunt <[email protected]> M: Sivaprasad Tummala <[email protected]> F: lib/power/ +F: drivers/power/*
You must not add this wildcard, it does not work.
And this patch can be squashed in the rework.
PATCH v10 6/6 power: rename library sources for cpu frequency management
In reply to Sivaprasad TummalaThis patch renames the existing core power library source files from rte_power.* to rte_power_cpufreq.* for better clarity
v9:
- documentation update
---
app/test/test_power.c | 2 +-
app/test/test_power_cpufreq.c | 2 +-
app/test/test_power_kvm_vm.c | 2 +-
doc/api/doxy-api-index.md | 2 +-
examples/distributor/main.c | 2 +-
examples/l3fwd-power/main.c | 2 +-
examples/l3fwd-power/perf_core.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/channel_monitor.h | 2 +-
examples/vm_power_manager/guest_cli/main.c | 2 +-
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c | 2 +-
examples/vm_power_manager/power_manager.c | 2 +-
lib/power/meson.build | 4 ++--
lib/power/{rte_power.c => rte_power_cpufreq.c} | 2 +-
lib/power/{rte_power.h => rte_power_cpufreq.h} | 4 ++--
lib/power/rte_power_pmd_mgmt.h | 2 +-
16 files changed, 18 insertions(+), 18 deletions(-)
rename lib/power/{rte_power.c => rte_power_cpufreq.c} (99%)
rename lib/power/{rte_power.h => rte_power_cpufreq.h} (99%)app/test/test_power.c +1 -1
@@ -22,7 +22,7 @@ test_power(void)#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> static int test_power (void )
app/test/test_power_cpufreq.c +1 -1
@@ -30,7 +30,7 @@ test_power_caps(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_LCORE_ID 2U#define TEST_POWER_LCORE_INVALID ((unsigned)RTE_MAX_LCORE)
app/test/test_power_kvm_vm.c +1 -1
@@ -20,7 +20,7 @@ test_power_kvm_vm(void) }#else -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define TEST_POWER_VM_LCORE_ID 0U#define TEST_POWER_VM_LCORE_OUT_OF_BOUNDS (RTE_MAX_LCORE+1)
doc/api/doxy-api-index.md +1 -1
@@ -102,7 +102,7 @@ The public API headers are grouped by topics: [per-lcore](@ref rte_per_lcore.h), [service cores](@ref rte_service.h), [keepalive](@ref rte_keepalive.h), - [power/freq](@ref rte_power.h), + [power/freq](@ref rte_power_cpufreq.h), [power/uncore](@ref rte_power_uncore.h), [PMD power](@ref rte_power_pmd_mgmt.h)
examples/distributor/main.c +1 -1
@@ -17,7 +17,7 @@#include <rte_prefetch.h> #include <rte_distributor.h> #include <rte_pause.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #define RX_RING_SIZE 1024#define TX_RING_SIZE 1024
examples/l3fwd-power/main.c +1 -1
@@ -41,7 +41,7 @@#include <rte_udp.h> #include <rte_string_fns.h> #include <rte_timer.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include <rte_metrics.h> #include <rte_telemetry.h>
examples/l3fwd-power/perf_core.c +1 -1
@@ -10,7 +10,7 @@#include <rte_common.h> #include <rte_memory.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_string_fns.h> #include "perf_core.h"
examples/vm_power_manager/channel_monitor.c +1 -1
@@ -31,7 +31,7 @@#ifdef RTE_NET_I40E #include <rte_pmd_i40e.h> #endif -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <libvirt/libvirt.h> #include "channel_monitor.h"
examples/vm_power_manager/channel_monitor.h +1 -1
@@ -5,7 +5,7 @@#ifndef CHANNEL_MONITOR_H_ #define CHANNEL_MONITOR_H_ -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "channel_manager.h"
examples/vm_power_manager/guest_cli/main.c +1 -1
@@ -9,7 +9,7 @@#include <string.h> #include <rte_lcore.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_debug.h> #include <rte_eal.h> #include <rte_log.h>
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +1 -1
@@ -18,7 +18,7 @@#include <rte_lcore.h> #include <rte_ethdev.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include "vm_power_cli_guest.h"
examples/vm_power_manager/power_manager.c +1 -1
@@ -15,7 +15,7 @@#include <sys/types.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #include <rte_spinlock.h> #include "channel_manager.h"
lib/power/meson.build +2 -2
@@ -13,14 +13,14 @@ if not is_linux endif sources = files( 'power_common.c', - 'rte_power.c', + 'rte_power_cpufreq.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', ) headers = files( 'power_cpufreq.h', 'power_uncore_ops.h', - 'rte_power.h', + 'rte_power_cpufreq.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h',
lib/power/rte_power_cpufreq.c renamed from lib/power/rte_power.c +1 -1
@@ -5,7 +5,7 @@#include <rte_spinlock.h> #include <rte_debug.h> -#include "rte_power.h" +#include "rte_power_cpufreq.h" #include "power_common.h" static enum power_management_env global_default_env =PM_ENV_NOT_SET ;
lib/power/rte_power_cpufreq.h renamed from lib/power/rte_power.h +2 -2
@@ -3,8 +3,8 @@* Copyright(c) 2024 Advanced Micro Devices, Inc. */ -#ifndef _RTE_POWER_H -#define _RTE_POWER_H +#ifndef _RTE_POWER_CPUFREQ_H +#define _RTE_POWER_CPUFREQ_H/** * @file
lib/power/rte_power_pmd_mgmt.h +1 -1
@@ -13,7 +13,7 @@#include <stdint.h> #include <rte_log.h> -#include <rte_power.h> +#include <rte_power_cpufreq.h> #ifdef __cplusplusextern "C" {
Signature · 1 line
2.34.1
Thomas Monjalon
Applied28/10/2024 20:55, Sivaprasad Tummala:
Quoted 14 lines
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Quoted 7 lines
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validationsdrivers/power: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
power: rename library sources for cpu frequency management
I'm a bit sad there is not more reviews.
I've moved the pointers check removal first, renamed intel_pstate files (not the functions), fixed few things like __cplusplus, include guards, sorting and maintainers file.
Applied
Quoted 23 lines · On Sun, 10 Nov 2024 19:35:55 +0100 Thomas Monjalon <[email protected]> wrote:
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 14 lines
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Quoted 7 lines
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validationsdrivers/power: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
power: rename library sources for cpu frequency management
Quoted 10 lines
I'm a bit sad there is not more reviews.
I've moved the pointers check removal first, renamed
intel_pstatefiles (not the functions), fixed few things like__cplusplus, include guards, sorting and maintainers file.Applied
I think this broke the build. The next unrelated change in CI is failing. Fixing the initialization in mlx5 patch failed.
-------------------------------BEGIN LOGS----------------------------
####################################################################################
#### [Begin job log] "ubuntu-22.04-gcc-stdatomic" at step Build and test
####################################################################################
Message: drivers/event/skeleton: Defining dependency "event_skeleton"
Message: drivers/event/sw: Defining dependency "event_sw"
Message: drivers/event/octeontx: Defining dependency "event_octeontx" Run-time dependency flexran_sdk_ldpc_decoder_5gnr found: NO (tried pkgconfig and cmake)
Message: drivers/baseband/acc: Defining dependency "baseband_acc"
Message: drivers/baseband/fpga_5gnr_fec: Defining dependency "baseband_fpga_5gnr_fec"
Message: drivers/baseband/fpga_lte_fec: Defining dependency "baseband_fpga_lte_fec"
Message: drivers/baseband/la12xx: Defining dependency "baseband_la12xx"
Message: drivers/baseband/null: Defining dependency "baseband_null" Run-time dependency flexran_sdk_turbo found: NO (tried pkgconfig and cmake) Run-time dependency flexran_sdk_ldpc_decoder_5gnr found: NO (tried pkgconfig and cmake)
Message: drivers/baseband/turbo_sw: Defining dependency "baseband_turbo_sw" Has header "cuda.h" : NO
Message: drivers/power/acpi: Defining dependency "power_acpi"
Message: drivers/power/amd_pstate: Defining dependency "power_amd_pstate" Library e_smi64 found: NO
Message: drivers/power/cppc: Defining dependency "power_cppc"
Message: drivers/power/intel_pstate: Defining dependency "power_intel_pstate"
Message: drivers/power/intel_uncore: Defining dependency "power_intel_uncore"
Message: drivers/power/kvm_vm: Defining dependency "power_kvm_vm"
drivers/meson.build:132:8: ERROR: Include dir power/pstate does not exist.
A full log can be found at /home/runner/work/dpdk/dpdk/build/meson-logs/meson-log.txt ##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "ubuntu-22.04-gcc-stdatomic" at step Build and test
####################################################################################
10/11/2024 20:29, Stephen Hemminger:
Quoted 33 lines
Quoted 30 lines · On Sun, 10 Nov 2024 19:35:55 +0100 Thomas Monjalon <[email protected]> wrote:
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 14 lines
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Quoted 7 lines
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validationsdrivers/power: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
power: rename library sources for cpu frequency managementI'm a bit sad there is not more reviews.
I've moved the pointers check removal first, renamed
intel_pstatefiles (not the functions), fixed few things like__cplusplus, include guards, sorting and maintainers file.
Quoted 6 lines
Quoted 3 lines
Applied
I think this broke the build. The next unrelated change in CI is failing. Fixing the initialization in mlx5 patch failed.
Indeed.
Thanks for the notice.
It should be fixed now.
Hello Siva, Thomas,
Quoted 24 lines · Thomas Monjalon
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 14 lines
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Quoted 7 lines
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validationsdrivers/power: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
power: rename library sources for cpu frequency management
Quoted 8 lines
I'm a bit sad there is not more reviews.
I've moved the pointers check removal first, renamed
intel_pstatefiles (not the functions), fixed few things like__cplusplus, include guards, sorting and maintainers file.Applied
This series breaks compilation of the vm_power_manager example as the "guest channel" API symbols are not provided by the power library (itself) anymore.
ninja: Entering directory `/home/dmarchan/builds/main/build-gcc-shared'
[3355/3373] Linking target examples/dpdk-guest_cli
FAILED: examples/dpdk-guest_cli
gcc -o examples/dpdk-guest_cliexamples/dpdk-guest_cli.p/vm_power_manager_guest_cli_main.c.o examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_parse.c.o examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o
-Wl,--as-needed -Wl,--no-undefined -Wl,--no-as-needed
-Wl,--undefined-version -pthread -Wl,--start-group -lm -ldl -lnuma
-lfdt '-Wl,-rpath,$ORIGIN/../lib'
-Wl,-rpath-link,/home/dmarchan/builds/main/build-gcc-shared/liblib/librte_eal.so.25.0 lib/librte_kvargs.so.25.0lib/librte_log.so.25.0 lib/librte_telemetry.so.25.0lib/librte_mempool.so.25.0 lib/librte_ring.so.25.0lib/librte_net.so.25.0 lib/librte_mbuf.so.25.0lib/librte_ethdev.so.25.0 lib/librte_meter.so.25.0lib/librte_cmdline.so.25.0 lib/librte_power.so.25.0lib/librte_timer.so.25.0 -lpcap -lvirt /usr/lib64/libbsd.so/usr/lib64/libarchive.so -Wl,--end-group/usr/bin/ld: examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `check_response_cmd':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:382:
undefined reference to `rte_power_guest_channel_receive_msg'/usr/bin/ld: examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `query_data':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:147:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld: examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `receive_capabilities':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:271:
undefined reference to `rte_power_guest_channel_receive_msg'/usr/bin/ld: examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `send_policy':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:476:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld: examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `query_data':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:147:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld: examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `receive_freq_list':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:161:
undefined reference to `rte_power_guest_channel_receive_msg'
collect2: error: ld returned 1 exit status
[3357/3373] Generating drivers/rte_common_cnxk.sym_chk with a custom
command (wrapped by meson to capture output)
ninja: build stopped: subcommand failed.
Siva, please have a look quickly.
Here is a quick fix written before first coffee of the day:
$ git diff --cached
drivers/power/kvm_vm/meson.build +1 -0
@@ -10,5 +10,6 @@ sources = files( 'guest_channel.c', 'kvm_vm.c', ) +headers = files('rte_power_guest_channel.h') deps += ['power']
(quoted diff) +0 -0
b/drivers/power/kvm_vm/rte_power_guest_channel.h similarity index 100%
rename from lib/power/rte_power_guest_channel.h rename to drivers/power/kvm_vm/rte_power_guest_channel.h
drivers/power/kvm_vm/version.map new file +8 -0
@@ -0,0 +1,8 @@ +DPDK_25 { + global: + + rte_power_guest_channel_receive_msg; + rte_power_guest_channel_send_msg; + + local: *; +};
(quoted diff) +0 -0
b/examples/vm_power_manager/guest_cli/meson.build
index a69f809e3b..bc3916a170 100644
examples/vm_power_manager/guest_cli/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['power'] +deps += ['power', 'power/kvm_vm'] sources = files( 'main.c',
(quoted diff) +0 -0
b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c index 803b6d1f82..14d1f3dd95 100644
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +1 -0
@@ -19,6 +19,7 @@#include <rte_ethdev.h> #include <rte_power_cpufreq.h> +#include <rte_power_guest_channel.h> #include "vm_power_cli_guest.h"
(quoted diff) +0 -0
b/examples/vm_power_manager/meson.build
index b866d8fd54..1903b68ed9 100644
examples/vm_power_manager/meson.build +1 -1
@@ -6,7 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -deps += ['power'] +deps += ['power', 'power/kvm_vm'] if dpdk_conf.has('RTE_NET_BNXT') deps += ['net_bnxt']
lib/power/meson.build +0 -1
@@ -22,7 +22,6 @@ headers = files( 'power_cpufreq.h', 'power_uncore_ops.h', 'rte_power_cpufreq.h', - 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_qos.h', 'rte_power_uncore.h',
lib/power/rte_power_cpufreq.h +0 -1
@@ -13,7 +13,6 @@#include <rte_common.h> #include <rte_log.h> -#include <rte_power_guest_channel.h> #include "power_cpufreq.h"
lib/power/version.map +0 -2
@@ -16,8 +16,6 @@ DPDK_25 { rte_power_get_env; rte_power_get_freq; rte_power_get_uncore_freq; - rte_power_guest_channel_receive_msg; - rte_power_guest_channel_send_msg; rte_power_init; rte_power_pmd_mgmt_get_emptypoll_max; rte_power_pmd_mgmt_get_pause_duration;
Signature · 1 line
David Marchand
Quoted 89 lines · David Marchand
Hello Siva, Thomas,
Quoted 24 lines · Thomas Monjalon
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 14 lines
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Quoted 7 lines
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validationsdrivers/power: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
power: rename library sources for cpu frequency managementQuoted 8 lines
I'm a bit sad there is not more reviews.
I've moved the pointers check removal first, renamed
intel_pstatefiles (not the functions), fixed few things like__cplusplus, include guards, sorting and maintainers file.Applied
This series breaks compilation of the
vm_power_managerexample as the "guest channel" API symbols are not provided by the power library (itself) anymore.ninja: Entering directory `/home/dmarchan/builds/main/build-gcc-shared' [3355/3373] Linking target examples/dpdk-guest_cli
FAILED: examples/dpdk-guest_cli
gcc -o examples/dpdk-guest_cliexamples/dpdk-guest_cli.p/vm_power_manager_guest_cli_main.c.oexamples/dpdk-guest_cli.p/vm_power_manager_guest_cli_parse.c.oexamples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o(quoted diff) +0
-4-Wl,--as-needed -Wl,--no-undefined -Wl,--no-as-needed -Wl,--undefined-version -pthread -Wl,--start-group -lm -ldl -lnuma -lfdt '-Wl,-rpath,$ORIGIN/../lib' -Wl,-rpath-link,/home/dmarchan/builds/main/build-gcc-shared/lib
lib/librte_eal.so.25.0lib/librte_kvargs.so.25.0lib/librte_log.so.25.0lib/librte_telemetry.so.25.0lib/librte_mempool.so.25.0lib/librte_ring.so.25.0lib/librte_net.so.25.0lib/librte_mbuf.so.25.0lib/librte_ethdev.so.25.0lib/librte_meter.so.25.0lib/librte_cmdline.so.25.0lib/librte_power.so.25.0lib/librte_timer.so.25.0-lpcap -lvirt/usr/lib64/libbsd.so/usr/lib64/libarchive.so-Wl,--end-group/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `check_response_cmd':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:382:
undefined reference to `rte_power_guest_channel_receive_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `query_data':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:147:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `receive_capabilities':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:271:
undefined reference to `rte_power_guest_channel_receive_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `send_policy':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:476:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `query_data':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:147:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `receive_freq_list':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:161:
undefined reference to `rte_power_guest_channel_receive_msg'
collect2: error: ld returned 1 exit status
[3357/3373] Generatingdrivers/rte_common_cnxk.sym_chkwith a custom
command (wrapped by meson to capture output)
ninja: build stopped: subcommand failed.
Quoted 3 lines
Siva, please have a look quickly.
Here is a quick fix written before first coffee of the day.
I ended up sending this as a patch:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Signature · 1 line
David Marchand
[AMD Official Use Only - AMD Internal Distribution Only]
Hi David,
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, November 12, 2024 4:08 PM
To: Tummala, Sivaprasad <[email protected]>; Thomas Monjalon <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 0/6] power: refactor power management library
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 88 lines · David Marchand
Hello Siva, Thomas,
Quoted 24 lines · Thomas Monjalon
28/10/2024 20:55, Sivaprasad Tummala:
Quoted 14 lines
This patchset refactors the power management library, addressing both core and uncore power management. The primary changes involve the creation of dedicated directories for each driver within '
drivers/power/core/*' and 'drivers/power/uncore/*'.This refactor significantly improves code organization, enhances clarity, and boosts maintainability. It lays the foundation for more focused development on individual drivers and facilitates seamless integration of future enhancements, particularly the AMD uncore driver.
Furthermore, this effort aims to streamline code maintenance by consolidating common functions for cpufreq and cppc across various core drivers, thus reducing code duplication.
Quoted 7 lines
Sivaprasad Tummala (6):
power: refactor core power management library
power: refactor uncore power management library test/power: removed function pointer validationsdrivers/power: uncore support for AMD EPYC processors
maintainers: update fordrivers/power
power: rename library sources for cpu frequency managementQuoted 7 lines
I'm a bit sad there is not more reviews.
I've moved the pointers check removal first, renamed
intel_pstatefiles (not the functions), fixed few things like__cplusplus, include guards, sorting and maintainers file.Applied
This series breaks compilation of the
vm_power_managerexample as the "guest channel" API symbols are not provided by the power library (itself) anymore.ninja: Entering directory `/home/dmarchan/builds/main/build-gcc-shared' [3355/3373] Linking target examples/dpdk-guest_cli
FAILED: examples/dpdk-guest_cli
gcc -o examples/dpdk-guest_cliexamples/dpdk-guest_cli.p/vm_power_manager_guest_cli_main.c.oexamples/dpdk-guest_cli.p/vm_power_manager_guest_cli_parse.c.oexamples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_gues t.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--no-as-needed(quoted diff) +0
-3-Wl,--undefined-version -pthread -Wl,--start-group -lm -ldl -lnuma -lfdt '-Wl,-rpath,$ORIGIN/../lib' -Wl,-rpath-link,/home/dmarchan/builds/main/build-gcc-shared/lib
lib/librte_eal.so.25.0lib/librte_kvargs.so.25.0lib/librte_log.so.25.0lib/librte_telemetry.so.25.0lib/librte_mempool.so.25.0lib/librte_ring.so.25.0lib/librte_net.so.25.0lib/librte_mbuf.so.25.0lib/librte_ethdev.so.25.0lib/librte_meter.so.25.0lib/librte_cmdline.so.25.0lib/librte_power.so.25.0lib/librte_timer.so.25.0-lpcap -lvirt/usr/lib64/libbsd.so/usr/lib64/libarchive.so-Wl,--end-group/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `check_response_cmd':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:382:
undefined reference to `rte_power_guest_channel_receive_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `query_data':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:147:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `receive_capabilities':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:271:
undefined reference to `rte_power_guest_channel_receive_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `send_policy':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:476:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `query_data':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:147:
undefined reference to `rte_power_guest_channel_send_msg'/usr/bin/ld:examples/dpdk-guest_cli.p/vm_power_manager_guest_cli_vm_power_cli_guest.c.o:
in function `receive_freq_list':/home/dmarchan/builds/main/build-gcc-shared/../../../git/pub/dpdk.org/main/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c:161:
undefined reference to `rte_power_guest_channel_receive_msg'
collect2: error: ld returned 1 exit status [3357/3373] Generatingdrivers/rte_common_cnxk.sym_chkwith a custom command (wrapped by
meson to capture output)
ninja: build stopped: subcommand failed.
Quoted 3 lines
Siva, please have a look quickly.
Here is a quick fix written before first coffee of the day.
LGTM!
--
David Marchand