patch 'power: fix mapped lcore ID' has been queued to stable release 22.11.7
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Wed Oct 23 23:16:58 CEST 2024
Hi,
FYI, your patch has been queued to stable release 22.11.7
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 10/25/24. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable
This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/a73f3a97ff25752b7f1f64ae65860a2ad3d86e9b
Thanks.
Luca Boccassi
---
>From a73f3a97ff25752b7f1f64ae65860a2ad3d86e9b Mon Sep 17 00:00:00 2001
From: Sivaprasad Tummala <sivaprasad.tummala at amd.com>
Date: Fri, 18 Oct 2024 03:34:34 +0000
Subject: [PATCH] power: fix mapped lcore ID
[ upstream commit 5c9b07eeba55d527025f1f4945e2dbb366f21215 ]
This commit fixes an issue in the power library
related to using lcores mapped to different
physical cores (--lcores option in EAL).
Previously, the power library incorrectly accessed
CPU sysfs attributes for power management, treating
lcore IDs as CPU IDs.
e.g. with --lcores '1 at 128', lcore_id '1' was interpreted
as CPU_id instead of '128'.
This patch corrects the cpu_id based on lcore and CPU
mappings. It also constraints power management support
for lcores mapped to multiple physical cores/threads.
When multiple lcores are mapped to the same physical core,
invoking frequency scaling APIs on any lcore will apply the
changes effectively.
Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")
Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala at amd.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
Acked-by: Huisong Li <lihuisong at huawei.com>
---
app/test/test_power_cpufreq.c | 21 ++++++++++++++++++---
lib/power/power_acpi_cpufreq.c | 6 +++++-
lib/power/power_common.c | 23 +++++++++++++++++++++++
lib/power/power_common.h | 1 +
lib/power/power_cppc_cpufreq.c | 6 +++++-
lib/power/power_pstate_cpufreq.c | 6 +++++-
6 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index 4d013cd7bb..051b9036dc 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <inttypes.h>
#include <rte_cycles.h>
+#include <rte_lcore.h>
#include "test.h"
@@ -46,9 +47,10 @@ test_power_caps(void)
static uint32_t total_freq_num;
static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
+static uint32_t cpu_id;
static int
-check_cur_freq(unsigned int lcore_id, uint32_t idx, bool turbo)
+check_cur_freq(__rte_unused unsigned int lcore_id, uint32_t idx, bool turbo)
{
#define TEST_POWER_CONVERT_TO_DECIMAL 10
#define MAX_LOOP 100
@@ -62,13 +64,13 @@ check_cur_freq(unsigned int lcore_id, uint32_t idx, bool turbo)
int i;
if (snprintf(fullpath, sizeof(fullpath),
- TEST_POWER_SYSFILE_CPUINFO_FREQ, lcore_id) < 0) {
+ TEST_POWER_SYSFILE_CPUINFO_FREQ, cpu_id) < 0) {
return 0;
}
f = fopen(fullpath, "r");
if (f == NULL) {
if (snprintf(fullpath, sizeof(fullpath),
- TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) {
+ TEST_POWER_SYSFILE_SCALING_FREQ, cpu_id) < 0) {
return 0;
}
f = fopen(fullpath, "r");
@@ -486,6 +488,19 @@ test_power_cpufreq(void)
{
int ret = -1;
enum power_management_env env;
+ rte_cpuset_t lcore_cpus;
+
+ lcore_cpus = rte_lcore_cpuset(TEST_POWER_LCORE_ID);
+ if (CPU_COUNT(&lcore_cpus) != 1) {
+ printf("Power management doesn't support lcore %u mapping to %u CPUs\n",
+ TEST_POWER_LCORE_ID,
+ CPU_COUNT(&lcore_cpus));
+ return TEST_SKIPPED;
+ }
+ for (cpu_id = 0; cpu_id < CPU_SETSIZE; cpu_id++) {
+ if (CPU_ISSET(cpu_id, &lcore_cpus))
+ break;
+ }
/* Test initialisation of a valid lcore */
ret = rte_power_init(TEST_POWER_LCORE_ID);
diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c
index 6e57aca535..8068c6d98b 100644
--- a/lib/power/power_acpi_cpufreq.c
+++ b/lib/power/power_acpi_cpufreq.c
@@ -257,7 +257,11 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
return -1;
}
- pi->lcore_id = lcore_id;
+ if (power_get_lcore_mapped_cpu_id(lcore_id, &pi->lcore_id) < 0) {
+ RTE_LOG(ERR, POWER, "Cannot get CPU ID mapped for lcore %u", lcore_id);
+ return -1;
+ }
+
/* Check and set the governor */
if (power_set_governor_userspace(pi) < 0) {
RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
diff --git a/lib/power/power_common.c b/lib/power/power_common.c
index 1e09facb86..e2a8c33604 100644
--- a/lib/power/power_common.c
+++ b/lib/power/power_common.c
@@ -9,6 +9,7 @@
#include <rte_log.h>
#include <rte_string_fns.h>
+#include <rte_lcore.h>
#include "power_common.h"
@@ -202,3 +203,25 @@ out:
return ret;
}
+
+int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id)
+{
+ rte_cpuset_t lcore_cpus;
+ uint32_t cpu;
+
+ lcore_cpus = rte_lcore_cpuset(lcore_id);
+ if (CPU_COUNT(&lcore_cpus) != 1) {
+ RTE_LOG(ERR, POWER,
+ "Power library does not support lcore %u mapping to %u CPUs",
+ lcore_id, CPU_COUNT(&lcore_cpus));
+ return -1;
+ }
+
+ for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
+ if (CPU_ISSET(cpu, &lcore_cpus))
+ break;
+ }
+ *cpu_id = cpu;
+
+ return 0;
+}
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index c1c7139276..b928df941f 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -27,5 +27,6 @@ int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...)
int read_core_sysfs_u32(FILE *f, uint32_t *val);
int read_core_sysfs_s(FILE *f, char *buf, unsigned int len);
int write_core_sysfs_s(FILE *f, const char *str);
+int power_get_lcore_mapped_cpu_id(uint32_t lcore_id, uint32_t *cpu_id);
#endif /* _POWER_COMMON_H_ */
diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c
index d6cc58cb3b..9a77811087 100644
--- a/lib/power/power_cppc_cpufreq.c
+++ b/lib/power/power_cppc_cpufreq.c
@@ -361,7 +361,11 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
return -1;
}
- pi->lcore_id = lcore_id;
+ if (power_get_lcore_mapped_cpu_id(lcore_id, &pi->lcore_id) < 0) {
+ RTE_LOG(ERR, POWER, "Cannot get CPU ID mapped for lcore %u", lcore_id);
+ return -1;
+ }
+
/* Check and set the governor */
if (power_set_governor_userspace(pi) < 0) {
RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c
index 52aa64510e..baa1835fbc 100644
--- a/lib/power/power_pstate_cpufreq.c
+++ b/lib/power/power_pstate_cpufreq.c
@@ -563,7 +563,11 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
return -1;
}
- pi->lcore_id = lcore_id;
+ if (power_get_lcore_mapped_cpu_id(lcore_id, &pi->lcore_id) < 0) {
+ RTE_LOG(ERR, POWER, "Cannot get CPU ID mapped for lcore %u", lcore_id);
+ return -1;
+ }
+
/* Check and set the governor */
if (power_set_governor_performance(pi) < 0) {
RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
--
2.45.2
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2024-10-23 22:16:43.479862967 +0100
+++ 0078-power-fix-mapped-lcore-ID.patch 2024-10-23 22:16:40.555944919 +0100
@@ -1 +1 @@
-From 5c9b07eeba55d527025f1f4945e2dbb366f21215 Mon Sep 17 00:00:00 2001
+From a73f3a97ff25752b7f1f64ae65860a2ad3d86e9b Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 5c9b07eeba55d527025f1f4945e2dbb366f21215 ]
+
@@ -25 +26,0 @@
-Cc: stable at dpdk.org
@@ -31,8 +32,7 @@
- app/test/test_power_cpufreq.c | 21 ++++++++++++++++++---
- lib/power/power_acpi_cpufreq.c | 6 +++++-
- lib/power/power_amd_pstate_cpufreq.c | 6 +++++-
- lib/power/power_common.c | 23 +++++++++++++++++++++++
- lib/power/power_common.h | 1 +
- lib/power/power_cppc_cpufreq.c | 6 +++++-
- lib/power/power_pstate_cpufreq.c | 6 +++++-
- 7 files changed, 62 insertions(+), 7 deletions(-)
+ app/test/test_power_cpufreq.c | 21 ++++++++++++++++++---
+ lib/power/power_acpi_cpufreq.c | 6 +++++-
+ lib/power/power_common.c | 23 +++++++++++++++++++++++
+ lib/power/power_common.h | 1 +
+ lib/power/power_cppc_cpufreq.c | 6 +++++-
+ lib/power/power_pstate_cpufreq.c | 6 +++++-
+ 6 files changed, 57 insertions(+), 6 deletions(-)
@@ -41 +41 @@
-index 619b2811c6..edbd34424e 100644
+index 4d013cd7bb..051b9036dc 100644
@@ -80 +80 @@
-@@ -497,6 +499,19 @@ test_power_cpufreq(void)
+@@ -486,6 +488,19 @@ test_power_cpufreq(void)
@@ -101 +101 @@
-index abad53bef1..ae809fbb60 100644
+index 6e57aca535..8068c6d98b 100644
@@ -104,18 +104 @@
-@@ -264,7 +264,11 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
- return -1;
- }
-
-- pi->lcore_id = lcore_id;
-+ if (power_get_lcore_mapped_cpu_id(lcore_id, &pi->lcore_id) < 0) {
-+ POWER_LOG(ERR, "Cannot get CPU ID mapped for lcore %u", lcore_id);
-+ return -1;
-+ }
-+
- /* Check and set the governor */
- if (power_set_governor_userspace(pi) < 0) {
- POWER_LOG(ERR, "Cannot set governor of lcore %u to "
-diff --git a/lib/power/power_amd_pstate_cpufreq.c b/lib/power/power_amd_pstate_cpufreq.c
-index 4809d45a22..2b728eca18 100644
---- a/lib/power/power_amd_pstate_cpufreq.c
-+++ b/lib/power/power_amd_pstate_cpufreq.c
-@@ -382,7 +382,11 @@ power_amd_pstate_cpufreq_init(unsigned int lcore_id)
+@@ -257,7 +257,11 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
@@ -127 +110 @@
-+ POWER_LOG(ERR, "Cannot get CPU ID mapped for lcore %u", lcore_id);
++ RTE_LOG(ERR, POWER, "Cannot get CPU ID mapped for lcore %u", lcore_id);
@@ -133 +116 @@
- POWER_LOG(ERR, "Cannot set governor of lcore %u to "
+ RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
@@ -135 +118 @@
-index 590986d5ef..b47c63a5f1 100644
+index 1e09facb86..e2a8c33604 100644
@@ -146 +129 @@
-@@ -204,3 +205,25 @@ out:
+@@ -202,3 +203,25 @@ out:
@@ -158 +141 @@
-+ POWER_LOG(ERR,
++ RTE_LOG(ERR, POWER,
@@ -173 +156 @@
-index 83f742f42a..82fb94d0c0 100644
+index c1c7139276..b928df941f 100644
@@ -176 +159 @@
-@@ -31,5 +31,6 @@ int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...)
+@@ -27,5 +27,6 @@ int open_core_sysfs_file(FILE **f, const char *mode, const char *format, ...)
@@ -184 +167 @@
-index e73f4520d0..cc9305bdfe 100644
+index d6cc58cb3b..9a77811087 100644
@@ -187 +170 @@
-@@ -368,7 +368,11 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
+@@ -361,7 +361,11 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
@@ -193 +176 @@
-+ POWER_LOG(ERR, "Cannot get CPU ID mapped for lcore %u", lcore_id);
++ RTE_LOG(ERR, POWER, "Cannot get CPU ID mapped for lcore %u", lcore_id);
@@ -199 +182 @@
- POWER_LOG(ERR, "Cannot set governor of lcore %u to "
+ RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
@@ -201 +184 @@
-index 1c2a91a178..4755909466 100644
+index 52aa64510e..baa1835fbc 100644
@@ -204 +187 @@
-@@ -570,7 +570,11 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
+@@ -563,7 +563,11 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
@@ -210 +193 @@
-+ POWER_LOG(ERR, "Cannot get CPU ID mapped for lcore %u", lcore_id);
++ RTE_LOG(ERR, POWER, "Cannot get CPU ID mapped for lcore %u", lcore_id);
@@ -216 +199 @@
- POWER_LOG(ERR, "Cannot set governor of lcore %u to "
+ RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
More information about the stable
mailing list