* [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-06-10 23:28 ` Thomas Monjalon
2026-05-22 4:11 ` [PATCH v3 02/10] power: add a common macro to verify lcore ID Huisong Li
` (8 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
Add a new helper function rte_lcore_is_eal_managed() to determine
if a logical core is managed by EAL.
This interface returns true if the lcore role is either ROLE_RTE
(standard worker/main cores) or ROLE_SERVICE (service cores).
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
doc/guides/rel_notes/release_26_07.rst | 6 ++++++
lib/eal/common/eal_common_lcore.c | 11 +++++++++++
lib/eal/include/rte_lcore.h | 12 ++++++++++++
3 files changed, 29 insertions(+)
diff --git a/doc/guides/rel_notes/release_26_07.rst b/doc/guides/rel_notes/release_26_07.rst
index f012d47a4b..be5ccecd46 100644
--- a/doc/guides/rel_notes/release_26_07.rst
+++ b/doc/guides/rel_notes/release_26_07.rst
@@ -63,6 +63,12 @@ New Features
``rte_eal_init`` and the application is responsible for probing each device,
* ``--auto-probing`` enables the initial bus probing, which is the current default behavior.
+* **Added lcore EAL-managed status check.**
+
+ Added ``rte_lcore_is_eal_managed()`` helper function in EAL lcore library
+ to check whether a logical core is managed by EAL
+ (i.e., its role is ``ROLE_RTE`` or ``ROLE_SERVICE``).
+
Removed Items
-------------
diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c
index 39411f9370..ab7b5e8393 100644
--- a/lib/eal/common/eal_common_lcore.c
+++ b/lib/eal/common/eal_common_lcore.c
@@ -102,6 +102,17 @@ int rte_lcore_is_enabled(unsigned int lcore_id)
return cfg->lcore_role[lcore_id] == ROLE_RTE;
}
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_lcore_is_eal_managed, 26.07)
+int rte_lcore_is_eal_managed(unsigned int lcore_id)
+{
+ struct rte_config *cfg = rte_eal_get_configuration();
+
+ if (lcore_id >= RTE_MAX_LCORE)
+ return 0;
+ return cfg->lcore_role[lcore_id] == ROLE_RTE ||
+ cfg->lcore_role[lcore_id] == ROLE_SERVICE;
+}
+
RTE_EXPORT_SYMBOL(rte_get_next_lcore)
unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap)
{
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 10f965b4f0..9e6bb5230a 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -195,6 +195,18 @@ rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id);
*/
int rte_lcore_is_enabled(unsigned int lcore_id);
+/**
+ * Test if an lcore is ROLE_RTE or ROLE_SERVICE.
+ *
+ * @param lcore_id
+ * The identifier of the lcore, which MUST be between 0 and
+ * RTE_MAX_LCORE-1.
+ * @return
+ * True if the given lcore is ROLE_RTE or ROLE_SERVICE; false otherwise.
+ */
+__rte_experimental
+int rte_lcore_is_eal_managed(unsigned int lcore_id);
+
/**
* Get the next enabled lcore ID.
*
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed
2026-05-22 4:11 ` [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed Huisong Li
@ 2026-06-10 23:28 ` Thomas Monjalon
2026-06-11 6:16 ` lihuisong (C)
0 siblings, 1 reply; 15+ messages in thread
From: Thomas Monjalon @ 2026-06-10 23:28 UTC (permalink / raw)
To: Huisong Li
Cc: anatoly.burakov, sivaprasad.tummala, dev, stephen, fengchengwen,
yangxingui, zhanjie9, lihuisong
22/05/2026 06:11, Huisong Li:
> Add a new helper function rte_lcore_is_eal_managed() to determine
> if a logical core is managed by EAL.
>
> This interface returns true if the lcore role is either ROLE_RTE
> (standard worker/main cores) or ROLE_SERVICE (service cores).
[...]
> +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_lcore_is_eal_managed, 26.07)
> +int rte_lcore_is_eal_managed(unsigned int lcore_id)
> +{
> + struct rte_config *cfg = rte_eal_get_configuration();
> +
> + if (lcore_id >= RTE_MAX_LCORE)
> + return 0;
> + return cfg->lcore_role[lcore_id] == ROLE_RTE ||
> + cfg->lcore_role[lcore_id] == ROLE_SERVICE;
> +}
I'm not sure about adding this function in the API.
We already have rte_eal_lcore_role()
and I feel having this explicit ROLE_RTE || ROLE_SERVICE
in the code where needed may be less confusing.
Note: we should prefix these constants with RTE_LCORE_
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed
2026-06-10 23:28 ` Thomas Monjalon
@ 2026-06-11 6:16 ` lihuisong (C)
2026-06-11 9:10 ` Thomas Monjalon
0 siblings, 1 reply; 15+ messages in thread
From: lihuisong (C) @ 2026-06-11 6:16 UTC (permalink / raw)
To: Thomas Monjalon
Cc: anatoly.burakov, sivaprasad.tummala, dev, stephen, fengchengwen,
yangxingui, zhanjie9, lihuisong
Hi Thomas,
Thanks for your review.
On 6/11/2026 7:28 AM, Thomas Monjalon wrote:
> 22/05/2026 06:11, Huisong Li:
>> Add a new helper function rte_lcore_is_eal_managed() to determine
>> if a logical core is managed by EAL.
>>
>> This interface returns true if the lcore role is either ROLE_RTE
>> (standard worker/main cores) or ROLE_SERVICE (service cores).
> [...]
>> +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_lcore_is_eal_managed, 26.07)
>> +int rte_lcore_is_eal_managed(unsigned int lcore_id)
>> +{
>> + struct rte_config *cfg = rte_eal_get_configuration();
>> +
>> + if (lcore_id >= RTE_MAX_LCORE)
>> + return 0;
>> + return cfg->lcore_role[lcore_id] == ROLE_RTE ||
>> + cfg->lcore_role[lcore_id] == ROLE_SERVICE;
>> +}
> I'm not sure about adding this function in the API.
> We already have rte_eal_lcore_role()
> and I feel having this explicit ROLE_RTE || ROLE_SERVICE
> in the code where needed may be less confusing.
Ack.
>
> Note: we should prefix these constants with RTE_LCORE_
Yeah, it's good.
This will break API. And we can do this in 26.11.
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed
2026-06-11 6:16 ` lihuisong (C)
@ 2026-06-11 9:10 ` Thomas Monjalon
2026-06-15 1:08 ` lihuisong (C)
0 siblings, 1 reply; 15+ messages in thread
From: Thomas Monjalon @ 2026-06-11 9:10 UTC (permalink / raw)
To: lihuisong (C)
Cc: anatoly.burakov, sivaprasad.tummala, dev, stephen, fengchengwen,
yangxingui, zhanjie9
11/06/2026 08:16, lihuisong (C):
> On 6/11/2026 7:28 AM, Thomas Monjalon wrote:
> > 22/05/2026 06:11, Huisong Li:
> >> Add a new helper function rte_lcore_is_eal_managed() to determine
> >> if a logical core is managed by EAL.
> >>
> >> This interface returns true if the lcore role is either ROLE_RTE
> >> (standard worker/main cores) or ROLE_SERVICE (service cores).
> > [...]
> >> +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_lcore_is_eal_managed, 26.07)
> >> +int rte_lcore_is_eal_managed(unsigned int lcore_id)
> >> +{
> >> + struct rte_config *cfg = rte_eal_get_configuration();
> >> +
> >> + if (lcore_id >= RTE_MAX_LCORE)
> >> + return 0;
> >> + return cfg->lcore_role[lcore_id] == ROLE_RTE ||
> >> + cfg->lcore_role[lcore_id] == ROLE_SERVICE;
> >> +}
> > I'm not sure about adding this function in the API.
> > We already have rte_eal_lcore_role()
> > and I feel having this explicit ROLE_RTE || ROLE_SERVICE
> > in the code where needed may be less confusing.
>
> Ack.
>
> >
> > Note: we should prefix these constants with RTE_LCORE_
>
> Yeah, it's good.
>
> This will break API. And we can do this in 26.11.
We can keep the old names as aliases.
Better to not break the API, even in 26.11.
We could decide later, after some time, to remove the aliases.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed
2026-06-11 9:10 ` Thomas Monjalon
@ 2026-06-15 1:08 ` lihuisong (C)
0 siblings, 0 replies; 15+ messages in thread
From: lihuisong (C) @ 2026-06-15 1:08 UTC (permalink / raw)
To: Thomas Monjalon
Cc: anatoly.burakov, sivaprasad.tummala, dev, stephen, fengchengwen,
yangxingui, zhanjie9, lihuisong
On 6/11/2026 5:10 PM, Thomas Monjalon wrote:
> 11/06/2026 08:16, lihuisong (C):
>> On 6/11/2026 7:28 AM, Thomas Monjalon wrote:
>>> 22/05/2026 06:11, Huisong Li:
>>>> Add a new helper function rte_lcore_is_eal_managed() to determine
>>>> if a logical core is managed by EAL.
>>>>
>>>> This interface returns true if the lcore role is either ROLE_RTE
>>>> (standard worker/main cores) or ROLE_SERVICE (service cores).
>>> [...]
>>>> +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_lcore_is_eal_managed, 26.07)
>>>> +int rte_lcore_is_eal_managed(unsigned int lcore_id)
>>>> +{
>>>> + struct rte_config *cfg = rte_eal_get_configuration();
>>>> +
>>>> + if (lcore_id >= RTE_MAX_LCORE)
>>>> + return 0;
>>>> + return cfg->lcore_role[lcore_id] == ROLE_RTE ||
>>>> + cfg->lcore_role[lcore_id] == ROLE_SERVICE;
>>>> +}
>>> I'm not sure about adding this function in the API.
>>> We already have rte_eal_lcore_role()
>>> and I feel having this explicit ROLE_RTE || ROLE_SERVICE
>>> in the code where needed may be less confusing.
>> Ack.
>>
>>> Note: we should prefix these constants with RTE_LCORE_
>> Yeah, it's good.
>>
>> This will break API. And we can do this in 26.11.
> We can keep the old names as aliases.
> Better to not break the API, even in 26.11.
> We could decide later, after some time, to remove the aliases.
ok, sounds good.
Will do this in separated series.
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 02/10] power: add a common macro to verify lcore ID
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
2026-05-22 4:11 ` [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 03/10] power/cpufreq: add the lcore ID verification to framework Huisong Li
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
There are many places to verify lcore ID in power. So add a common macro
to do this to simplify code.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
lib/power/power_common.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index 3f56b1103d..78cebef59b 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -23,6 +23,13 @@ extern int rte_power_logtype;
#define POWER_DEBUG_LOG(...)
#endif
+#define RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, retval) do { \
+ if (!rte_lcore_is_eal_managed(lcore_id)) { \
+ POWER_LOG(ERR, "lcore id %u is invalid", lcore_id); \
+ return retval; \
+ } \
+} while (0)
+
/* check if scaling driver matches one we want */
__rte_internal
int cpufreq_check_scaling_driver(const char *driver);
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 03/10] power/cpufreq: add the lcore ID verification to framework
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
2026-05-22 4:11 ` [PATCH v3 01/10] eal: add interface to check if lcore is EAL managed Huisong Li
2026-05-22 4:11 ` [PATCH v3 02/10] power: add a common macro to verify lcore ID Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 04/10] power/acpi: remove redundant lcore ID checks Huisong Li
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
Currently, many cpufreq drivers verify the lcore ID in their
own driver and just restrict it to the RTE_MAX_LCORE range.
Actually, the lcore ID verification is common for each cpufreq
driver. It is better to add this verification to framework.
In addition, the lcore ID for cpufreq library is used by the
application and managed by the EAL layer. So this patch use
rte_lcore_is_eal_managed to verify the lcore ID in cpufreq
core.
Please note the lcore ID for cpufreq library must be ROLE_RTE
or ROLE_SERVICE after this patch.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
doc/guides/rel_notes/release_26_07.rst | 7 +++++++
lib/power/rte_power_cpufreq.c | 13 +++++++++++++
2 files changed, 20 insertions(+)
diff --git a/doc/guides/rel_notes/release_26_07.rst b/doc/guides/rel_notes/release_26_07.rst
index be5ccecd46..98a7cf0203 100644
--- a/doc/guides/rel_notes/release_26_07.rst
+++ b/doc/guides/rel_notes/release_26_07.rst
@@ -69,6 +69,13 @@ New Features
to check whether a logical core is managed by EAL
(i.e., its role is ``ROLE_RTE`` or ``ROLE_SERVICE``).
+* **Added lcore ID verification to power cpufreq framework.**
+
+ Added centralized lcore ID validation using ``rte_lcore_is_eal_managed()``
+ in the power cpufreq framework. All cpufreq API functions now verify
+ that the lcore ID is EAL-managed (``ROLE_RTE`` or ``ROLE_SERVICE``)
+ before proceeding, replacing per-driver range checks.
+
Removed Items
-------------
diff --git a/lib/power/rte_power_cpufreq.c b/lib/power/rte_power_cpufreq.c
index f63e976dc2..8394cbc77f 100644
--- a/lib/power/rte_power_cpufreq.c
+++ b/lib/power/rte_power_cpufreq.c
@@ -116,6 +116,7 @@ rte_power_init(unsigned int lcore_id)
struct rte_power_cpufreq_ops *ops;
uint8_t env;
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
if (global_default_env != PM_ENV_NOT_SET)
return global_cpufreq_ops->init(lcore_id);
@@ -147,6 +148,7 @@ RTE_EXPORT_SYMBOL(rte_power_exit)
int
rte_power_exit(unsigned int lcore_id)
{
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
if (global_default_env != PM_ENV_NOT_SET)
return global_cpufreq_ops->exit(lcore_id);
@@ -161,6 +163,7 @@ uint32_t
rte_power_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t n)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, 0);
return global_cpufreq_ops->get_avail_freqs(lcore_id, freqs, n);
}
@@ -169,6 +172,7 @@ uint32_t
rte_power_get_freq(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, RTE_POWER_INVALID_FREQ_INDEX);
return global_cpufreq_ops->get_freq(lcore_id);
}
@@ -177,6 +181,7 @@ uint32_t
rte_power_set_freq(unsigned int lcore_id, uint32_t index)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->set_freq(lcore_id, index);
}
@@ -185,6 +190,7 @@ int
rte_power_freq_up(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->freq_up(lcore_id);
}
@@ -193,6 +199,7 @@ int
rte_power_freq_down(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->freq_down(lcore_id);
}
@@ -201,6 +208,7 @@ int
rte_power_freq_max(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->freq_max(lcore_id);
}
@@ -209,6 +217,7 @@ int
rte_power_freq_min(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->freq_min(lcore_id);
}
@@ -217,6 +226,7 @@ int
rte_power_turbo_status(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->turbo_status(lcore_id);
}
@@ -225,6 +235,7 @@ int
rte_power_freq_enable_turbo(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->enable_turbo(lcore_id);
}
@@ -233,6 +244,7 @@ int
rte_power_freq_disable_turbo(unsigned int lcore_id)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->disable_turbo(lcore_id);
}
@@ -242,5 +254,6 @@ rte_power_get_capabilities(unsigned int lcore_id,
struct rte_power_core_capabilities *caps)
{
RTE_ASSERT(global_cpufreq_ops != NULL);
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -1);
return global_cpufreq_ops->get_caps(lcore_id, caps);
}
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 04/10] power/acpi: remove redundant lcore ID checks
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
` (2 preceding siblings ...)
2026-05-22 4:11 ` [PATCH v3 03/10] power/cpufreq: add the lcore ID verification to framework Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 05/10] power/amd_pstate: " Huisong Li
` (5 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
Now that the cpufreq framework validates the lcore ID using
rte_lcore_is_eal_managed() before dispatching to any driver,
each individual cpufreq driver no longer needs its own range
check against RTE_MAX_LCORE.
Remove the duplicated lcore ID checks from the acpi cpufreq
driver ops.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
drivers/power/acpi/acpi_cpufreq.c | 65 -------------------------------
1 file changed, 65 deletions(-)
diff --git a/drivers/power/acpi/acpi_cpufreq.c b/drivers/power/acpi/acpi_cpufreq.c
index 81a5e3f6ea..9c78b4cb1a 100644
--- a/drivers/power/acpi/acpi_cpufreq.c
+++ b/drivers/power/acpi/acpi_cpufreq.c
@@ -242,12 +242,6 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
return -1;
}
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
exp_state = POWER_IDLE;
/* The power in use state works as a guard variable between
@@ -319,11 +313,6 @@ power_acpi_cpufreq_exit(unsigned int lcore_id)
struct acpi_power_info *pi;
uint32_t exp_state;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
pi = &lcore_power_info[lcore_id];
exp_state = POWER_USED;
/* The power in use state works as a guard variable between
@@ -373,11 +362,6 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return 0;
- }
-
if (freqs == NULL) {
POWER_LOG(ERR, "NULL buffer supplied");
return 0;
@@ -396,22 +380,12 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
uint32_t
power_acpi_cpufreq_get_freq(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return RTE_POWER_INVALID_FREQ_INDEX;
- }
-
return lcore_power_info[lcore_id].curr_idx;
}
int
power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
return set_freq_internal(&(lcore_power_info[lcore_id]), index);
}
@@ -420,11 +394,6 @@ power_acpi_cpufreq_freq_down(unsigned int lcore_id)
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx + 1 == pi->nb_freqs)
return 0;
@@ -438,11 +407,6 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id)
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx == 0 ||
(pi->curr_idx == 1 && pi->turbo_available && !pi->turbo_enable))
@@ -455,11 +419,6 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id)
int
power_acpi_cpufreq_freq_max(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
/* Frequencies in the array are from high to low. */
if (lcore_power_info[lcore_id].turbo_available) {
if (lcore_power_info[lcore_id].turbo_enable)
@@ -479,11 +438,6 @@ power_acpi_cpufreq_freq_min(unsigned int lcore_id)
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
/* Frequencies in the array are from high to low. */
@@ -496,11 +450,6 @@ power_acpi_turbo_status(unsigned int lcore_id)
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
return pi->turbo_enable;
@@ -512,11 +461,6 @@ power_acpi_enable_turbo(unsigned int lcore_id)
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->turbo_available)
@@ -545,11 +489,6 @@ power_acpi_disable_turbo(unsigned int lcore_id)
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
pi->turbo_enable = 0;
@@ -572,10 +511,6 @@ int power_acpi_get_capabilities(unsigned int lcore_id,
{
struct acpi_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
if (caps == NULL) {
POWER_LOG(ERR, "Invalid argument");
return -1;
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 05/10] power/amd_pstate: remove redundant lcore ID checks
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
` (3 preceding siblings ...)
2026-05-22 4:11 ` [PATCH v3 04/10] power/acpi: remove redundant lcore ID checks Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 06/10] power/cppc: " Huisong Li
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
Now that the cpufreq framework validates the lcore ID using
rte_lcore_is_eal_managed() before dispatching to any driver,
each individual cpufreq driver no longer needs its own range
check against RTE_MAX_LCORE.
Remove the duplicated lcore ID checks from the amd_pstate
cpufreq driver ops.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
drivers/power/amd_pstate/amd_pstate_cpufreq.c | 65 -------------------
1 file changed, 65 deletions(-)
diff --git a/drivers/power/amd_pstate/amd_pstate_cpufreq.c b/drivers/power/amd_pstate/amd_pstate_cpufreq.c
index 95495bff7d..8ca27d689d 100644
--- a/drivers/power/amd_pstate/amd_pstate_cpufreq.c
+++ b/drivers/power/amd_pstate/amd_pstate_cpufreq.c
@@ -360,12 +360,6 @@ power_amd_pstate_cpufreq_init(unsigned int lcore_id)
return -1;
}
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
exp_state = POWER_IDLE;
/* The power in use state works as a guard variable between
@@ -443,11 +437,6 @@ power_amd_pstate_cpufreq_exit(unsigned int lcore_id)
struct amd_pstate_power_info *pi;
uint32_t exp_state;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
pi = &lcore_power_info[lcore_id];
exp_state = POWER_USED;
/* The power in use state works as a guard variable between
@@ -493,11 +482,6 @@ power_amd_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return 0;
- }
-
if (freqs == NULL) {
POWER_LOG(ERR, "NULL buffer supplied");
return 0;
@@ -516,22 +500,12 @@ power_amd_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t
uint32_t
power_amd_pstate_cpufreq_get_freq(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return RTE_POWER_INVALID_FREQ_INDEX;
- }
-
return lcore_power_info[lcore_id].curr_idx;
}
int
power_amd_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
return set_freq_internal(&(lcore_power_info[lcore_id]), index);
}
@@ -540,11 +514,6 @@ power_amd_pstate_cpufreq_freq_down(unsigned int lcore_id)
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx + 1 == pi->nb_freqs)
return 0;
@@ -558,11 +527,6 @@ power_amd_pstate_cpufreq_freq_up(unsigned int lcore_id)
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx == 0 || (pi->curr_idx == pi->nom_idx &&
pi->turbo_available && !pi->turbo_enable))
@@ -575,11 +539,6 @@ power_amd_pstate_cpufreq_freq_up(unsigned int lcore_id)
int
power_amd_pstate_cpufreq_freq_max(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
/* Frequencies in the array are from high to low. */
if (lcore_power_info[lcore_id].turbo_available) {
if (lcore_power_info[lcore_id].turbo_enable)
@@ -600,11 +559,6 @@ power_amd_pstate_cpufreq_freq_min(unsigned int lcore_id)
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
/* Frequencies in the array are from high to low. */
@@ -616,11 +570,6 @@ power_amd_pstate_turbo_status(unsigned int lcore_id)
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
return pi->turbo_enable;
@@ -631,11 +580,6 @@ power_amd_pstate_enable_turbo(unsigned int lcore_id)
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->turbo_available)
@@ -667,11 +611,6 @@ power_amd_pstate_disable_turbo(unsigned int lcore_id)
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
pi->turbo_enable = 0;
@@ -695,10 +634,6 @@ power_amd_pstate_get_capabilities(unsigned int lcore_id,
{
struct amd_pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
if (caps == NULL) {
POWER_LOG(ERR, "Invalid argument");
return -1;
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 06/10] power/cppc: remove redundant lcore ID checks
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
` (4 preceding siblings ...)
2026-05-22 4:11 ` [PATCH v3 05/10] power/amd_pstate: " Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 07/10] power/intel_pstate: " Huisong Li
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
Now that the cpufreq framework validates the lcore ID using
rte_lcore_is_eal_managed() before dispatching to any driver,
each individual cpufreq driver no longer needs its own range
check against RTE_MAX_LCORE.
Remove the duplicated lcore ID checks from the cppc cpufreq
driver ops.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
drivers/power/cppc/cppc_cpufreq.c | 65 -------------------------------
1 file changed, 65 deletions(-)
diff --git a/drivers/power/cppc/cppc_cpufreq.c b/drivers/power/cppc/cppc_cpufreq.c
index 3cd4165c83..529f68e574 100644
--- a/drivers/power/cppc/cppc_cpufreq.c
+++ b/drivers/power/cppc/cppc_cpufreq.c
@@ -346,12 +346,6 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
return -1;
}
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
exp_state = POWER_IDLE;
/* The power in use state works as a guard variable between
@@ -429,11 +423,6 @@ power_cppc_cpufreq_exit(unsigned int lcore_id)
struct cppc_power_info *pi;
uint32_t exp_state;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
pi = &lcore_power_info[lcore_id];
exp_state = POWER_USED;
/* The power in use state works as a guard variable between
@@ -479,11 +468,6 @@ power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return 0;
- }
-
if (freqs == NULL) {
POWER_LOG(ERR, "NULL buffer supplied");
return 0;
@@ -502,22 +486,12 @@ power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
uint32_t
power_cppc_cpufreq_get_freq(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return RTE_POWER_INVALID_FREQ_INDEX;
- }
-
return lcore_power_info[lcore_id].curr_idx;
}
int
power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
return set_freq_internal(&(lcore_power_info[lcore_id]), index);
}
@@ -526,11 +500,6 @@ power_cppc_cpufreq_freq_down(unsigned int lcore_id)
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx + 1 == pi->nb_freqs)
return 0;
@@ -544,11 +513,6 @@ power_cppc_cpufreq_freq_up(unsigned int lcore_id)
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx == 0 || (pi->curr_idx == 1 &&
pi->turbo_available && !pi->turbo_enable))
@@ -561,11 +525,6 @@ power_cppc_cpufreq_freq_up(unsigned int lcore_id)
int
power_cppc_cpufreq_freq_max(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
/* Frequencies in the array are from high to low. */
if (lcore_power_info[lcore_id].turbo_available) {
if (lcore_power_info[lcore_id].turbo_enable)
@@ -585,11 +544,6 @@ power_cppc_cpufreq_freq_min(unsigned int lcore_id)
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
/* Frequencies in the array are from high to low. */
@@ -601,11 +555,6 @@ power_cppc_turbo_status(unsigned int lcore_id)
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
return pi->turbo_enable;
@@ -616,11 +565,6 @@ power_cppc_enable_turbo(unsigned int lcore_id)
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->turbo_available)
@@ -652,11 +596,6 @@ power_cppc_disable_turbo(unsigned int lcore_id)
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
pi->turbo_enable = 0;
@@ -680,10 +619,6 @@ power_cppc_get_capabilities(unsigned int lcore_id,
{
struct cppc_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
if (caps == NULL) {
POWER_LOG(ERR, "Invalid argument");
return -1;
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 07/10] power/intel_pstate: remove redundant lcore ID checks
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
` (5 preceding siblings ...)
2026-05-22 4:11 ` [PATCH v3 06/10] power/cppc: " Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 08/10] power/kvm_vm: " Huisong Li
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
Now that the cpufreq framework validates the lcore ID using
rte_lcore_is_eal_managed() before dispatching to any driver,
each individual cpufreq driver no longer needs its own range
check against RTE_MAX_LCORE.
Remove the duplicated lcore ID checks from the intel_pstate
cpufreq driver ops.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
.../power/intel_pstate/intel_pstate_cpufreq.c | 65 -------------------
1 file changed, 65 deletions(-)
diff --git a/drivers/power/intel_pstate/intel_pstate_cpufreq.c b/drivers/power/intel_pstate/intel_pstate_cpufreq.c
index 8e27570e3c..e7ed9c8260 100644
--- a/drivers/power/intel_pstate/intel_pstate_cpufreq.c
+++ b/drivers/power/intel_pstate/intel_pstate_cpufreq.c
@@ -548,12 +548,6 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
return -1;
}
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceed %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
exp_state = POWER_IDLE;
/* The power in use state works as a guard variable between
@@ -630,11 +624,6 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
struct pstate_power_info *pi;
uint32_t exp_state;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
- lcore_id, RTE_MAX_LCORE - 1U);
- return -1;
- }
pi = &lcore_power_info[lcore_id];
exp_state = POWER_USED;
@@ -688,11 +677,6 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return 0;
- }
-
if (freqs == NULL) {
POWER_LOG(ERR, "NULL buffer supplied");
return 0;
@@ -711,11 +695,6 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
uint32_t
power_pstate_cpufreq_get_freq(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return RTE_POWER_INVALID_FREQ_INDEX;
- }
-
return lcore_power_info[lcore_id].curr_idx;
}
@@ -723,11 +702,6 @@ power_pstate_cpufreq_get_freq(unsigned int lcore_id)
int
power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
return set_freq_internal(&(lcore_power_info[lcore_id]), index);
}
@@ -736,11 +710,6 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id)
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx == 0 ||
(pi->curr_idx == 1 && pi->turbo_available && !pi->turbo_enable))
@@ -755,11 +724,6 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id)
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->curr_idx + 1 == pi->nb_freqs)
return 0;
@@ -771,11 +735,6 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id)
int
power_pstate_cpufreq_freq_max(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
/* Frequencies in the array are from high to low. */
if (lcore_power_info[lcore_id].turbo_available) {
if (lcore_power_info[lcore_id].turbo_enable)
@@ -796,11 +755,6 @@ power_pstate_cpufreq_freq_min(unsigned int lcore_id)
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
/* Frequencies in the array are from high to low. */
@@ -813,11 +767,6 @@ power_pstate_turbo_status(unsigned int lcore_id)
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
return pi->turbo_enable;
@@ -828,11 +777,6 @@ power_pstate_enable_turbo(unsigned int lcore_id)
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
if (pi->turbo_available)
@@ -854,11 +798,6 @@ power_pstate_disable_turbo(unsigned int lcore_id)
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
-
pi = &lcore_power_info[lcore_id];
pi->turbo_enable = 0;
@@ -882,10 +821,6 @@ int power_pstate_get_capabilities(unsigned int lcore_id,
{
struct pstate_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID");
- return -1;
- }
if (caps == NULL) {
POWER_LOG(ERR, "Invalid argument");
return -1;
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 08/10] power/kvm_vm: remove redundant lcore ID checks
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
` (6 preceding siblings ...)
2026-05-22 4:11 ` [PATCH v3 07/10] power/intel_pstate: " Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 09/10] power: allow the service core to config power QoS Huisong Li
2026-05-22 4:11 ` [PATCH v3 10/10] power: add lcore ID check for PMD mgmt Huisong Li
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
Now that the cpufreq framework validates the lcore ID using
rte_lcore_is_eal_managed() before dispatching to any driver,
each individual cpufreq driver no longer needs its own range
check against RTE_MAX_LCORE.
Remove the duplicated lcore ID checks from the kvm_vm cpufreq
driver and its guest_channel helper.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
drivers/power/kvm_vm/guest_channel.c | 22 ----------------------
drivers/power/kvm_vm/kvm_vm.c | 10 ----------
2 files changed, 32 deletions(-)
diff --git a/drivers/power/kvm_vm/guest_channel.c b/drivers/power/kvm_vm/guest_channel.c
index 42bfcedb56..dc8fe05fef 100644
--- a/drivers/power/kvm_vm/guest_channel.c
+++ b/drivers/power/kvm_vm/guest_channel.c
@@ -61,11 +61,6 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
char fd_path[PATH_MAX];
int fd = -1;
- if (lcore_id >= RTE_MAX_LCORE) {
- GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
- lcore_id, RTE_MAX_LCORE-1);
- return -1;
- }
/* check if path is already open */
if (global_fds[lcore_id] != -1) {
GUEST_CHANNEL_LOG(ERR, "Channel(%u) is already open with fd %d",
@@ -127,12 +122,6 @@ guest_channel_send_msg(struct rte_power_channel_packet *pkt,
int ret, buffer_len = sizeof(*pkt);
void *buffer = pkt;
- if (lcore_id >= RTE_MAX_LCORE) {
- GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
- lcore_id, RTE_MAX_LCORE-1);
- return -1;
- }
-
if (global_fds[lcore_id] < 0) {
GUEST_CHANNEL_LOG(ERR, "Channel is not connected");
return -1;
@@ -169,12 +158,6 @@ int power_guest_channel_read_msg(void *pkt,
if (pkt_len == 0 || pkt == NULL)
return -1;
- if (lcore_id >= RTE_MAX_LCORE) {
- GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
- lcore_id, RTE_MAX_LCORE-1);
- return -1;
- }
-
if (global_fds[lcore_id] < 0) {
GUEST_CHANNEL_LOG(ERR, "Channel is not connected");
return -1;
@@ -225,11 +208,6 @@ int rte_power_guest_channel_receive_msg(void *pkt,
void
guest_channel_host_disconnect(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- GUEST_CHANNEL_LOG(ERR, "Channel(%u) is out of range 0...%d",
- lcore_id, RTE_MAX_LCORE-1);
- return;
- }
if (global_fds[lcore_id] < 0)
return;
close(global_fds[lcore_id]);
diff --git a/drivers/power/kvm_vm/kvm_vm.c b/drivers/power/kvm_vm/kvm_vm.c
index 5754a441cd..e8b454bb55 100644
--- a/drivers/power/kvm_vm/kvm_vm.c
+++ b/drivers/power/kvm_vm/kvm_vm.c
@@ -24,11 +24,6 @@ power_kvm_vm_check_supported(void)
int
power_kvm_vm_init(unsigned int lcore_id)
{
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
- lcore_id, RTE_MAX_LCORE-1);
- return -1;
- }
pkt[lcore_id].command = RTE_POWER_CPU_POWER;
pkt[lcore_id].resource_id = lcore_id;
return guest_channel_host_connect(FD_PATH, lcore_id);
@@ -73,11 +68,6 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
{
int ret;
- if (lcore_id >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Core(%u) is out of range 0...%d",
- lcore_id, RTE_MAX_LCORE-1);
- return -1;
- }
pkt[lcore_id].unit = scale_direction;
ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
if (ret == 0)
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 09/10] power: allow the service core to config power QoS
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
` (7 preceding siblings ...)
2026-05-22 4:11 ` [PATCH v3 08/10] power/kvm_vm: " Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
2026-05-22 4:11 ` [PATCH v3 10/10] power: add lcore ID check for PMD mgmt Huisong Li
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
The lcore ID verification in power QoS API used to use
rte_lcore_is_enabled(), which only accepts the lcore with
ROLE_RTE role. But service core thread (ROLE_SERVICE) can
also use power QoS API.
So this patch replaces rte_lcore_is_enabled() with the new
helper rte_lcore_is_eal_managed() by using the common macro
RTE_POWER_VALID_LCOREID_OR_ERR_RET. This change makes the
power QoS API accept both ROLE_RTE and ROLE_SERVICE lcores.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
doc/guides/rel_notes/release_26_07.rst | 6 ++++++
lib/power/rte_power_qos.c | 10 ++--------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/doc/guides/rel_notes/release_26_07.rst b/doc/guides/rel_notes/release_26_07.rst
index 98a7cf0203..0eca0261b3 100644
--- a/doc/guides/rel_notes/release_26_07.rst
+++ b/doc/guides/rel_notes/release_26_07.rst
@@ -76,6 +76,12 @@ New Features
that the lcore ID is EAL-managed (``ROLE_RTE`` or ``ROLE_SERVICE``)
before proceeding, replacing per-driver range checks.
+ The power QoS library also updated its lcore validation to use the
+ new helper, so service cores (``ROLE_SERVICE``) are now permitted
+ to configure power QoS parameters via ``rte_power_qos_set_cpu_resume_latency()``
+ and ``rte_power_qos_get_cpu_resume_latency()``, in addition to
+ regular DPDK lcores (``ROLE_RTE``).
+
Removed Items
-------------
diff --git a/lib/power/rte_power_qos.c b/lib/power/rte_power_qos.c
index be230d1c50..f6630b08f7 100644
--- a/lib/power/rte_power_qos.c
+++ b/lib/power/rte_power_qos.c
@@ -27,10 +27,7 @@ rte_power_qos_set_cpu_resume_latency(uint16_t lcore_id, int latency)
FILE *f;
int ret;
- if (!rte_lcore_is_enabled(lcore_id)) {
- POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
- return -EINVAL;
- }
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -EINVAL);
ret = power_get_lcore_mapped_cpu_id(lcore_id, &cpu_id);
if (ret != 0)
return ret;
@@ -82,10 +79,7 @@ rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id)
FILE *f;
int ret;
- if (!rte_lcore_is_enabled(lcore_id)) {
- POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
- return -EINVAL;
- }
+ RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, -EINVAL);
ret = power_get_lcore_mapped_cpu_id(lcore_id, &cpu_id);
if (ret != 0)
return ret;
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v3 10/10] power: add lcore ID check for PMD mgmt
2026-05-22 4:11 [PATCH v3 00/10] power: centralize lcore ID verification in cpufreq framework Huisong Li
` (8 preceding siblings ...)
2026-05-22 4:11 ` [PATCH v3 09/10] power: allow the service core to config power QoS Huisong Li
@ 2026-05-22 4:11 ` Huisong Li
9 siblings, 0 replies; 15+ messages in thread
From: Huisong Li @ 2026-05-22 4:11 UTC (permalink / raw)
To: anatoly.burakov, sivaprasad.tummala
Cc: dev, thomas, stephen, fengchengwen, yangxingui, zhanjie9,
lihuisong
The pmd_mgmt lib is mainly used together with the data plane of ethdev
PMD. The core in data plane is ROLE_RTE. So use rte_lcore_is_enabled
to verify it.
Fixes: 426511683762 ("power: add get/set min/max scaling frequencies API")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
lib/power/rte_power_pmd_mgmt.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index a4d53aac2a..a5fc1c3a94 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -511,7 +511,8 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
- if (queue_id >= RTE_MAX_QUEUES_PER_PORT || lcore_id >= RTE_MAX_LCORE) {
+ if (queue_id >= RTE_MAX_QUEUES_PER_PORT ||
+ !rte_lcore_is_enabled(lcore_id)) {
ret = -EINVAL;
goto end;
}
@@ -627,7 +628,7 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
- if (lcore_id >= RTE_MAX_LCORE || queue_id >= RTE_MAX_QUEUES_PER_PORT)
+ if (!rte_lcore_is_enabled(lcore_id) || queue_id >= RTE_MAX_QUEUES_PER_PORT)
return -EINVAL;
/* check if the queue is stopped */
@@ -729,8 +730,8 @@ RTE_EXPORT_SYMBOL(rte_power_pmd_mgmt_set_scaling_freq_min)
int
rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min)
{
- if (lcore >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
+ if (!rte_lcore_is_enabled(lcore)) {
+ POWER_LOG(ERR, "lcore id %u is not enabled", lcore);
return -EINVAL;
}
@@ -747,8 +748,8 @@ RTE_EXPORT_SYMBOL(rte_power_pmd_mgmt_set_scaling_freq_max)
int
rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max)
{
- if (lcore >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
+ if (!rte_lcore_is_enabled(lcore)) {
+ POWER_LOG(ERR, "lcore id %u is not enabled", lcore);
return -EINVAL;
}
@@ -769,8 +770,8 @@ RTE_EXPORT_SYMBOL(rte_power_pmd_mgmt_get_scaling_freq_min)
int
rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore)
{
- if (lcore >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
+ if (!rte_lcore_is_enabled(lcore)) {
+ POWER_LOG(ERR, "lcore id %u is not enabled", lcore);
return -EINVAL;
}
@@ -784,8 +785,8 @@ RTE_EXPORT_SYMBOL(rte_power_pmd_mgmt_get_scaling_freq_max)
int
rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore)
{
- if (lcore >= RTE_MAX_LCORE) {
- POWER_LOG(ERR, "Invalid lcore ID: %u", lcore);
+ if (!rte_lcore_is_enabled(lcore)) {
+ POWER_LOG(ERR, "lcore id %u is not enabled", lcore);
return -EINVAL;
}
--
2.33.0
^ permalink raw reply related [flat|nested] 15+ messages in thread