introduce PM QoS interface
cover introduce PM QoS interface
Subject: [PATCH 0/2] introduce PM QoS interface
The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a cpu_dma_latency device under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
So this series introduce PM QoS interface.
Huisong Li (2):
power: introduce PM QoS interface examples/l3fwd-power: add PM QoS request configuration
doc/guides/prog_guide/power_man.rst | 16 ++++ doc/guides/rel_notes/release_24_03.rst | 4 + examples/l3fwd-power/main.c | 41 +++++++++- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 98 ++++++++++++++++++++++++ lib/power/rte_power_qos.h | 101 +++++++++++++++++++++++++ lib/power/version.map | 4 + 7 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH 1/2 power: introduce PM QoS interface
The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a cpu_dma_latency device under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature has beed supported by kernel-v2.6.25.
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
So this PM QoS API make it easy to obtain the CPU latency limit on system and send the CPU latency QoS request for the application that need them.
The recommend usage method is as follows:
1) an application process first creates QoS request.
2) update the CPU latency request to zero when need.
3) back to the default value when no need(this step is optional).
4) release QoS request when process exit.
--- doc/guides/prog_guide/power_man.rst | 16 ++++ doc/guides/rel_notes/release_24_03.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 98 ++++++++++++++++++++++++ lib/power/rte_power_qos.h | 101 +++++++++++++++++++++++++ lib/power/version.map | 4 + 6 files changed, 225 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +16 -0
@@ -249,6 +249,22 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. +PM QoS API +---------- +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service threads are delay sensitive and very except +the low resume time, like interrupt packet receiving mode. + +This PM QoS API is aimed to obtain the CPU latency limit on system and send the +CPU latency QoS request for the application that need them. + +* ``rte_power_qos_get_curr_cpu_latency()`` is used to get the current CPU + latency limit on system. +* For sending CPU latency QoS request, first call ``rte_power_create_qos_request()`` + to create a QoS request, then update CPU latency value by calling + ``rte_power_qos_update_request()``. The ``rte_power_release_qos_request()`` is + used to release this QoS request when process exit. + References ----------
doc/guides/rel_notes/release_24_03.rst +4 -0
@@ -196,6 +196,10 @@ New Features Added DMA producer mode to measure performance of ``OP_FORWARD`` mode of event DMA adapter. +* **Added CPU latency PM QoS support.** + + Added the interface querying cpu latency PM QoS limit on system and + the interface sending cpu latency QoS request in power lib. Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +98 -0
98 lines not on this page · raw message
lib/power/rte_power_qos.h new file +101 -0
101 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_create_qos_request; + rte_power_release_qos_request; + rte_power_qos_get_curr_cpu_latency; + rte_power_qos_update_request; };
Signature · 1 line
2.22.0
PATCH 2/2 examples/l3fwd-power: add PM QoS request configuration
In reply to Huisong LiAdd PM QoS request configuration to declease the process resume latency.
--- examples/l3fwd-power/main.c | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-)
examples/l3fwd-power/main.c +40 -1
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2232,12 +2233,48 @@ static int check_ptype(uint16_t portid) } +static int +pm_qos_init (void ) +{ +int cur_cpu_latency; +int ret; + + ret =rte_power_qos_get_curr_cpu_latency (&cur_cpu_latency); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER ,"failed to get current cpu latency.\n" ); +return ret; + } +RTE_LOG (INFO ,L3FWD_POWER ,"current cpu latency is %dus on system.\n" , + (cur_cpu_latency /QOS_USEC_PER_SEC )); + + ret =rte_power_create_qos_request (); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER ,"Failed to create power QoS request.\n" ); +return ret; + } + +/* +* Set strict latency requirement to prevent service thread going into +* a deeper sleep state whose resume time is longer. +*/ + ret =rte_power_qos_update_request (PM_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) +RTE_LOG (ERR ,L3FWD_POWER ,"Failed to change cpu latency to 0.\n" ); +return ret; +} +static int init_power_library (void ) {enum power_management_env env;unsigned int lcore_id; -int ret =0 ; +int ret; + + ret =pm_qos_init (); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER ,"init power Qos failed.\n" ); +return ret; + }RTE_LCORE_FOREACH (lcore_id) {/* init power management library */
@@ -2268,6 +2305,8 @@ deinit_power_library(void)unsigned int lcore_id, max_pkg, max_die, die, pkg;int ret =0 ; +rte_power_release_qos_request (); +RTE_LCORE_FOREACH (lcore_id) {/* deinit power management library */ ret =rte_power_exit (lcore_id);
Signature · 1 line
2.22.0
Quoted 12 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.
Quoted 5 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature. Does Windows or BSD offer something similar?
Furthermore, any high-res timing should use nanoseconds, not microseconds or milliseconds.
I realize that the Linux kernel only uses microseconds for these APIs, but the DPDK API should use nanoseconds.
Hi Moren,
Thanks for your revew.
Quoted 12 lines · Morten Brørup
Quoted 12 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.
Quoted 6 lines
Quoted 5 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
The DPDK power lib just work on Linux according to the meson.build under lib/power. If they support this features, they can open it.
Quoted 3 lines
Furthermore, any high-res timing should use nanoseconds, not microseconds or milliseconds.
I realize that the Linux kernel only uses microseconds for these APIs, but the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs. Kernel interface just know an integer value with microseconds unit.
/BR
/Huisong
Quoted 24 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Thursday, 21 March 2024 04.04Hi Moren,
Thanks for your revew.
Quoted 16 lines · Morten Brørup
Quoted 16 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
Ask Windows experts or research using Google.
Quoted 3 lines
The DPDK power lib just work on Linux according to the meson.build under lib/power.
If they support this features, they can open it.
The DPDK power lib currently only works on Linux, yes.
But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future.
DPDK is on track to work across multiple platforms, including Windows.
We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only.
Quoted 9 lines
Quoted 2 lines
Furthermore, any high-res timing should use nanoseconds, not microseconds or
milliseconds.
Quoted 1 line
I realize that the Linux kernel only uses microseconds for these APIs, but
the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs.
Kernel interface just know an integer value with microseconds unit.
One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds. You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution.
+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows.
Quoted 24 lines · Morten Brørup
Quoted 24 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Thursday, 21 March 2024 04.04Hi Moren,
Thanks for your revew.
Quoted 16 lines · Morten Brørup
Quoted 16 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
Ask Windows experts or research using Google.
I download freebsd source code, I didn't find this similar feature. They don't even support cpuidle feature(this QoS feature affects cpuilde.). I don't find any useful about this on Windows from google.
@Tyler, @Alan, @Wei and @Long
Do you know windows support that userspace read and send CPU latency which has an impact on deep level of CPU idle?
Quoted 8 lines
Quoted 3 lines
The DPDK power lib just work on Linux according to the meson.build under lib/power.
If they support this features, they can open it.The DPDK power lib currently only works on Linux, yes.
But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future.DPDK is on track to work across multiple platforms, including Windows.
We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only.
totally understand you.
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
Furthermore, any high-res timing should use nanoseconds, not microseconds or
milliseconds.
Quoted 1 line
I realize that the Linux kernel only uses microseconds for these APIs, but
the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs.
Kernel interface just know an integer value with microseconds unit.One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds.
If so, we have to modify the implementation interface on Linux. This change the input/output unit about the interface.
And DPDK also has to do this based on kernel version. It is not good.
The cpuidle governor select which idle state based on the worst-case latency of idle state.
These the worst-case latency of Cstate reported by ACPI table is in microseconds as the section 8.4.1.1. _CST (C States) and 8.4.3.3. _LPI (Low Power Idle States) in ACPI spec [1]. So it is probably not meaning to change this interface implementation.
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle state.
Quoted 2 lines
You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution.
[1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
Quoted 70 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Friday, 22 March 2024 09.54+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows.
Quoted 7 lines · Morten Brørup
Quoted 7 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Thursday, 21 March 2024 04.04Hi Moren,
Thanks for your revew.
Quoted 8 lines
Quoted 8 lines · Morten Brørup
Quoted 7 lines
Quoted 7 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtainthe
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.The deeper the idle state, the lower the power consumption, but the
longer
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
Ask Windows experts or research using Google.
I download freebsd source code, I didn't find this similar feature. They don't even support cpuidle feature(this QoS feature affects cpuilde.). I don't find any useful about this on Windows from google.
@Tyler, @Alan, @Wei and @Long
Do you know windows support that userspace read and send CPU latency which has an impact on deep level of CPU idle?
Quoted 5 lines
Quoted 3 lines
The DPDK power lib just work on Linux according to the meson.build under lib/power.
If they support this features, they can open it.The DPDK power lib currently only works on Linux, yes. But its API should still be designed to be platform agnostic, so the
functions can be implemented on other platforms in the future.
Quoted 3 lines
DPDK is on track to work across multiple platforms, including Windows. We must always consider other platforms, and not design DPDK APIs as if they
are for Linux/BSD only.
totally understand you.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Furthermore, any high-res timing should use nanoseconds, not microseconds
or
Quoted 8 lines
Quoted 7 lines
milliseconds.
Quoted 1 line
I realize that the Linux kernel only uses microseconds for these APIs, but
the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs.
Kernel interface just know an integer value with microseconds unit.One solution is to expose nanoseconds in the DPDK API, and in the Linux
Quoted 10 lines
specific implementation convert from/to microseconds.
If so, we have to modify the implementation interface on Linux. This change the input/output unit about the interface.
And DPDK also has to do this based on kernel version. It is not good. The cpuidle governor select which idle state based on the worst-case latency of idle state.
These the worst-case latency of Cstate reported by ACPI table is in microseconds as the section 8.4.1.1._CST(C States) and 8.4.3.3._LPI(Low Power Idle States) in ACPI spec [1].
So it is probably not meaning to change this interface implementation.
OK... Since microsecond resolution is good enough for ACPI and Linux, you have me convinced that it's also good enough for DPDK (for this specific topic).
Thank you for the detailed reply!
Quoted 3 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle state.
It would defeat the purpose (i.e. not saving sufficient amounts of power) if the CPU cannot enter a deeper idle state.
Personally, I would think a wake-up latency of up to 10 microseconds should be fine for must purposes. Default Linux timerslack is 50 microseconds, so you could also use that value.
Quoted 6 lines
Quoted 1 line
You might also want to add a note to the in-line documentation of the
relevant functions that the Linux implementation only uses microsecond resolution.
Quoted 1 line
[1]
https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
Quoted 78 lines · Morten Brørup
Quoted 68 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Friday, 22 March 2024 09.54+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows.
Quoted 7 lines · Morten Brørup
Quoted 7 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Thursday, 21 March 2024 04.04Hi Moren,
Thanks for your revew.
Quoted 8 lines
Quoted 8 lines · Morten Brørup
Quoted 7 lines
Quoted 7 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtainthe
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.The deeper the idle state, the lower the power consumption, but the
longer
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
Ask Windows experts or research using Google.
I download freebsd source code, I didn't find this similar feature. They don't even support cpuidle feature(this QoS feature affects cpuilde.). I don't find any useful about this on Windows from google.
@Tyler, @Alan, @Wei and @Long
Do you know windows support that userspace read and send CPU latency which has an impact on deep level of CPU idle?
Quoted 5 lines
Quoted 3 lines
The DPDK power lib just work on Linux according to the meson.build under lib/power.
If they support this features, they can open it.The DPDK power lib currently only works on Linux, yes. But its API should still be designed to be platform agnostic, so the
functions can be implemented on other platforms in the future.
Quoted 2 lines
DPDK is on track to work across multiple platforms, including Windows. We must always consider other platforms, and not design DPDK APIs as if they
are for Linux/BSD only.
totally understand you.Quoted 1 line
Quoted 1 line
Quoted 1 line
Furthermore, any high-res timing should use nanoseconds, not microseconds
or
Quoted 8 lines
Quoted 7 lines
milliseconds.
Quoted 1 line
I realize that the Linux kernel only uses microseconds for these APIs, but
the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs.
Kernel interface just know an integer value with microseconds unit.One solution is to expose nanoseconds in the DPDK API, and in the Linux
Quoted 10 lines
specific implementation convert from/to microseconds.
If so, we have to modify the implementation interface on Linux. This change the input/output unit about the interface.
And DPDK also has to do this based on kernel version. It is not good. The cpuidle governor select which idle state based on the worst-case latency of idle state.
These the worst-case latency of Cstate reported by ACPI table is in microseconds as the section 8.4.1.1._CST(C States) and 8.4.3.3._LPI(Low Power Idle States) in ACPI spec [1].
So it is probably not meaning to change this interface implementation.
Quoted 7 lines
OK... Since microsecond resolution is good enough for ACPI and Linux, you have me convinced that it's also good enough for DPDK (for this specific topic).
Thank you for the detailed reply!
Quoted 2 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle state.
It would defeat the purpose (i.e. not saving sufficient amounts of power) if the CPU cannot enter a deeper idle state.
Yes, it is not good for power.
AFAIS, PM QoS is just to decrease the influence for performance. Anyway, if we set to zero, system can be into Cstates-0 at least.
Quoted 3 lines
Personally, I would think a wake-up latency of up to 10 microseconds should be fine for must purposes. Default Linux timerslack is 50 microseconds, so you could also use that value.
How much CPU latency is ok. Maybe, we can give the decision to the application. Linux will collect all these QoS request and use the minimum latency. what do you think, Morten?
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
You might also want to add a note to the in-line documentation of the
relevant functions that the Linux implementation only uses microsecond resolution.
[1]
https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
Quoted 6 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Tuesday, 26 March 2024 03.12Quoted 2 lines · Morten Brørup
Quoted 2 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Friday, 22 March 2024 09.54
[...]
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle
state.
Quoted 1 line
It would defeat the purpose (i.e. not saving sufficient amounts of
power) if the CPU cannot enter a deeper idle state. Yes, it is not good for power.
AFAIS, PM QoS is just to decrease the influence for performance. Anyway, if we set to zero, system can be into Cstates-0 at least.Quoted 1 line
Quoted 6 lines
Quoted 1 line
Personally, I would think a wake-up latency of up to 10 microseconds
should be fine for must purposes.
Quoted 1 line
Default Linux timerslack is 50 microseconds, so you could also use
that value.
How much CPU latency is ok. Maybe, we can give the decision to the application.
Yes, the application should decide the acceptable worst-case latency.
Quoted 2 lines
Linux will collect all these QoS request and use the minimum latency. what do you think, Morten?
For the example application, you could use a value of 50 microseconds and refer to this value also being the default timerslack in Linux.
Quoted 19 lines · Morten Brørup
Quoted 6 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Tuesday, 26 March 2024 03.12Quoted 2 lines · Morten Brørup
Quoted 2 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Friday, 22 March 2024 09.54[...]
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle
state.
Quoted 1 line
It would defeat the purpose (i.e. not saving sufficient amounts of
power) if the CPU cannot enter a deeper idle state. Yes, it is not good for power.
AFAIS, PM QoS is just to decrease the influence for performance. Anyway, if we set to zero, system can be into Cstates-0 at least.Quoted 1 line
Personally, I would think a wake-up latency of up to 10 microseconds
should be fine for must purposes.
Quoted 1 line
Default Linux timerslack is 50 microseconds, so you could also use
Quoted 8 lines
Quoted 3 lines
that value.
How much CPU latency is ok. Maybe, we can give the decision to the application.Yes, the application should decide the acceptable worst-case latency.
Quoted 2 lines
Linux will collect all these QoS request and use the minimum latency. what do you think, Morten?
For the example application, you could use a value of 50 microseconds and refer to this value also being the default timerslack in Linux.
There is a description for "/proc/<pid>/timerslack_ns" in Linux document [1]
"
This file provides the value of the task’s timerslack value in nanoseconds.
This value specifies an amount of time that normal timers may be deferred in order to coalesce timers and avoid unnecessary wakeups. This allows a task’s interactivity vs power consumption tradeoff to be adjusted.
"
I cannot understand what the relationship is between the timerslack in Linux and cpu latency to wake up.
It seems that timerslack is just to defer the timer in order to coalesce timers and avoid unnecessary wakeups. And it has not a lot to do with the CPU latency which is aimed to avoid task to enter deeper idle state and satify application request.
Quoted 1 line
Quoted 40 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Tuesday, 26 March 2024 13.15Quoted 19 lines · Morten Brørup
Quoted 6 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Tuesday, 26 March 2024 03.12Quoted 2 lines · Morten Brørup
Quoted 2 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Friday, 22 March 2024 09.54[...]
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle
state.
Quoted 1 line
It would defeat the purpose (i.e. not saving sufficient amounts of
power) if the CPU cannot enter a deeper idle state. Yes, it is not good for power.
AFAIS, PM QoS is just to decrease the influence for performance. Anyway, if we set to zero, system can be into Cstates-0 at least.Quoted 1 line
Personally, I would think a wake-up latency of up to 10 microseconds
should be fine for must purposes.
Quoted 1 line
Default Linux timerslack is 50 microseconds, so you could also use
Quoted 8 lines
Quoted 3 lines
that value.
How much CPU latency is ok. Maybe, we can give the decision to the application.Yes, the application should decide the acceptable worst-case latency.
Quoted 2 lines
Linux will collect all these QoS request and use the minimum latency. what do you think, Morten?
For the example application, you could use a value of 50 microseconds
and refer to this value also being the default timerslack in Linux. There is a description for "/proc/<pid>/timerslack_ns" in Linux document
[1]
"
This file provides the value of the task’s timerslack value in nanoseconds.
This value specifies an amount of time that normal timers may be deferred in order to coalesce timers and avoid unnecessary wakeups. This allows a task’s interactivity vs power consumption tradeoff to be
Quoted 8 lines
adjusted.
"
I cannot understand what the relationship is between the timerslack in Linux and cpu latency to wake up.
It seems that timerslack is just to defer the timer in order to coalesce timers and avoid unnecessary wakeups.
And it has not a lot to do with the CPU latency which is aimed to avoid task to enter deeper idle state and satify application request.
Correct. They control two different things.
However, both can cause latency for the application, so my rationale for the relationship was:
If the application accepts X us of latency caused by kernel scheduling delays (caused by timerslack), the application should accept the same amount of latency caused by CPU wake-up latency.
This also means that if you want lower latency than 50 us, you should not only set cpu wake-up latency, you should also set timerslack.
Obviously, if the application is only affected by one of the two, the application only needs to adjust that one of them.
As for the 50 us value, someone in the Linux kernel team decided that 50 us was an acceptable amount of latency for the kernel; we could use the same value, referring to that. Or we could choose some other value, and describe how we came up with our own value. And if necessary, also adjust timerslack accordingly.
Quoted 48 lines · Morten Brørup
Quoted 40 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Tuesday, 26 March 2024 13.15Quoted 19 lines · Morten Brørup
Quoted 6 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Tuesday, 26 March 2024 03.12Quoted 2 lines · Morten Brørup
Quoted 2 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Friday, 22 March 2024 09.54[...]
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle
state.
Quoted 1 line
It would defeat the purpose (i.e. not saving sufficient amounts of
power) if the CPU cannot enter a deeper idle state. Yes, it is not good for power.
AFAIS, PM QoS is just to decrease the influence for performance. Anyway, if we set to zero, system can be into Cstates-0 at least.Quoted 1 line
Personally, I would think a wake-up latency of up to 10 microseconds
should be fine for must purposes.
Quoted 1 line
Default Linux timerslack is 50 microseconds, so you could also use
Quoted 8 lines
Quoted 3 lines
that value.
How much CPU latency is ok. Maybe, we can give the decision to the application.Yes, the application should decide the acceptable worst-case latency.
Quoted 2 lines
Linux will collect all these QoS request and use the minimum latency. what do you think, Morten?
For the example application, you could use a value of 50 microseconds
and refer to this value also being the default timerslack in Linux. There is a description for "/proc/<pid>/timerslack_ns" in Linux document
[1]
"
This file provides the value of the task’s timerslack value in nanoseconds.
This value specifies an amount of time that normal timers may be deferred in order to coalesce timers and avoid unnecessary wakeups. This allows a task’s interactivity vs power consumption tradeoff to beQuoted 8 lines
adjusted.
"
I cannot understand what the relationship is between the timerslack in Linux and cpu latency to wake up.
It seems that timerslack is just to defer the timer in order to coalesce timers and avoid unnecessary wakeups.
And it has not a lot to do with the CPU latency which is aimed to avoid task to enter deeper idle state and satify application request.
Quoted 4 lines
Correct. They control two different things.
However, both can cause latency for the application, so my rationale for the relationship was:
If the application accepts X us of latency caused by kernel scheduling delays (caused by timerslack), the application should accept the same amount of latency caused by CPU wake-up latency.
Understand, thanks for explain.
Quoted 4 lines
This also means that if you want lower latency than 50 us, you should not only set cpu wake-up latency, you should also set timerslack.
Obviously, if the application is only affected by one of the two, the application only needs to adjust that one of them.
Yes, I think it is.
Quoted 2 lines
As for the 50 us value, someone in the Linux kernel team decided that 50 us was an acceptable amount of latency for the kernel; we could use the same value, referring to that. Or we could choose some other value, and describe how we came up with our own value. And if necessary, also adjust timerslack accordingly.
So how about use the default 50us of timerslack in l3fwd-power?
And we add some description about this in code or document, like, suggest user also need to modify this process's timerslack if want a more little latency.
Quoted 1 line
Quoted 38 lines · lihuisong (C)
+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows.
Quoted 24 lines · Morten Brørup
Quoted 24 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Thursday, 21 March 2024 04.04Hi Moren,
Thanks for your revew.
Quoted 16 lines · Morten Brørup
Quoted 16 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
Ask Windows experts or research using Google.
I download freebsd source code, I didn't find this similar feature. They don't even support cpuidle feature(this QoS feature affects cpuilde.). I don't find any useful about this on Windows from google.
Quoted 4 lines
@Tyler, @Alan, @Wei and @Long
Do you know windows support that userspace read and send CPU latency which has an impact on deep level of CPU idle?
it is unlikely you'll find an api that let's you manage things in terms of raw latency values as the linux knobs here do. windows more often employs policy centric schemes to permit the system to abstract implementation detail.
powercfg is probably the closest thing you can use to tune the same things on windows. where you select e.g. the 'performance' scheme but it won't allow you to pick specific latency numbers.
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
The DPDK power lib just work on Linux according to the meson.build under lib/power.
If they support this features, they can open it.The DPDK power lib currently only works on Linux, yes.
But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future.DPDK is on track to work across multiple platforms, including Windows.
We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only.totally understand you.
since lib/power isn't built for windows at this time i don't think it's appropriate to constrain your innovation. i do appreciate the engagement though and would just offer general guidance that if you can design your api with some kind of abstraction in mind that would be great and by all means if you can figure out how to wrangle powercfg /Qh into satisfying the api in a policy centric way it might be kind of nice.
i'll let other windows experts chime in here if they choose.
thanks!
Quoted 26 lines
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
Furthermore, any high-res timing should use nanoseconds, not microseconds or
milliseconds.
Quoted 1 line
I realize that the Linux kernel only uses microseconds for these APIs, but
the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs.
Kernel interface just know an integer value with microseconds unit.One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds.
If so, we have to modify the implementation interface on Linux. This change the input/output unit about the interface.
And DPDK also has to do this based on kernel version. It is not good. The cpuidle governor select which idle state based on the worst-case latency of idle state.
These the worst-case latency of Cstate reported by ACPI table is in microseconds as the section 8.4.1.1._CST(C States) and 8.4.3.3._LPI(Low Power Idle States) in ACPI spec [1].
So it is probably not meaning to change this interface implementation.For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle state.
Quoted 2 lines
You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution.
[1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
Hi Tyler,
Quoted 47 lines · Tyler Retzlaff
Quoted 38 lines · lihuisong (C)
+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows.
Quoted 24 lines · Morten Brørup
Quoted 24 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Thursday, 21 March 2024 04.04Hi Moren,
Thanks for your revew.
Quoted 16 lines · Morten Brørup
Quoted 16 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
Ask Windows experts or research using Google.
I download freebsd source code, I didn't find this similar feature. They don't even support cpuidle feature(this QoS feature affects cpuilde.). I don't find any useful about this on Windows from google.
Quoted 4 lines
@Tyler, @Alan, @Wei and @Long
Do you know windows support that userspace read and send CPU latency which has an impact on deep level of CPU idle?
it is unlikely you'll find an api that let's you manage things in terms of raw latency values as the linux knobs here do. windows more often employs policy centric schemes to permit the system to abstract implementation detail.
Quoted 5 lines
powercfg is probably the closest thing you can use to tune the same things on windows. where you select e.g. the 'performance' scheme but it won't allow you to pick specific latency numbers.
Thanks for your feedback. I will take a look at this tool.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
The DPDK power lib just work on Linux according to the meson.build under lib/power.
If they support this features, they can open it.The DPDK power lib currently only works on Linux, yes.
But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future.DPDK is on track to work across multiple platforms, including Windows.
We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only.
Quoted 7 lines
Quoted 1 line
totally understand you.
since lib/power isn't built for windows at this time i don't think it's appropriate to constrain your innovation. i do appreciate the engagement though and would just offer general guidance that if you can design your api with some kind of abstraction in mind that would be great and by all means if you can figure out how to wrangle powercfg /Qh into satisfying the api in a policy centric way it might be kind of nice.
Testing this by using powercfg on Windows creates a very challenge for me. So I don't plan to do this on Windows. If you need, you can add it, ok?
Quoted 31 lines
i'll let other windows experts chime in here if they choose.
thanks!
Quoted 19 lines
Quoted 9 lines
Quoted 8 lines
Quoted 1 line
Furthermore, any high-res timing should use nanoseconds, not microseconds or
milliseconds.
Quoted 1 line
I realize that the Linux kernel only uses microseconds for these APIs, but
the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs.
Kernel interface just know an integer value with microseconds unit.One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds.
If so, we have to modify the implementation interface on Linux. This change the input/output unit about the interface.
And DPDK also has to do this based on kernel version. It is not good. The cpuidle governor select which idle state based on the worst-case latency of idle state.
These the worst-case latency of Cstate reported by ACPI table is in microseconds as the section 8.4.1.1._CST(C States) and 8.4.3.3._LPI(Low Power Idle States) in ACPI spec [1].
So it is probably not meaning to change this interface implementation.Quoted 6 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle state.
Quoted 2 lines
You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution.
[1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
.
Quoted 68 lines · lihuisong (C)
Hi Tyler,
Quoted 47 lines · Tyler Retzlaff
Quoted 38 lines · lihuisong (C)
+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows.
Quoted 24 lines · Morten Brørup
Quoted 24 lines
From: lihuisong (C) [mailto:[email protected]]
Sent: Thursday, 21 March 2024 04.04Hi Moren,
Thanks for your revew.
Quoted 16 lines · Morten Brørup
Quoted 16 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 20 March 2024 11.55The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor.
Linux creates a
cpu_dma_latencydevice under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link:
https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos
This feature is supported by kernel-v2.6.25.The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
So this series introduce PM QoS interface.
This looks like a 1:1 wrapper for a Linux kernel feature.
right
Quoted 1 line
Does Windows or BSD offer something similar?
How do we know Windows or BSD support this similar feature?
Ask Windows experts or research using Google.
I download freebsd source code, I didn't find this similar feature. They don't even support cpuidle feature(this QoS feature affects cpuilde.). I don't find any useful about this on Windows from google.
Quoted 4 lines
@Tyler, @Alan, @Wei and @Long
Do you know windows support that userspace read and send CPU latency which has an impact on deep level of CPU idle?
it is unlikely you'll find an api that let's you manage things in terms of raw latency values as the linux knobs here do. windows more often employs policy centric schemes to permit the system to abstract implementation detail.
Quoted 5 lines
powercfg is probably the closest thing you can use to tune the same things on windows. where you select e.g. the 'performance' scheme but it won't allow you to pick specific latency numbers.
Thanks for your feedback. I will take a look at this tool.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
The DPDK power lib just work on Linux according to the meson.build under lib/power.
If they support this features, they can open it.The DPDK power lib currently only works on Linux, yes.
But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future.DPDK is on track to work across multiple platforms, including Windows.
We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only.totally understand you.
Quoted 8 lines
Quoted 6 lines
since lib/power isn't built for windows at this time i don't think it's appropriate to constrain your innovation. i do appreciate the engagement though and would just offer general guidance that if you can design your api with some kind of abstraction in mind that would be great and by all means if you can figure out how to wrangle powercfg /Qh into satisfying the api in a policy centric way it might be kind of nice.
Testing this by using powercfg on Windows creates a very challenge for me. So I don't plan to do this on Windows. If you need, you can add it, ok?
ordinarily i would say it is appropriate to, however in this circumstance i agree. there is quite possibly significant porting work to be done so i would have to address it if we ever include it for windows.
thanks
Quoted 31 lines
Quoted 31 lines
i'll let other windows experts chime in here if they choose.
thanks!
Quoted 19 lines
Quoted 9 lines
Quoted 8 lines
Quoted 1 line
Furthermore, any high-res timing should use nanoseconds, not microseconds or
milliseconds.
Quoted 1 line
I realize that the Linux kernel only uses microseconds for these APIs, but
the DPDK API should use nanoseconds.
Nanoseconds is more precise, it's good.
But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs.
Kernel interface just know an integer value with microseconds unit.One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds.
If so, we have to modify the implementation interface on Linux. This change the input/output unit about the interface.
And DPDK also has to do this based on kernel version. It is not good. The cpuidle governor select which idle state based on the worst-case latency of idle state.
These the worst-case latency of Cstate reported by ACPI table is in microseconds as the section 8.4.1.1._CST(C States) and 8.4.3.3._LPI(Low Power Idle States) in ACPI spec [1].
So it is probably not meaning to change this interface implementation.Quoted 6 lines
For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle state.
Quoted 2 lines
You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution.
[1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
.
v2 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 22 +++++ doc/guides/rel_notes/release_24_07.rst | 4 + examples/l3fwd-power/main.c | 29 +++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 116 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 70 +++++++++++++++ lib/power/version.map | 2 + 7 files changed, 245 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v2 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 22 +++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 116 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 70 +++++++++++++++ lib/power/version.map | 2 + 6 files changed, 216 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +22 -0
@@ -249,6 +249,28 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can effect the work +CPU's idle state selection and just allow to enter the shallowest idle state +if set to zero (strict resume latency) for this CPU. + +The ``rte_power_qos_get_cpu_resume_latency()`` function can obtain the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -89,6 +89,10 @@ New Features * Added SSE/NEON vector datapath. +* **Introduce PM QoS interface.** + + * Introduce PM QoS interface to low the delay after sleep. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +116 -0
116 lines not on this page · raw message
lib/power/rte_power_qos.h new file +70 -0
70 lines not on this page · raw message
lib/power/version.map +2 -0
@@ -51,4 +51,6 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
RE: [PATCH v2 1/2] power: introduce PM QoS API on CPU wide
lib/power/rte_power_qos.c line 16
Quoted 2 lines
lib/power/rte_power_qos.c new file +2
-0+#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us"
Is it OK to access this path using the lcore_id as CPU parameter to open_core_sysfs_file(), or must it be mapped through rte_lcore_to_cpu_id(lcore_id) first?
@David, do you know?
lib/power/rte_power_qos.c line 29
Quoted 13 lines
lib/power/rte_power_qos.c new file +13
-0+ +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[BUFSIZ ] = {0 }; +FILE *f; +int ret; + +if (lcore_id >=RTE_MAX_LCORE ) { +POWER_LOG (ERR ,"Lcore id %u can not exceeds %u" , + lcore_id,RTE_MAX_LCORE -1U ); +return -EINVAL ; + }
The lcore_id could be a registered non-EAL thread. You should probably fail in that case.
Same comment for rte_power_qos_get_cpu_resume_latency().
lib/power/rte_power_qos.h line 34
Quoted 2 lines
lib/power/rte_power_qos.h new file +2
-0+#define PM_QOS_STRICT_LATENCY_VALUE 0 +#define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1))
These definitions are in the public header file, and thus should be RTE_POWER_ prefixed and have comments describing them.
Re: [PATCH v2 1/2] power: introduce PM QoS API on CPU wide
Hi Morten,
Thanks for your review.
Quoted 3 lines · Morten Brørup
lib/power/rte_power_qos.c line 16
Quoted 2 lines
lib/power/rte_power_qos.c new file +2
-0+#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us"Is it OK to access this path using the
lcore_idas CPU parameter toopen_core_sysfs_file(), or must it be mapped throughrte_lcore_to_cpu_id(lcore_id)first?
The cpu_id getting by rte_lcore_to_cpu_id() is from lcore_config[lcore_id].core_id which is from "/sys/devices/system/cpu/cpuX/topology/core_id" file, please see the function eal_cpu_core_id(). So I think the number in above "cpuX" must be the lcore_id in DPDK.
And the similar interface in power lib also directly use the locore_id.
Quoted 18 lines
@David, do you know?
lib/power/rte_power_qos.c line 29
Quoted 13 lines
lib/power/rte_power_qos.c new file +13
-0+ +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[BUFSIZ ] = {0 }; +FILE *f; +int ret; + +if (lcore_id >=RTE_MAX_LCORE ) { +POWER_LOG (ERR ,"Lcore id %u can not exceeds %u" , + lcore_id,RTE_MAX_LCORE -1U ); +return -EINVAL ; + }The
lcore_idcould be a registered non-EAL thread. You should probably fail in that case.
right, how about use rte_lcore_is_enabled(locore_id)?
Quoted 7 lines
Same comment for
rte_power_qos_get_cpu_resume_latency().lib/power/rte_power_qos.h line 34
Quoted 2 lines
lib/power/rte_power_qos.h new file +2
-0+#define PM_QOS_STRICT_LATENCY_VALUE 0 +#define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1))These definitions are in the public header file, and thus should be
RTE_POWER_prefixed and have comments describing them.
Ack
Quoted 3 lines
.
RE: [PATCH v2 1/2] power: introduce PM QoS API on CPU wide
Quoted 11 lines
From: lihuisong (C) [mailto:[email protected]]
Hi Morten,
Thanks for your review.
Quoted 3 lines · Morten Brørup
lib/power/rte_power_qos.c line 16
Quoted 2 lines
lib/power/rte_power_qos.c new file +2
-0+#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us"Is it OK to access this path using the
lcore_idas CPU parameter to
Quoted 8 lines
open_core_sysfs_file(), or must it be mapped throughrte_lcore_to_cpu_id(lcore_id)first?
Thecpu_idgetting byrte_lcore_to_cpu_id()is from lcore_config[lcore_id].core_id which is from "/sys/devices/system/cpu/cpuX/topology/core_id" file, please see the functioneal_cpu_core_id().
So I think the number in above "cpuX" must be thelcore_idin DPDK. And the similar interface in power lib also directly use thelocore_id.
Then it should be OK.
Thanks for the detailed answer.
Quoted 18 lines
Quoted 18 lines
@David, do you know?
lib/power/rte_power_qos.c line 29
Quoted 13 lines
lib/power/rte_power_qos.c new file +13
-0+ +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[BUFSIZ ] = {0 }; +FILE *f; +int ret; + +if (lcore_id >=RTE_MAX_LCORE ) { +POWER_LOG (ERR ,"Lcore id %u can not exceeds %u" , + lcore_id,RTE_MAX_LCORE -1U ); +return -EINVAL ; + }The
lcore_idcould be a registered non-EAL thread. You should probably fail in that case.
Quoted 1 line
right, how about use
rte_lcore_is_enabled(locore_id)?
I suppose setting latency for service cores should be forbidden too, so using rte_lcore_is_enabled() to check for ROLE_RTE is correct.
Quoted 12 lines
Quoted 7 lines
Same comment for
rte_power_qos_get_cpu_resume_latency().lib/power/rte_power_qos.h line 34
Quoted 2 lines
lib/power/rte_power_qos.h new file +2
-0+#define PM_QOS_STRICT_LATENCY_VALUE 0 +#define PM_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1))These definitions are in the public header file, and thus should be
RTE_POWER_prefixed and have comments describing them. AckQuoted 3 lines
.
PATCH v2 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
examples/l3fwd-power/main.c +29 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2259,6 +2260,25 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* +* Set the work CPU with strict latency limit to allow the +* process running on the CPU can only enter the shallowest +* idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +PM_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2298,6 +2318,15 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +PM_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
v3 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 22 +++++ doc/guides/rel_notes/release_24_07.rst | 4 + examples/l3fwd-power/main.c | 29 +++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 71 +++++++++++++++ lib/power/version.map | 2 + 7 files changed, 244 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v3 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 22 +++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 71 +++++++++++++++ lib/power/version.map | 2 + 6 files changed, 215 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +22 -0
@@ -249,6 +249,28 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can effect the work +CPU's idle state selection and just allow to enter the shallowest idle state +if set to zero (strict resume latency) for this CPU. + +The ``rte_power_qos_get_cpu_resume_latency()`` function can obtain the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -89,6 +89,10 @@ New Features * Added SSE/NEON vector datapath. +* **Introduce PM QoS interface.** + + * Introduce PM QoS interface to low the delay after sleep. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +114 -0
114 lines not on this page · raw message
lib/power/rte_power_qos.h new file +71 -0
71 lines not on this page · raw message
lib/power/version.map +2 -0
@@ -51,4 +51,6 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
Re: [PATCH v3 1/2] power: introduce PM QoS API on CPU wide
Quoted 11 lines · On Wed, 19 Jun 2024 14:31:43 +0800 Huisong Li <[email protected]> wrote:
doc/guides/prog_guide/power_man.rst +11
-0+PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task.
doc/guides/prog_guide/power_man.rst Get Num Pkgs · line 273
Quoted 10 lines
doc/guides/prog_guide/power_man.rst +10
-0+ +The per-CPU PM QoS API can be used to set and get the CPU resume latency. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can effect the work +CPU's idle state selection and just allow to enter the shallowest idle state +if set to zero (strict resume latency) for this CPU. + +The ``rte_power_qos_get_cpu_resume_latency()`` function can obtain the resume +latency on specified CPU. +
Wording of this is hard to read and needs to be reworded for clarity. Explain more what PM QoS is to the user.
Also, not sure if details about sysfs implementation is helpful. Should also say this is Linux only.
Re: [PATCH v3 1/2] power: introduce PM QoS API on CPU wide
Hi Stephen,
Thanks for your review.
Quoted 18 lines · Stephen Hemminger
Quoted 15 lines · On Wed, 19 Jun 2024 14:31:43 +0800 Huisong Li <[email protected]> wrote:
doc/guides/prog_guide/power_man.rst +15
-0+PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can effect the work
Quoted 8 lines
doc/guides/prog_guide/power_man.rst Get Num Pkgs · line 273
Quoted 6 lines
doc/guides/prog_guide/power_man.rst +6
-0+CPU's idle state selection and just allow to enter the shallowest idle state +if set to zero (strict resume latency) for this CPU. + +The ``rte_power_qos_get_cpu_resume_latency()`` function can obtain the resume +latency on specified CPU. +Wording of this is hard to read and needs to be reworded for clarity. Explain more what PM QoS is to the user.
Yes, it's very important. How do you feel about the following description?
-->
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to set and get the CPU resume latency based on this sysfs.
The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's idle state selection in Linux and limit just to enter the shallowest idle state to low the delay of resuming service after sleeping by setting strict resume latency (zero value).
The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume latency on specified CPU.
Quoted 1 line
Also, not sure if details about sysfs implementation is helpful.
It's just a short background.
IMO, it is helpful for user to make sense of this API.
Quoted 2 lines
Should also say this is Linux only.
.
Re: [PATCH v3 1/2] power: introduce PM QoS API on CPU wide
In reply to Huisong Li19/06/2024 08:31, Huisong Li:
Quoted 27 lines
lib/power/rte_power_qos.h new file +24
-0@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file rte_power_qos.h + * + * PM QoS API. + * + * The CPU-wide resume latency limit has a positive impact on this CPU's idle + * state selection in each cpuidle governor. + * Please see the PM QoS on CPU wide in the following link: + * https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-latency-us + * + * The deeper the idle state, the lower the power consumption, but the
lib/power/rte_power_qos.h line 34
Quoted 10 lines
lib/power/rte_power_qos.h new file +10
-0+* longer the resume time. Some service are delay sensitive and very except the +* low resume time, like interrupt packet receiving mode. +* +* In these case, per-CPU PM QoS API can be used to control this CPU's idle +* state selection and limit just enter the shallowest idle state to low the +* delay after sleep by setting strict resume latency (zero value). +*/ + +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1))
stdint.h include is missing
Re: [PATCH v3 1/2] power: introduce PM QoS API on CPU wide
Quoted 31 lines · Thomas Monjalon
19/06/2024 08:31, Huisong Li:
Quoted 30 lines
lib/power/rte_power_qos.h new file +27
-0@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file rte_power_qos.h + * + * PM QoS API. + * + * The CPU-wide resume latency limit has a positive impact on this CPU's idle + * state selection in each cpuidle governor. + * Please see the PM QoS on CPU wide in the following link: + * https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-latency-us + * + * The deeper the idle state, the lower the power consumption, but the + * longer the resume time. Some service are delay sensitive and very except the + * low resume time, like interrupt packet receiving mode. + *
Quoted 8 lines
lib/power/rte_power_qos.h line 34
Quoted 7 lines
lib/power/rte_power_qos.h new file +7
-0+* In these case, per-CPU PM QoS API can be used to control this CPU's idle +* state selection and limit just enter the shallowest idle state to low the +* delay after sleep by setting strict resume latency (zero value). +*/ + +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1))
stdint.hinclude is missing
Yes, it desn't satisfy self-contained header files. will add it in next version, thanks.
Quoted 4 lines
.
PATCH v3 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
examples/l3fwd-power/main.c +29 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2259,6 +2260,25 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* +* Set the work CPU with strict latency limit to allow the +* process running on the CPU can only enter the shallowest +* idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2298,6 +2318,15 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
Re: [PATCH v3 2/2] examples/l3fwd-power: add PM QoS configuration
examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 5 lines · On Wed, 19 Jun 2024 14:31:44 +0800 Huisong Li <[email protected]> wrote:
examples/l3fwd-power/main.c +5
-0+/* +* Set the work CPU with strict latency limit to allow the +* process running on the CPU can only enter the shallowest +* idle state. +*/
Wording of that comment is awkward to read.
Suggest:
Set the worker lcore's to have strict latency limit to allow the CPU to enter the shallowest idle state.
Re: [PATCH v3 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 10 lines · Stephen Hemminger
examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 5 lines · On Wed, 19 Jun 2024 14:31:44 +0800 Huisong Li <[email protected]> wrote:
examples/l3fwd-power/main.c +5
-0+/* +* Set the work CPU with strict latency limit to allow the +* process running on the CPU can only enter the shallowest +* idle state. +*/ Wording of that comment is awkward to read.
Quoted 4 lines
Suggest:
Set the worker lcore's to have strict latency limit to allow the CPU to enter the shallowest idle state.
Ack. Thanks for your suggestion.
Quoted 1 line
.
RE: [PATCH v3 0/2] power: introduce PM QoS interface
In reply to Huisong LiQuoted 21 lines
From: Huisong Li [mailto:[email protected]]
Sent: Wednesday, 19 June 2024 08.32The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
[1] https://www.kernel.org/doc/html/latest/admin-guide/abi-
testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos- resume-latency-us
Quoted 6 lines
---
v3:
- addRTE_POWER_xxxprefix for some macro in header
- add the check forlcore_idwithrte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
v4 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + examples/l3fwd-power/main.c | 28 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 7 files changed, 247 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v4 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 6 files changed, 219 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +24 -0
@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -89,6 +89,10 @@ New Features * Added SSE/NEON vector datapath. +* **Introduce PM QoS interface.** + + * Introduce per-CPU PM QoS interface to low the delay after sleep. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +114 -0
114 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +2 -0
@@ -51,4 +51,6 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
Re: [PATCH v4 1/2] power: introduce PM QoS API on CPU wide
lib/power/rte_power_qos.c line 21
Quoted 1 line · On Thu, 27 Jun 2024 14:00:10 +0800 Huisong Li <[email protected]> wrote:
lib/power/rte_power_qos.c new file +1
-0+char buf[BUFSIZ ] = {0 };
BUFSIZ is 4K and you probably don't need all of that. And initializing to 0 here should not be needed.
Why not:
char buf[LINE_MAX];
lib/power/rte_power_qos.c line 54
Quoted 6 lines
lib/power/rte_power_qos.c new file +6
-0+if (latency ==0 ) +sprintf (buf,"%s" ,"n/a" ); +else if (latency ==RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ) +sprintf (buf,"%u" ,0 ); +else +sprintf (buf,"%u" , latency);
Use snprintf instead.
Re: [PATCH v4 1/2] power: introduce PM QoS API on CPU wide
Quoted 5 lines · Stephen Hemminger
lib/power/rte_power_qos.c line 21
Quoted 1 line · On Thu, 27 Jun 2024 14:00:10 +0800 Huisong Li <[email protected]> wrote:
lib/power/rte_power_qos.c new file +1
-0+char buf[BUFSIZ ] = {0 };BUFSIZ is 4K and you probably don't need all of that.
I rember the maximum buffer length of sysfs show in Linux is BUFSIZ. Just from the same size, here is ok to receive the data from Linux. But LINE_MAX is also enough to use.
Quoted 1 line
And initializing to 0 here should not be needed.
Ack
Quoted 3 lines
Why not:
char buf[LINE_MAX];
Thanks for your suggestion. use it in next version.
Quoted 7 lines
lib/power/rte_power_qos.c line 54
Quoted 6 lines
lib/power/rte_power_qos.c new file +6
-0+if (latency ==0 ) +sprintf (buf,"%s" ,"n/a" ); +else if (latency ==RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ) +sprintf (buf,"%u" ,0 ); +else +sprintf (buf,"%u" , latency);Use snprintf instead.
Ack
Quoted 1 line
.
PATCH v4 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
examples/l3fwd-power/main.c +28 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2259,6 +2260,24 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2298,6 +2317,15 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
v5 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + examples/l3fwd-power/main.c | 28 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 7 files changed, 247 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v5 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 6 files changed, 219 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +24 -0
@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -89,6 +89,10 @@ New Features * Added SSE/NEON vector datapath. +* **Introduce PM QoS interface.** + + * Introduce per-CPU PM QoS interface to low the delay after sleep. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +114 -0
114 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +2 -0
@@ -51,4 +51,6 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
Re: [PATCH v5 1/2] power: introduce PM QoS API on CPU wide
Hi Huisong,
I knew that this patchset was based on the *dpdk-next-net* repository in our previous communication. However, maybe it's better to rebase this pactchset on the *dpdk* repository. Because the CI system is not smart enough to recognize the patchset as a change for the *dpdk-next-net* repository. I personally feel this patchset is more likely a change for the *dpdk* repository because it modified the lib directory which is the infrastructure of DPDK instead of a feature for *dpdk-next-net*.
Best regard,
Min Zhou
Quoted 25 lines · Huisong Li
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 6 files changed, 219 insertions(+)create mode 100644
lib/power/rte_power_qos.c
create mode 100644lib/power/rte_power_qos.h
<snip>
Re: [PATCH v5 1/2] power: introduce PM QoS API on CPU wide
Hi
Quoted 4 lines · zhoumin
Hi Huisong,
I knew that this patchset was based on the *dpdk-next-net* repository in our previous communication. However, maybe it's better to rebase this pactchset on the *dpdk* repository. Because the CI system is not smart enough to recognize the patchset as a change for the *dpdk-next-net* repository. I personally feel this patchset is more likely a change for the *dpdk* repository because it modified the
libdirectory which is the infrastructure of DPDK instead of a feature for *dpdk-next-net*.
Generally, the 'dpdk-next-net' repo is ahead of 'dpdk' repo. And we make some development based on 'dpdk-next-net' repo.
I found that there are some patches also happen to the same issue that CI applt patch failed. So I think the reason why this series trigger warning should be analyzed and resolved.
Quoted 30 lines · Huisong Li
Quoted 22 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>---
doc/guides/prog_guide/power_man.rst | 24 ++++++doc/guides/rel_notes/release_24_07.rst| 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 +Quoted 3 lines
6 files changed, 219 insertions(+)create mode 100644
lib/power/rte_power_qos.c
create mode 100644lib/power/rte_power_qos.h<snip>
.
PATCH v5 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
examples/l3fwd-power/main.c +28 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2259,6 +2260,24 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2298,6 +2317,15 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
v6 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + examples/l3fwd-power/main.c | 28 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 7 files changed, 247 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v6 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 6 files changed, 219 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +24 -0
@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -155,6 +155,10 @@ New Features Added an API that allows the user to reclaim the defer queue with RCU. +* **Introduce per-CPU PM QoS interface.** + + * Introduce per-CPU PM QoS interface to low the delay after sleep. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +114 -0
114 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +2 -0
@@ -51,4 +51,6 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
PATCH v6 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
examples/l3fwd-power/main.c +28 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2259,6 +2260,24 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2298,6 +2317,15 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ; +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
Re: [PATCH v6 2/2] examples/l3fwd-power: add PM QoS configuration
examples/l3fwd-power/main.c init_power_library(void) · line 2266
Quoted 4 lines · On Tue, 9 Jul 2024 10:29:27 +0800 Huisong Li <[email protected]> wrote:
examples/l3fwd-power/main.c +3
-0+RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ;
Why do you need this check? RTE_LCORE_FOREACH calls rte_next_lcore which already skips lcores that are not enabled.
Re: [PATCH v6 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 9 lines · Stephen Hemminger
examples/l3fwd-power/main.c init_power_library(void) · line 2266
Quoted 4 lines · On Tue, 9 Jul 2024 10:29:27 +0800 Huisong Li <[email protected]> wrote:
examples/l3fwd-power/main.c +3
-0+RTE_LCORE_FOREACH (lcore_id) { +if (rte_lcore_is_enabled (lcore_id) ==0 ) +continue ;Why do you need this check?
RTE_LCORE_FOREACHcallsrte_next_lcorewhich already skips lcores that are not enabled.
Yes, it is dead code. will delete it in next version. Thanks.
Quoted 1 line
.
v7 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + examples/l3fwd-power/main.c | 24 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 7 files changed, 243 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v7 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 6 files changed, 219 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +24 -0
@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -155,6 +155,10 @@ New Features Added an API that allows the user to reclaim the defer queue with RCU. +* **Introduce per-CPU PM QoS interface.** + + * Introduce per-CPU PM QoS interface to low the delay after sleep. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +114 -0
114 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +2 -0
@@ -51,4 +51,6 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
PATCH v7 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
examples/l3fwd-power/main.c +24 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2259,6 +2260,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2298,6 +2315,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
v8 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + examples/l3fwd-power/main.c | 24 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 7 files changed, 243 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v8 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_07.rst | 4 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 2 + 6 files changed, 219 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +24 -0
@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_07.rst +4 -0
@@ -156,6 +156,10 @@ New Features * Added defer queue reclamation via RCU. * Added SVE support for bulk lookup. +* **Introduce per-CPU PM QoS interface.** + + * Introduce per-CPU PM QoS interface to low the delay after sleep. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +114 -0
114 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +2 -0
@@ -51,4 +51,6 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
PATCH v8 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
examples/l3fwd-power/main.c +24 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2259,6 +2260,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2298,6 +2315,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
v9 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ examples/l3fwd-power/main.c | 24 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 7 files changed, 246 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v9 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 114 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 6 files changed, 222 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +24 -0
@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the delay after sleep by controlling + CPU idle state selection. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +114 -0
114 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency; };
Signature · 1 line
2.22.0
Re: [PATCH v9 1/2] power: introduce PM QoS API on CPU wide
Hi Huisong
Please see comments inline.
Thanks
Quoted 16 lines · Huisong Li
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>---
...
Quoted 17 lines
lib/power/rte_power_qos.c new file +11
-0@@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <rte_lcore.h> +#include <rte_log.h> +
lib/power/rte_power_qos.c line 21
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+#include "power_common.h" +#include "rte_power_qos.h" + +#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us" + +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[LINE_MAX ];
no need LINE_MAX, [32] would enough.
Quoted 12 lines
lib/power/rte_power_qos.c new file +12
-0+FILE *f; +int ret; + +if (!rte_lcore_is_enabled (lcore_id)) { +POWER_LOG (ERR ,"lcore id %u is not enabled" , lcore_id); +return -EINVAL ; + } + +if (latency <0 ) { +POWER_LOG (ERR ,"latency should be greater than and equal to 0" ); +return -EINVAL ; + }
lib/power/rte_power_qos.c line 43
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+ + ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meanning
meanning -> meaning
Quoted 6 lines
lib/power/rte_power_qos.c new file +6
-0+* is as follows for different input string. +* 1> the resume latency is 0 if the input is "n/a". +* 2> the resume latency is no constraint if the input is "0". +* 3> the resume latency is the actual value to be set. +*/ +if (latency ==0 )
lib/power/rte_power_qos.c line 59
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+snprintf (buf,sizeof (buf),"%s" ,"n/a" ); + else if (latency == RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT) + snprintf(buf, sizeof(buf), "%u", 0); + else + snprintf(buf, sizeof(buf), "%u", latency); + + ret = write_core_sysfs_s(f, buf); + if (ret != 0) { + POWER_LOG(ERR, "Failed to write "PM_QOS_SYSFILE_RESUME_LATENCY_US, lcore_id); + goto out;
no need of goto
lib/power/rte_power_qos.c line 64
Quoted 5 lines
lib/power/rte_power_qos.c new file +5
-0+ } + +out: +if (f !=NULL ) +fclose (f);
just fclose(f) because f is valid here.
Quoted 22 lines
lib/power/rte_power_qos.c new file +22
-0+ +return ret; +} + +int +rte_power_qos_get_cpu_resume_latency (uint16_t lcore_id) +{ +char buf[LINE_MAX ]; +int latency =-1 ; +FILE *f; +int ret; + +if (!rte_lcore_is_enabled (lcore_id)) { +POWER_LOG (ERR ,"lcore id %u is not enabled" , lcore_id); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"r" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + }
lib/power/rte_power_qos.c line 96
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+ + ret =read_core_sysfs_s (f, buf,sizeof (buf)); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to read " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); + goto out; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meanning
meanning -> meaning
Quoted 5 lines
lib/power/rte_power_qos.c new file +5
-0+* is as follows for different output string. +* 1> the resume latency is 0 if the output is "n/a". +* 2> the resume latency is no constraint if the output is "0". +* 3> the resume latency is the actual value in used for other string. +*/
lib/power/rte_power_qos.c line 111
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+if (strcmp (buf,"n/a" ) ==0 ) + latency =0 ; +else { + latency =strtoul (buf,NULL ,10 ); + latency = latency ==0 ?RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT : latency; + } + +out: +if (f !=NULL ) +fclose (f);
just fclose(f) because f is valid here.
Quoted 87 lines
lib/power/rte_power_qos.c new file +3
-0+ +return latency !=-1 ? latency : ret; +}lib/power/rte_power_qos.h new file +73
-0@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <stdint.h> + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @file rte_power_qos.h +* +* PM QoS API. +* +* The CPU-wide resume latency limit has a positive impact on this CPU's idle +* state selection in each cpuidle governor. +* Please see the PM QoS on CPU wide in the following link: +* https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-latency-us +* +* The deeper the idle state, the lower the power consumption, but the +* longer the resume time. Some service are delay sensitive and very except the +* low resume time, like interrupt packet receiving mode. +* +* In these case, per-CPU PM QoS API can be used to control this CPU's idle +* state selection and limit just enter the shallowest idle state to low the +* delay after sleep by setting strict resume latency (zero value). +*/ + +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1)) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* @param lcore_id +* target logical core id +* +* @param latency +* The latency should be greater than and equal to zero in microseconds unit. +* +* @return +* 0 on success. Otherwise negative value is returned. +*/ +__rte_experimental +int rte_power_qos_set_cpu_resume_latency(uint16_t lcore_id, int latency); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Get the current resume latency of this logical core. +* The default value in kernel is @see RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT +* if don't set it. +* +* @return +* Negative value on failure. +* >= 0 means the actual resume latency limit on this core. +*/ +__rte_experimental +int rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_QOS_H */ lib/power/version.map +0
-0
lib/power/version.map EXPERIMENTAL { · line 57
Quoted 7 lines
lib/power/version.map +4
-0@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency;
order by alphabetic.
another question, I think rename cpu with core maybe more accurate, despite sysfs export with cpu, but in DPDK it means core. and there are some rte_power_core_xxx name in rte_power library, I think better to keep the same.
Quoted 2 lines
lib/power/version.map +0
-0};
Re: [PATCH v9 1/2] power: introduce PM QoS API on CPU wide
Hi Chengwen,
Thanks for your review.
Quoted 45 lines · fengchengwen
Hi Huisong
Please see comments inline.
Thanks
Quoted 16 lines · Huisong Li
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>---
...
Quoted 20 lines
lib/power/rte_power_qos.c new file +14
-0@@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <rte_lcore.h> +#include <rte_log.h> + +#include "power_common.h" +#include "rte_power_qos.h" +
Quoted 8 lines
lib/power/rte_power_qos.c line 21
Quoted 7 lines
lib/power/rte_power_qos.c new file +7
-0+#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us" + +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[LINE_MAX ];no need
LINE_MAX, [32] would enough.
Ack
Quoted 16 lines
Quoted 16 lines
lib/power/rte_power_qos.c new file +15
-0+FILE *f; +int ret; + +if (!rte_lcore_is_enabled (lcore_id)) { +POWER_LOG (ERR ,"lcore id %u is not enabled" , lcore_id); +return -EINVAL ; + } + +if (latency <0 ) { +POWER_LOG (ERR ,"latency should be greater than and equal to 0" ); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +if (ret !=0 ) {
Quoted 8 lines
lib/power/rte_power_qos.c line 43
Quoted 7 lines
lib/power/rte_power_qos.c new file +7
-0+POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meanning meanning -> meaning
Ack
Quoted 10 lines
Quoted 10 lines
lib/power/rte_power_qos.c new file +9
-0+* is as follows for different input string. +* 1> the resume latency is 0 if the input is "n/a". +* 2> the resume latency is no constraint if the input is "0". +* 3> the resume latency is the actual value to be set. +*/ +if (latency ==0 ) +snprintf (buf,sizeof (buf),"%s" ,"n/a" ); +else if (latency ==RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ) +snprintf (buf,sizeof (buf),"%u" ,0 );
Quoted 8 lines
lib/power/rte_power_qos.c line 59
Quoted 7 lines
lib/power/rte_power_qos.c new file +7
-0+else +snprintf (buf,sizeof (buf),"%u" , latency); + + ret =write_core_sysfs_s (f, buf); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to write " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); + goto out;no need of goto
Ack
Quoted 7 lines
lib/power/rte_power_qos.c line 64
Quoted 6 lines
lib/power/rte_power_qos.c new file +5
-0+ } + +out: +if (f !=NULL ) +fclose (f);just fclose(f) because f is valid here.
Ack
Quoted 25 lines
Quoted 25 lines
lib/power/rte_power_qos.c new file +25
-0+ +return ret; +} + +int +rte_power_qos_get_cpu_resume_latency (uint16_t lcore_id) +{ +char buf[LINE_MAX ]; +int latency =-1 ; +FILE *f; +int ret; + +if (!rte_lcore_is_enabled (lcore_id)) { +POWER_LOG (ERR ,"lcore id %u is not enabled" , lcore_id); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"r" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + } + + ret =read_core_sysfs_s (f, buf,sizeof (buf)); +if (ret !=0 ) {
Quoted 8 lines
lib/power/rte_power_qos.c line 96
Quoted 7 lines
lib/power/rte_power_qos.c new file +7
-0+POWER_LOG (ERR ,"Failed to read " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); + goto out; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meanning meanning -> meaning
Ack
Quoted 17 lines
Quoted 6 lines
lib/power/rte_power_qos.c new file +5
-0+* is as follows for different output string. +* 1> the resume latency is 0 if the output is "n/a". +* 2> the resume latency is no constraint if the output is "0". +* 3> the resume latency is the actual value in used for other string. +*/ lib/power/rte_power_qos.c line 111
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+if (strcmp (buf,"n/a" ) ==0 ) + latency =0 ; +else { + latency =strtoul (buf,NULL ,10 ); + latency = latency ==0 ?RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT : latency; + } + +out: +if (f !=NULL ) +fclose (f);just fclose(f) because f is valid here.
Ack
Quoted 88 lines
Quoted 88 lines
lib/power/rte_power_qos.c new file +3
-0+ +return latency !=-1 ? latency : ret; +}lib/power/rte_power_qos.h new file +73
-0@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <stdint.h> + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @file rte_power_qos.h +* +* PM QoS API. +* +* The CPU-wide resume latency limit has a positive impact on this CPU's idle +* state selection in each cpuidle governor. +* Please see the PM QoS on CPU wide in the following link: +* https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-latency-us +* +* The deeper the idle state, the lower the power consumption, but the +* longer the resume time. Some service are delay sensitive and very except the +* low resume time, like interrupt packet receiving mode. +* +* In these case, per-CPU PM QoS API can be used to control this CPU's idle +* state selection and limit just enter the shallowest idle state to low the +* delay after sleep by setting strict resume latency (zero value). +*/ + +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1)) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* @param lcore_id +* target logical core id +* +* @param latency +* The latency should be greater than and equal to zero in microseconds unit. +* +* @return +* 0 on success. Otherwise negative value is returned. +*/ +__rte_experimental +int rte_power_qos_set_cpu_resume_latency(uint16_t lcore_id, int latency); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Get the current resume latency of this logical core. +* The default value in kernel is @see RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT +* if don't set it. +* +* @return +* Negative value on failure. +* >= 0 means the actual resume latency limit on this core. +*/ +__rte_experimental +int rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_QOS_H */ lib/power/version.map +0
-0@@ -51,4 +51,8 @@ EXPERIMENTAL {
Quoted 8 lines
lib/power/version.map EXPERIMENTAL { · line 57
Quoted 7 lines
lib/power/version.map +4
-0rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency;order by alphabetic.
Ack
Quoted 3 lines
another question, I think rename cpu with core maybe more accurate, despite sysfs export with cpu, but in DPDK it means core. and there are some
rte_power_core_xxxname inrte_powerlibrary, I think better to keep the same.
Firstly, the rte_power_qos_set/get_cpu_resume_latency is just consistent with linux sysfs interface. Having the same name is more releative for user. In addition, Sivaprasad Tummala is reworking power library and the name of rte_power_core_xxx also might be changed.
Quoted 4 lines
lib/power/version.map EXPERIMENTAL { · line 58
Quoted 3 lines
lib/power/version.map +0
-0};.
Re: [PATCH v9 1/2] power: introduce PM QoS API on CPU wide
Quoted 30 lines · lihuisong (C)
Hi Chengwen,
Thanks for your review.
Quoted 25 lines · fengchengwen
Hi Huisong
Please see comments inline.
Thanks
Quoted 16 lines · Huisong Li
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>---
...
...
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
lib/power/version.map +0
-0@@ -51,4 +51,8 @@ EXPERIMENTAL {Quoted 8 lines
lib/power/version.map EXPERIMENTAL { · line 57
Quoted 7 lines
lib/power/version.map +4
-0rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_set_cpu_resume_latency; + rte_power_qos_get_cpu_resume_latency;order by alphabetic.
Quoted 6 lines
Ack
Quoted 3 lines
another question, I think rename cpu with core maybe more accurate, despite sysfs export with cpu, but in DPDK it means core. and there are some
rte_power_core_xxxname inrte_powerlibrary, I think better to keep the same.Firstly, the rte_power_qos_set/get_cpu_resume_latency is just consistent with linux sysfs interface. Having the same name is more releative for user. In addition, Sivaprasad Tummala is reworking power library and the name of
rte_power_core_xxxalso might be changed.
ok
Quoted 4 lines
Quoted 4 lines
lib/power/version.map EXPERIMENTAL { · line 58
Quoted 3 lines
lib/power/version.map +0
-0};.
PATCH v9 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
examples/l3fwd-power/main.c +24 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on CPU%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
Re: [PATCH v9 2/2] examples/l3fwd-power: add PM QoS configuration
Hi Huisong,
Quoted 26 lines · Huisong Li
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +2
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } +
examples/l3fwd-power/main.c init_power_library(void) · line 2274
Quoted 10 lines
examples/l3fwd-power/main.c +10
-0+RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { + RTE_LOG(ERR, L3FWD_POWER, + "Failed to set strict resume latency on CPU%u.\n",
suggest on core%u and use if (ret != 0)
and how about use warning, if current system don't support it, we just give a warning message but let's it continue.
Quoted 23 lines
examples/l3fwd-power/main.c +12
-0+ lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Re: [PATCH v9 2/2] examples/l3fwd-power: add PM QoS configuration
Hi chengwen,
Quoted 32 lines · fengchengwen
Hi Huisong,
Quoted 29 lines · Huisong Li
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +5
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow
Quoted 8 lines
examples/l3fwd-power/main.c init_power_library(void) · line 2274
Quoted 7 lines
examples/l3fwd-power/main.c +7
-0+* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret <0 ) { + RTE_LOG(ERR, L3FWD_POWER, + "Failed to set strict resume latency on CPU%u.\n",suggest on core%u and use if (ret != 0)
Ack
Quoted 3 lines
and how about use warning, if current system don't support it, we just give a warning message but let's it continue.
Because power lib is just supported and compiled on Linux.
And Linux always enable this feature. So Linux always support it.
I don't know what it would be like to compile l3fwd-power on windows.
But this is the another issue and other power APIs, like rte_power_init, are used directly in l3fwd-power without any condition. So how about contiue to use error message?
Quoted 26 lines
Quoted 15 lines
examples/l3fwd-power/main.c +5
-0+ lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } }examples/l3fwd-power/main.c deinit_power_library(void) · line 2328
Quoted 10 lines
examples/l3fwd-power/main.c +7
-0+ +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }.
Re: [PATCH v9 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 48 lines · lihuisong (C)
Hi chengwen,
Quoted 31 lines · fengchengwen
Hi Huisong,
Quoted 28 lines · Huisong Li
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>---
examples/l3fwd-power/main.c| 24 ++++++++++++++++++++++++1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +5
-0@@ -47,6 +47,7 @@ #include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"@@ -2260,6 +2261,22 @@ init_power_library(void) return -1; } } + + RTE_LCORE_FOREACH(lcore_id) { + /* +* Set the worker lcore's to have strict latency limit to allow Quoted 8 lines
examples/l3fwd-power/main.c init_power_library(void) · line 2274
Quoted 7 lines
examples/l3fwd-power/main.c +7
-0+* the CPU to enter the shallowest idle state. +*/ + ret = rte_power_qos_set_cpu_resume_latency(lcore_id, + RTE_POWER_QOS_STRICT_LATENCY_VALUE); + if (ret < 0) { + RTE_LOG(ERR, L3FWD_POWER, + "Failed to set strict resume latency on CPU%u.\n",suggest on core%u and use if (ret != 0)
Ack
Quoted 3 lines
and how about use warning, if current system don't support it, we just give a warning message but let's it continue.
Quoted 5 lines
Because power lib is just supported and compiled on Linux.
And Linux always enable this feature. So Linux always support it.
I don't know what it would be like to compile l3fwd-power on windows.
But this is the another issue and other power APIs, likerte_power_init, are used directly in l3fwd-power without any condition. So how about contiue to use error message?
ok
Quoted 24 lines
Quoted 24 lines
Quoted 20 lines
examples/l3fwd-power/main.c +5
-0+ lcore_id); + return ret; + } + } + return ret; } @@ -2299,6 +2316,13 @@ deinit_power_library(void)}
}
}examples/l3fwd-power/main.c +7
-0+ + RTE_LCORE_FOREACH(lcore_id) { + /* Restore the original value in kernel. */ + rte_power_qos_set_cpu_resume_latency(lcore_id, + RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT); + } +Quoted 3 lines
return ret;
}.
v10 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v10:
- replace LINE_MAX with a custom macro and fix two typos.
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ examples/l3fwd-power/main.c | 24 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 111 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 7 files changed, 243 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v10 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 111 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 6 files changed, 219 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +24 -0
@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the delay after sleep by controlling + CPU idle state selection. + Removed Items -------------
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'
lib/power/rte_power_qos.c new file +111 -0
111 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; };
Signature · 1 line
2.22.0
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Quoted 14 lines · On Thu, 12 Sep 2024 10:38:11 +0800 Huisong Li <[email protected]> wrote:
doc/guides/prog_guide/power_man.rst +14
-0+ +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based
doc/guides/prog_guide/power_man.rst Get Num Pkgs · line 275
Quoted 10 lines
doc/guides/prog_guide/power_man.rst +10
-0+on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. +
These paragraphs need some editing help. The wording is awkward, it uses passive voice, and does not seemed directed at a user audience. If you need help, a writer or AI might help clarify.
It also ends up in the section associated with Intel UnCore. It would be better after the Turbo Boost section.
lib/power/rte_power_qos.c line 41
Quoted 5 lines
lib/power/rte_power_qos.c new file +5
-0+ ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + }
The function open_core_sysfs_file() should have been written to return FILE * and then it could have same attributes as fopen().
The message should include the error reason.
if (open_core_sysfs_file(&f, "w", PM_QOS_SYSFILE_RESUME_LATENCY_US, lcore_id)) {
POWER_LOG(ERR, "Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US ": %s",
lcore_id, strerror(errno));Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Hi Stephen,
Quoted 22 lines · Stephen Hemminger
Quoted 19 lines · On Thu, 12 Sep 2024 10:38:11 +0800 Huisong Li <[email protected]> wrote:
doc/guides/prog_guide/power_man.rst +19
-0+ +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume
Quoted 8 lines
doc/guides/prog_guide/power_man.rst Get Num Pkgs · line 275
Quoted 5 lines
doc/guides/prog_guide/power_man.rst +5
-0+latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. +These paragraphs need some editing help. The wording is awkward, it uses passive voice, and does not seemed directed at a user audience. If you need help, a writer or AI might help clarify.
How about the following description:
-->
The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
The ``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` can set and get the CPU resume latency based on this per-CPU sysfs.
The ``rte_power_qos_set_cpu_resume_latency()`` can control the CPU's idle state selection and limit to enter the shallowest idle state to low the delay of resuming service by setting strict resume latency (zero value) so as to get better performance.
Quoted 3 lines
It also ends up in the section associated with Intel UnCore. It would be better after the Turbo Boost section.
Ack
Quoted 10 lines
lib/power/rte_power_qos.c line 41
Quoted 8 lines
lib/power/rte_power_qos.c new file +5
-0+ ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + }The function
open_core_sysfs_file()should have been written to return FILE * and then it could have same attributes asfopen().
Do you mean we should save this handle for directly using it to get or set this resume latency?
If it is I understand, we cannot do it like this. Because qos driver in Linux use the "noop_llseek()" as the .llseek API.
Quoted 6 lines
The message should include the error reason.
if (open_core_sysfs_file(&f, "w", PM_QOS_SYSFILE_RESUME_LATENCY_US, lcore_id)) { POWER_LOG(ERR, "Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US ": %s", lcore_id, strerror(errno));
Good idea. Thanks.
Quoted 2 lines
.
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Hi Stephen,
Can you take a look at this reply so as to send out the next version ASAP? Thanks.😁
/Huisong
Quoted 90 lines · lihuisong (C)
Hi Stephen,
Quoted 32 lines · Stephen Hemminger
Quoted 29 lines · On Thu, 12 Sep 2024 10:38:11 +0800 Huisong Li <[email protected]> wrote:
doc/guides/prog_guide/power_man.rst +5
-0+ +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but thelonger
+the resume time. Some service are delay sensitive and very except the lowdoc/guides/prog_guide/power_man.rst +3
-0+resume time, like interrupt packet receiving mode. + +And the"
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for
+userspace. Each cpuidle governor in Linux select which idle state to enterdoc/guides/prog_guide/power_man.rst +3
-0+based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resumelatency based
doc/guides/prog_guide/power_man.rst +3
-0+on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can controlthe CPU's
+idle state selection in Linux and limit just to enter the shallowest idle state
+to low the delay of resuming service after sleeping by setting strict resume
+latency (zero value).Quoted 8 lines
doc/guides/prog_guide/power_man.rst Get Num Pkgs · line 275
Quoted 5 lines
(quoted diff) +2
-0+ +The ``rte_power_qos_get_cpu_resume_latency()`` function can get theresume
doc/guides/prog_guide/power_man.rst +2
-0+latency on specified CPU. +These paragraphs need some editing help. The wording is awkward, it uses passive voice, and does not seemed directed at a user audience. If you need help, a writer or AI might help clarify.
How about the following description:
-->
The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
The ``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` can set and get the CPU resume latency based on this per-CPU sysfs.
The ``rte_power_qos_set_cpu_resume_latency()`` can control the CPU's idle state selection and limit to enter the shallowest idle state to low the delay of resuming service by setting strict resume latency (zero value) so as to get better performance.
Quoted 3 lines
It also ends up in the section associated with Intel UnCore. It would be better after the Turbo Boost section.
Ack
Quoted 10 lines
Quoted 10 lines
+ ret = open_core_sysfs_file(&f, "w",
PM_QOS_SYSFILE_RESUME_LATENCY_US,lcore_id);
+ if (ret != 0) {
+ POWER_LOG(ERR, "Failed to open
"PM_QOS_SYSFILE_RESUME_LATENCY_US,lcore_id);
+ return ret;
+ }Quoted 2 lines
The function
open_core_sysfs_file()should have been written to return FILE * and then it could have same attributes asfopen().Do you mean we should save this handle for directly using it to get or set this resume latency?
If it is I understand, we cannot do it like this. Because qos driver in Linux use the "noop_llseek()" as the .llseek API.Quoted 6 lines
The message should include the error reason.
if (
open_core_sysfs_file(&f, "w", PM_QOS_SYSFILE_RESUME_LATENCY_US, lcore_id)) {POWER_LOG(ERR, "Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US ": %s", lcore_id, strerror(errno));Good idea. Thanks.
Quoted 2 lines
.
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Quoted 7 lines · On Tue, 15 Oct 2024 17:41:39 +0800 "lihuisong (C)" <[email protected]> wrote:
Hi Stephen,
Can you take a look at this reply so as to send out the next version ASAP? Thanks.😁
/Huisong
在 2024/10/14 20:19, lihuisong (C) 写道:
The biggest issue is that lcore is not the same as cpu as far as kernel is concerned. DPDK support mapping lcore to a cpuset, and that is not necessarily the same one-to-one mapping as values in sysfs. In documentation of eal see.
For example, "--lcores='1,2@(5-7),(3-5)@(0,2),(0,6),7-8'" which means start 9 EAL thread;
lcore 0 runs on cpuset 0x41 (cpu 0,6);
lcore 1 runs on cpuset 0x2 (cpu 1);
lcore 2 runs on cpuset 0xe0 (cpu 5,6,7);
lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2);
lcore 6 runs on cpuset 0x41 (cpu 0,6);
lcore 7 runs on cpuset 0x80 (cpu 7);
lcore 8 runs on cpuset 0x100 (cpu 8).This problem existed in power library and this new API still has it.
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Hi Stephen,
Quoted 5 lines · Stephen Hemminger
Quoted 2 lines · On Tue, 15 Oct 2024 17:41:39 +0800 "lihuisong (C)" <[email protected]> wrote:
Hi Stephen,
Quoted 8 lines
Quoted 5 lines
Can you take a look at this reply so as to send out the next version ASAP? Thanks.😁
/Huisong
在 2024/10/14 20:19, lihuisong (C) 写道:The biggest issue is that lcore is not the same as cpu as far as kernel is concerned. DPDK support mapping lcore to a cpuset, and that is not necessarily the same one-to-one mapping as values in sysfs. In documentation of eal see.
Yes, you are right.
Quoted 11 lines
For example, "--lcores='1,2@(5-7),(3-5)@(0,2),(0,6),7-8'" which means start 9 EAL thread;
lcore 0 runs on cpuset 0x41 (cpu 0,6); lcore 1 runs on cpuset 0x2 (cpu 1); lcore 2 runs on cpuset 0xe0 (cpu 5,6,7); lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2); lcore 6 runs on cpuset 0x41 (cpu 0,6); lcore 7 runs on cpuset 0x80 (cpu 7); lcore 8 runs on cpuset 0x100 (cpu 8).This problem existed in power library and this new API still has it.
How about use lcore_config[lcore_id].cpuset to get the real cpu_id?
And for this case that application use '--lcores', we simply do some operations in power lib for all mapping CPUs in lcore's cpuset. If it is ok, I will fix it for the entire power library and this new API.
Quoted 2 lines
.
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Quoted 27 lines · On Thu, 17 Oct 2024 10:11:13 +0800 "lihuisong (C)" <[email protected]> wrote:
Hi Stephen,
Quoted 5 lines · Stephen Hemminger
Quoted 2 lines · On Tue, 15 Oct 2024 17:41:39 +0800 "lihuisong (C)" <[email protected]> wrote:
Hi Stephen,
Quoted 8 lines
Quoted 5 lines
Can you take a look at this reply so as to send out the next version ASAP? Thanks.😁
/Huisong
在 2024/10/14 20:19, lihuisong (C) 写道:The biggest issue is that lcore is not the same as cpu as far as kernel is concerned. DPDK support mapping lcore to a cpuset, and that is not necessarily the same one-to-one mapping as values in sysfs. In documentation of eal see.
Yes, you are right.
Quoted 10 lines
For example, "--lcores='1,2@(5-7),(3-5)@(0,2),(0,6),7-8'" which means start 9 EAL thread;
lcore 0 runs on cpuset 0x41 (cpu 0,6); lcore 1 runs on cpuset 0x2 (cpu 1); lcore 2 runs on cpuset 0xe0 (cpu 5,6,7); lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2); lcore 6 runs on cpuset 0x41 (cpu 0,6); lcore 7 runs on cpuset 0x80 (cpu 7); lcore 8 runs on cpuset 0x100 (cpu 8).
Quoted 6 lines
Quoted 1 line
This problem existed in power library and this new API still has it.
How about use lcore_config[lcore_id].cpuset to get the real
cpu_id? And for this case that application use '--lcores', we simply do some operations in power lib for all mapping CPUs in lcore's cpuset. If it is ok, I will fix it for the entire power library and this new API.Quoted 1 line
Using the lcore_config is the right direction but the cpuset may have more than one cpu, so the code needs to iterate over those cpus. Probably safe to ignore problems the case where user misconfigures to have two lcores using an overlapping set of cpu's like the example in the doc.
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Quoted 34 lines · Stephen Hemminger
Quoted 26 lines · On Thu, 17 Oct 2024 10:11:13 +0800 "lihuisong (C)" <[email protected]> wrote:
Hi Stephen,
Quoted 5 lines · Stephen Hemminger
Quoted 2 lines · On Tue, 15 Oct 2024 17:41:39 +0800 "lihuisong (C)" <[email protected]> wrote:
Hi Stephen,
Quoted 8 lines
Quoted 5 lines
Can you take a look at this reply so as to send out the next version ASAP? Thanks.😁
/Huisong
在 2024/10/14 20:19, lihuisong (C) 写道:The biggest issue is that lcore is not the same as cpu as far as kernel is concerned. DPDK support mapping lcore to a cpuset, and that is not necessarily the same one-to-one mapping as values in sysfs. In documentation of eal see.
Yes, you are right.
Quoted 9 lines
For example, "--lcores='1,2@(5-7),(3-5)@(0,2),(0,6),7-8'" which means start 9 EAL thread;
lcore 0 runs on cpuset 0x41 (cpu 0,6); lcore 1 runs on cpuset 0x2 (cpu 1); lcore 2 runs on cpuset 0xe0 (cpu 5,6,7); lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2); lcore 6 runs on cpuset 0x41 (cpu 0,6); lcore 7 runs on cpuset 0x80 (cpu 7); lcore 8 runs on cpuset 0x100 (cpu 8).Quoted 5 lines
Quoted 1 line
This problem existed in power library and this new API still has it.
How about use lcore_config[lcore_id].cpuset to get the real
cpu_id? And for this case that application use '--lcores', we simply do some operations in power lib for all mapping CPUs in lcore's cpuset. If it is ok, I will fix it for the entire power library and this new API.
Quoted 5 lines
Using the
lcore_configis the right direction but the cpuset may have more than one cpu, so the code needs to iterate over those cpus. Probably safe to ignore problems the case where user misconfigures to have two lcores using an overlapping set of cpu's like the example in the doc.
.
Yes, so we don't care this overlapping set case.
That's attributed to an usage issue and we just need to clearly comment this case's influence in doc, ok?
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
In reply to Stephen HemmingerHi Stephen,
The modification for this issue has been sent out. please have a look at v11, thanks.
/Huisong
Quoted 27 lines · Stephen Hemminger
Quoted 7 lines · On Tue, 15 Oct 2024 17:41:39 +0800 "lihuisong (C)" <[email protected]> wrote:
Hi Stephen,
Can you take a look at this reply so as to send out the next version ASAP? Thanks.😁
/Huisong
在 2024/10/14 20:19, lihuisong (C) 写道:The biggest issue is that lcore is not the same as cpu as far as kernel is concerned. DPDK support mapping lcore to a cpuset, and that is not necessarily the same one-to-one mapping as values in sysfs. In documentation of eal see.
For example, "--lcores='1,2@(5-7),(3-5)@(0,2),(0,6),7-8'" which means start 9 EAL thread;
lcore 0 runs on cpuset 0x41 (cpu 0,6); lcore 1 runs on cpuset 0x2 (cpu 1); lcore 2 runs on cpuset 0xe0 (cpu 5,6,7); lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2); lcore 6 runs on cpuset 0x41 (cpu 0,6); lcore 7 runs on cpuset 0x80 (cpu 7); lcore 8 runs on cpuset 0x100 (cpu 8).This problem existed in power library and this new API still has it.
.
RE: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
In reply to Huisong LiQuoted 130 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 111 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 6 files changed, 219 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.hdoc/guides/prog_guide/power_man.rst +24
-0@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------doc/guides/rel_notes/release_24_11.rst +5
-0@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the delay after sleep by controlling + CPU idle state selection. + Removed Items -------------lib/power/meson.build +2
-0@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'lib/power/rte_power_qos.c new file +27
-0@@ -0,0 +1,111 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <rte_lcore.h> +#include <rte_log.h> + +#include "power_common.h" +#include "rte_power_qos.h" + +#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us" + +#define PM_QOS_CPU_RESUME_LATENCY_BUF_LEN 32 + +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN ]; +FILE *f; +int ret; + +if (!rte_lcore_is_enabled (lcore_id)) {
lib/power/rte_power_qos.c line 37
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+POWER_LOG (ERR ,"lcore id %u is not enabled" , lcore_id); +return -EINVAL ; + } + +if (latency <0 ) { +POWER_LOG (ERR ,"latency should be greater than and equal to 0" ); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id);
That was already brought by Morten:lcore_id is not always equal to cpu_core_id (cpu affinity). Looking through power library it is not specific to that particular patch, but sort of common limitation (bug?) in rte_power lib.
Quoted 169 lines
lib/power/rte_power_qos.c new file +74
-0+if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning +* is as follows for different input string. +* 1> the resume latency is 0 if the input is "n/a". +* 2> the resume latency is no constraint if the input is "0". +* 3> the resume latency is the actual value to be set. +*/ +if (latency ==0 ) +snprintf (buf,sizeof (buf),"%s" ,"n/a" ); +else if (latency ==RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ) +snprintf (buf,sizeof (buf),"%u" ,0 ); +else +snprintf (buf,sizeof (buf),"%u" , latency); + + ret =write_core_sysfs_s (f, buf); +if (ret !=0 ) +POWER_LOG (ERR ,"Failed to write " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); + +fclose (f); + +return ret; +} + +int +rte_power_qos_get_cpu_resume_latency (uint16_t lcore_id) +{ +char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN ]; +int latency =-1 ; +FILE *f; +int ret; + +if (!rte_lcore_is_enabled (lcore_id)) { +POWER_LOG (ERR ,"lcore id %u is not enabled" , lcore_id); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"r" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + } + + ret =read_core_sysfs_s (f, buf,sizeof (buf)); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to read " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); + goto out; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning +* is as follows for different output string. +* 1> the resume latency is 0 if the output is "n/a". +* 2> the resume latency is no constraint if the output is "0". +* 3> the resume latency is the actual value in used for other string. +*/ +if (strcmp (buf,"n/a" ) ==0 ) + latency =0 ; +else { + latency =strtoul (buf,NULL ,10 ); + latency = latency ==0 ?RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT : latency; + } + +out: +fclose (f); + +return latency !=-1 ? latency : ret; +}lib/power/rte_power_qos.h new file +24
-0@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <stdint.h> + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file rte_power_qos.h + * + * PM QoS API. + * + * The CPU-wide resume latency limit has a positive impact on this CPU's idle + * state selection in each cpuidle governor. + * Please see the PM QoS on CPU wide in the following link: + * https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-latency-us
+ *
+ * The deeper the idle state, the lower the power consumption, but the
+ * longer the resume time. Some service are delay sensitive and very except the
+ * low resume time, like interrupt packet receiving mode.
+ *
+ * In these case, per-CPU PM QoS API can be used to control this CPU's idle
+ * state selection and limit just enter the shallowest idle state to low the
+ * delay after sleep by setting strict resume latency (zero value).
+ */lib/power/rte_power_qos.h new file +40
-0+ +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1)) + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* @param lcore_id +* target logical core id +* +* @param latency +* The latency should be greater than and equal to zero in microseconds unit. +* +* @return +* 0 on success. Otherwise negative value is returned. +*/ +__rte_experimental +int rte_power_qos_set_cpu_resume_latency(uint16_t lcore_id, int latency); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Get the current resume latency of this logical core. +* The default value in kernel is @see RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT +* if don't set it. +* +* @return +* Negative value on failure. +* >= 0 means the actual resume latency limit on this core. +*/ +__rte_experimental +int rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_QOS_H */ lib/power/version.map +4
-1@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; }; --2.22.0
Re: [PATCH v10 1/2] power: introduce PM QoS API on CPU wide
Hi Konstantin Ananyev,
Thanks for your review.
Quoted 133 lines · Konstantin Ananyev
Quoted 133 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- doc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 111 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 6 files changed, 219 insertions(+)create mode 100644
lib/power/rte_power_qos.c
create mode 100644lib/power/rte_power_qos.hdoc/guides/prog_guide/power_man.rst +24
-0@@ -249,6 +249,30 @@ Get Num Pkgs Get Num Dies Get the number of die's on a given package. + +PM QoS +------ + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are delay sensitive and very except the low +resume time, like interrupt packet receiving mode. + +And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The per-CPU PM QoS API can be used to set and get the CPU resume latency based +on this sysfs. + +The ``rte_power_qos_set_cpu_resume_latency()`` function can control the CPU's +idle state selection in Linux and limit just to enter the shallowest idle state +to low the delay of resuming service after sleeping by setting strict resume +latency (zero value). + +The ``rte_power_qos_get_cpu_resume_latency()`` function can get the resume +latency on specified CPU. + References ----------doc/guides/rel_notes/release_24_11.rst +5
-0@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the delay after sleep by controlling + CPU idle state selection. + Removed Items -------------lib/power/meson.build +2
-0@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) if cc.has_argument('-Wno-cast-qual') cflags += '-Wno-cast-qual'lib/power/rte_power_qos.c new file +31
-0@@ -0,0 +1,111 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <rte_lcore.h> +#include <rte_log.h> + +#include "power_common.h" +#include "rte_power_qos.h" + +#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us" + +#define PM_QOS_CPU_RESUME_LATENCY_BUF_LEN 32 + +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN ]; +FILE *f; +int ret; + +if (!rte_lcore_is_enabled (lcore_id)) { +POWER_LOG (ERR ,"lcore id %u is not enabled" , lcore_id); +return -EINVAL ; + } +
Quoted 8 lines
lib/power/rte_power_qos.c line 37
Quoted 6 lines
lib/power/rte_power_qos.c new file +6
-0+if (latency <0 ) { +POWER_LOG (ERR ,"latency should be greater than and equal to 0" ); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id);That was already brought by Morten:
lcore_idis not always equal tocpu_core_id(cpu affinity).
Yes, Morten also mentioned it.
And I tried to answer him, please find our previous disscussion, thanks. I think it's ok😁
Quoted 2 lines
Looking through power library it is not specific to that particular patch, but sort of common limitation (bug?) in
rte_powerlib.
Yes it is very common in power lib.
Quoted 7 lines
Quoted 7 lines
lib/power/rte_power_qos.c new file +5
-0+if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US , lcore_id); +return ret; + } +
<...>
PATCH v10 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
examples/l3fwd-power/main.c +24 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
RE: [PATCH v10 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 25 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +1
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ;
examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 10 lines
examples/l3fwd-power/main.c +8
-0} } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE );
I wonder why it is set to all worker cores silently and unconditionally? Wouldn't it be a change from current behavior of the power library?
Quoted 27 lines
examples/l3fwd-power/main.c +15
-1+if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
RE: [PATCH v10 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 30 lines
Quoted 30 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +4
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/*
Quoted 8 lines
examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 5 lines
examples/l3fwd-power/main.c +5
-0+* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE );I wonder why it is set to all worker cores silently and unconditionally? Wouldn't it be a change from current behavior of the power library?
s/library/sample app/
Quoted 28 lines
Quoted 28 lines
examples/l3fwd-power/main.c +15
-1+if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
Re: [PATCH v10 2/2] examples/l3fwd-power: add PM QoS configuration
In reply to Konstantin AnanyevHi Konstantin Ananyev,
Quoted 20 lines · Konstantin Ananyev
Quoted 20 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +1
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h>
Quoted 16 lines
Quoted 4 lines
examples/l3fwd-power/main.c +0
-0#include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ;examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 10 lines
examples/l3fwd-power/main.c +8
-0} } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE );I wonder why it is set to all worker cores silently and unconditionally? Wouldn't it be a change from current behavior of the power library?
L3fwd-power uses Rx interrupt to receive packet. Do you mean this setting should be for the core of Rx queue, right? This setting doesn't change the behavior of l3fwd-power. It is just for getting low resume latency when worker core wakes up from sleeping.
Quoted 28 lines
Quoted 28 lines
examples/l3fwd-power/main.c +15
-1+if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
RE: [PATCH v10 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 37 lines
Quoted 21 lines
Quoted 21 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +1
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> Quoted 16 lines
Quoted 4 lines
examples/l3fwd-power/main.c +0
-0#include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ;examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 10 lines
examples/l3fwd-power/main.c +8
-0} } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE );I wonder why it is set to all worker cores silently and unconditionally? Wouldn't it be a change from current behavior of the power library?
Quoted 1 line
L3fwd-power uses Rx interrupt to receive packet.
AFAIK, not exactly.
From what I remember l3fwd-power still runs RX in poll mode, thought it counts number of idle rx bursts.
As that number goes above some threshold, it puts itself into sleep with some timeout value.
Quoted 4 lines
Do you mean this
setting should be for the core of Rx queue, right?
This setting doesn't change the behavior of l3fwd-power. It is just for getting low resume latency when worker core wakes up from sleeping.
As understand your patch - you force CPU to select more shallow C state when entering such sleep.
Then it means that possible packet loss will be smaller,
but power consumption probably higher, correct?
If so, then it looks like a change from current behavior for that app, and we probably need to document what will be an expected change. Or probably as a better way - provider user with a way to choose, new cmdline option or so.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
examples/l3fwd-power/main.c +15
-1+if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
Re: [PATCH v10 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 36 lines · Konstantin Ananyev
Quoted 36 lines
Quoted 36 lines
Quoted 24 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +1
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ;examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 10 lines
examples/l3fwd-power/main.c +8
-0} } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE );I wonder why it is set to all worker cores silently and unconditionally? Wouldn't it be a change from current behavior of the power library?
Quoted 6 lines
Quoted 1 line
L3fwd-power uses Rx interrupt to receive packet.
AFAIK, not exactly.
From what I remember l3fwd-power still runs RX in poll mode,
thought it counts number of idle rx bursts.
As that number goes above some threshold, it puts itself into sleep with some timeout value.
Exactly.
Quoted 9 lines
Quoted 5 lines
Do you mean this
setting should be for the core of Rx queue, right?
This setting doesn't change the behavior of l3fwd-power. It is just for getting low resume latency when worker core wakes up from sleeping.As understand your patch - you force CPU to select more shallow C state when entering such sleep.
Then it means that possible packet loss will be smaller,
but power consumption probably higher, correct?
correct.
Quoted 4 lines
If so, then it looks like a change from current behavior for that app, and we probably need to document what will be an expected change. Or probably as a better way - provider user with a way to choose, new cmdline option or so.
Yes.
The power consumption may increase but the performance is better due to this patch if the platform enables cpuidle funtion. After all, this is just a very little point. It is enough to document this change or impact in doc of this API. Just let it more clear for user. What do you think?
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
examples/l3fwd-power/main.c +15
-1+if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
RE: [PATCH v10 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 25 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +1
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ;examples/l3fwd-power/main.c init_power_library(void) · line 2271
Quoted 10 lines
examples/l3fwd-power/main.c +8
-0} } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE );I wonder why it is set to all worker cores silently and unconditionally? Wouldn't it be a change from current behavior of the power library?
Quoted 6 lines
Quoted 1 line
L3fwd-power uses Rx interrupt to receive packet.
AFAIK, not exactly.
From what I remember l3fwd-power still runs RX in poll mode,
thought it counts number of idle rx bursts.
As that number goes above some threshold, it puts itself into sleep with some timeout value.Exactly.
Quoted 9 lines
Quoted 5 lines
Do you mean this
setting should be for the core of Rx queue, right?
This setting doesn't change the behavior of l3fwd-power. It is just for getting low resume latency when worker core wakes up from sleeping.As understand your patch - you force CPU to select more shallow C state when entering such sleep.
Then it means that possible packet loss will be smaller,
but power consumption probably higher, correct?
Quoted 8 lines
correct.
Quoted 4 lines
If so, then it looks like a change from current behavior for that app, and we probably need to document what will be an expected change. Or probably as a better way - provider user with a way to choose, new cmdline option or so.
Yes.
The power consumption may increase but the performance is better due to this patch if the platform enables cpuidle funtion.
Yes, that what I expect, and personally I am ok with that. Though I suspect different users who use this sample as some test-app might have different priorities in that tradeoff (power vs performance).
Quoted 3 lines
After all, this is just a very little point. It is enough to document this change or impact in doc of this API. Just let it more clear for user. What do you think?
I think yes, probably just updating docs (rel-notes, SG ?) will be enough. David Hunt, what are your thoughts here?
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
examples/l3fwd-power/main.c +15
-1+if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
Re: [PATCH v10 0/2] power: introduce PM QoS interface
In reply to Huisong LiQuoted 54 lines · Huisong Li
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v10:
- replaceLINE_MAXwith a custom macro and fix two typos.
v9:
- move new feature description fromrelease_24_07.rsttorelease_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead coderte_lcore_is_enabledin patch[2/2]
v6:
- updaterelease_24_07.rstbased on dpdk repo to resolve CI warning.
v5:
- useLINE_MAXto replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- addstdint.hinclude
- add Acked-by Morten Brørup <[email protected]>
v3:
- addRTE_POWER_xxxprefix for some macro in header
- add the check forlcore_idwithrte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wideHuisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configurationdoc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ examples/l3fwd-power/main.c | 24 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 111 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 7 files changed, 243 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Re: [PATCH v10 0/2] power: introduce PM QoS interface
Hi Thomas and Ferruh,
Kindly ping for merge.
/Huisong
Quoted 1 line · fengchengwen
Series-reviewed-by Chengwen Feng <[email protected]>
Thanks chengwen.
Quoted 57 lines · Huisong Li
Quoted 51 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
---
v10:
- replaceLINE_MAXwith a custom macro and fix two typos.
v9:
- move new feature description fromrelease_24_07.rsttorelease_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead coderte_lcore_is_enabledin patch[2/2]
v6:
- updaterelease_24_07.rstbased on dpdk repo to resolve CI warning.
v5:
- useLINE_MAXto replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- addstdint.hinclude
- add Acked-by Morten Brørup <[email protected]>
v3:
- addRTE_POWER_xxxprefix for some macro in header
- add the check forlcore_idwithrte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wideHuisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configurationdoc/guides/prog_guide/power_man.rst | 24 ++++++ doc/guides/rel_notes/release_24_11.rst | 5 ++ examples/l3fwd-power/main.c | 24 ++++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 111 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 ++++++++++++++++ lib/power/version.map | 4 + 7 files changed, 243 insertions(+)Quoted 3 lines
create mode 100644
lib/power/rte_power_qos.c
create mode 100644lib/power/rte_power_qos.h.
Re: [PATCH v10 0/2] power: introduce PM QoS interface
In reply to Huisong LiQuoted 10 lines · On Thu, 12 Sep 2024 10:38:10 +0800 Huisong Li <[email protected]> wrote:
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
Quoted 5 lines
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
This is not a direct critique of this patch.
The power library should have been designed to take a single configuration structure specifying CPU frequencies, wake up latency, and all the parameters from the kernel. And there would be a simple API with: rte_power_config_set() and rte_power_config_get().
Re: [PATCH v10 0/2] power: introduce PM QoS interface
Quoted 17 lines · Stephen Hemminger
Quoted 14 lines · On Thu, 12 Sep 2024 10:38:10 +0800 Huisong Li <[email protected]> wrote:
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay after sleep by setting strict resume latency (zero value).
Quoted 6 lines
Quoted 1 line
This is not a direct critique of this patch.
The power library should have been designed to take a single configuration structure specifying CPU frequencies, wake up latency, and all the parameters from the kernel. And there would be a simple API with:rte_power_config_set()andrte_power_config_get().
Agreed. There are several different configuration objects in power library.
It would be better if we could put the relevant configurations together.
This may be able to do it after Sivaprasad's optimized patches for core and uncore codes in power library.
Quoted 2 lines
.
v11 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
---
v11:
- operate the cpu id the lcore mapped by the new function power_get_lcore_mapped_cpu_id().
v10:
- replace LINE_MAX with a custom macro and fix two typos.
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (2):
power: introduce PM QoS API on CPU wide
examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + examples/l3fwd-power/main.c | 24 +++++ lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 7 files changed, 250 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v11 1/2 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +19 -0
@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -237,6 +237,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value to
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_qos.c new file +123 -0
123 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; };
Signature · 1 line
2.22.0
RE: [PATCH v11 1/2] power: introduce PM QoS API on CPU wide
Quoted 11 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
Quoted 6 lines
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>
LGTM overall, few nits, see below.
Quoted 128 lines
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.hdoc/guides/prog_guide/power_man.rst +19
-0@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------doc/guides/rel_notes/release_24_11.rst +5
-0@@ -237,6 +237,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value tolib/power/meson.build +2
-0@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']lib/power/rte_power_qos.c new file +46
-0@@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <rte_lcore.h> +#include <rte_log.h> + +#include "power_common.h" +#include "rte_power_qos.h" + +#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us" + +#define PM_QOS_CPU_RESUME_LATENCY_BUF_LEN 32 + +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN ]; +uint32_t cpu_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 ; + } + ret =power_get_lcore_mapped_cpu_id (lcore_id, &cpu_id); +if (ret !=0 ) +return ret; + +if (latency <0 ) { +POWER_LOG (ERR ,"latency should be greater than and equal to 0" ); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , cpu_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US " : %s" , + cpu_id,strerror (errno)); +return ret; + }
lib/power/rte_power_qos.c line 56
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+ +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning +* is as follows for different input string. +* 1> the resume latency is 0 if the input is "n/a". +* 2> the resume latency is no constraint if the input is "0". +* 3> the resume latency is the actual value to be set. +*/ +if (latency ==0 )
Why not to use your own macro:RTE_POWER_QOS_STRICT_LATENCY_VALUE
Instead of hard-coded constant here?
Quoted 47 lines
lib/power/rte_power_qos.c new file +47
-0+snprintf (buf,sizeof (buf),"%s" ,"n/a" ); + else if (latency == RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT) + snprintf(buf, sizeof(buf), "%u", 0); + else + snprintf(buf, sizeof(buf), "%u", latency); + + ret = write_core_sysfs_s(f, buf); + if (ret != 0) + POWER_LOG(ERR, "Failed to write "PM_QOS_SYSFILE_RESUME_LATENCY_US" : %s", + cpu_id, strerror(errno)); + + fclose(f); + + return ret; +} + +int +rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id) +{ + char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN]; + int latency = -1; + uint32_t cpu_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; + } + ret = power_get_lcore_mapped_cpu_id(lcore_id, &cpu_id); + if (ret != 0) + return ret; + + ret = open_core_sysfs_file(&f, "r", PM_QOS_SYSFILE_RESUME_LATENCY_US, cpu_id); + if (ret != 0) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US " : %s" , + cpu_id,strerror (errno)); +return ret; + } + + ret =read_core_sysfs_s (f, buf,sizeof (buf)); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to read " PM_QOS_SYSFILE_RESUME_LATENCY_US " : %s" , + cpu_id,strerror (errno)); + goto out; + } +
lib/power/rte_power_qos.c line 113
Quoted 10 lines
lib/power/rte_power_qos.c new file +10
-0+/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning +* is as follows for different output string. +* 1> the resume latency is 0 if the output is "n/a". +* 2> the resume latency is no constraint if the output is "0". +* 3> the resume latency is the actual value in used for other string. +*/ +if (strcmp (buf,"n/a" ) ==0 ) + latency =0 ;
RTE_POWER_QOS_STRICT_LATENCY_VALUE
?
Quoted 50 lines
lib/power/rte_power_qos.c new file +10
-0+else { + latency =strtoul (buf,NULL ,10 ); + latency = latency ==0 ?RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT : latency; + } + +out: +fclose (f); + +return latency !=-1 ? latency : ret; +}lib/power/rte_power_qos.h new file +24
-0@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <stdint.h> + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file rte_power_qos.h + * + * PM QoS API. + * + * The CPU-wide resume latency limit has a positive impact on this CPU's idle + * state selection in each cpuidle governor. + * Please see the PM QoS on CPU wide in the following link: + * https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-latency-us
+ *
+ * The deeper the idle state, the lower the power consumption, but the
+ * longer the resume time. Some service are delay sensitive and very except the
+ * low resume time, like interrupt packet receiving mode.
+ *
+ * In these case, per-CPU PM QoS API can be used to control this CPU's idle
+ * state selection and limit just enter the shallowest idle state to low the
+ * delay after sleep by setting strict resume latency (zero value).
+ */
lib/power/rte_power_qos.h line 36
Quoted 3 lines
lib/power/rte_power_qos.h new file +3
-0+ +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1))
Isn't it just INT32_MAX?
Quoted 51 lines
lib/power/rte_power_qos.h new file +36
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* @param lcore_id +* target logical core id +* +* @param latency +* The latency should be greater than and equal to zero in microseconds unit. +* +* @return +* 0 on success. Otherwise negative value is returned. +*/ +__rte_experimental +int rte_power_qos_set_cpu_resume_latency(uint16_t lcore_id, int latency); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Get the current resume latency of this logical core. +* The default value in kernel is @see RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT +* if don't set it. +* +* @return +* Negative value on failure. +* >= 0 means the actual resume latency limit on this core. +*/ +__rte_experimental +int rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_QOS_H */ lib/power/version.map +4
-1@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; }; --2.22.0
Re: [PATCH v11 1/2] power: introduce PM QoS API on CPU wide
Quoted 153 lines · Konstantin Ananyev
Quoted 10 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.Quoted 6 lines
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>LGTM overall, few nits, see below.
Quoted 134 lines
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+)create mode 100644
lib/power/rte_power_qos.c
create mode 100644lib/power/rte_power_qos.hdoc/guides/prog_guide/power_man.rst +19
-0@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------doc/guides/rel_notes/release_24_11.rst +5
-0@@ -237,6 +237,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value tolib/power/meson.build +2
-0@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']lib/power/rte_power_qos.c new file +52
-0@@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <rte_lcore.h> +#include <rte_log.h> + +#include "power_common.h" +#include "rte_power_qos.h" + +#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us" + +#define PM_QOS_CPU_RESUME_LATENCY_BUF_LEN 32 + +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) +{ +char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN ]; +uint32_t cpu_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 ; + } + ret =power_get_lcore_mapped_cpu_id (lcore_id, &cpu_id); +if (ret !=0 ) +return ret; + +if (latency <0 ) { +POWER_LOG (ERR ,"latency should be greater than and equal to 0" ); +return -EINVAL ; + } + + ret =open_core_sysfs_file (&f,"w" ,PM_QOS_SYSFILE_RESUME_LATENCY_US , cpu_id); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US " : %s" , + cpu_id,strerror (errno)); +return ret; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning +* is as follows for different input string. +* 1> the resume latency is 0 if the input is "n/a".
Quoted 8 lines
lib/power/rte_power_qos.c line 56
Quoted 4 lines
lib/power/rte_power_qos.c new file +4
-0+* 2> the resume latency is no constraint if the input is "0". +* 3> the resume latency is the actual value to be set. +*/ +if (latency ==0 )Why not to use your own macro:
RTE_POWER_QOS_STRICT_LATENCY_VALUE
Instead of hard-coded constant here?
you are right. will fix it in next version.
Quoted 52 lines
Quoted 52 lines
lib/power/rte_power_qos.c new file +51
-0+snprintf (buf,sizeof (buf),"%s" ,"n/a" ); + else if (latency == RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT) + snprintf(buf, sizeof(buf), "%u", 0); + else + snprintf(buf, sizeof(buf), "%u", latency); + + ret = write_core_sysfs_s(f, buf); + if (ret != 0) + POWER_LOG(ERR, "Failed to write "PM_QOS_SYSFILE_RESUME_LATENCY_US" : %s", + cpu_id, strerror(errno)); + + fclose(f); + + return ret; +} + +int +rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id) +{ + char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN]; + int latency = -1; + uint32_t cpu_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; + } + ret = power_get_lcore_mapped_cpu_id(lcore_id, &cpu_id); + if (ret != 0) + return ret; + + ret = open_core_sysfs_file(&f, "r", PM_QOS_SYSFILE_RESUME_LATENCY_US, cpu_id); + if (ret != 0) { +POWER_LOG (ERR ,"Failed to open " PM_QOS_SYSFILE_RESUME_LATENCY_US " : %s" , + cpu_id,strerror (errno)); +return ret; + } + + ret =read_core_sysfs_s (f, buf,sizeof (buf)); +if (ret !=0 ) { +POWER_LOG (ERR ,"Failed to read " PM_QOS_SYSFILE_RESUME_LATENCY_US " : %s" , + cpu_id,strerror (errno)); + goto out; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning +* is as follows for different output string.
Quoted 8 lines
lib/power/rte_power_qos.c line 113
Quoted 6 lines
lib/power/rte_power_qos.c new file +6
-0+* 1> the resume latency is 0 if the output is "n/a". +* 2> the resume latency is no constraint if the output is "0". +* 3> the resume latency is the actual value in used for other string. +*/ +if (strcmp (buf,"n/a" ) ==0 ) + latency =0 ;
RTE_POWER_QOS_STRICT_LATENCY_VALUE
Ack
Quoted 48 lines
?
Quoted 46 lines
lib/power/rte_power_qos.c new file +10
-0+else { + latency =strtoul (buf,NULL ,10 ); + latency = latency ==0 ?RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT : latency; + } + +out: +fclose (f); + +return latency !=-1 ? latency : ret; +}lib/power/rte_power_qos.h new file +24
-0@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <stdint.h> + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file rte_power_qos.h + * + * PM QoS API. + * + * The CPU-wide resume latency limit has a positive impact on this CPU's idle + * state selection in each cpuidle governor. + * Please see the PM QoS on CPU wide in the following link: + * https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?highlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-latency-us
+ *
+ * The deeper the idle state, the lower the power consumption, but the
+ * longer the resume time. Some service are delay sensitive and very except the
+ * low resume time, like interrupt packet receiving mode.
+ *
Quoted 8 lines
lib/power/rte_power_qos.h line 36
Quoted 7 lines
+ * In these case, per-CPU PM QoS API can be used to control this CPU's idle
+ * state selection and limit just enter the shallowest idle state to low the
+ * delay after sleep by setting strict resume latency (zero value).
+ */lib/power/rte_power_qos.h new file +3
-0+ +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ((int)(UINT32_MAX >> 1))Isn't it just
INT32_MAX?
will fix it.
Quoted 52 lines
Quoted 52 lines
lib/power/rte_power_qos.h new file +36
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* @param lcore_id +* target logical core id +* +* @param latency +* The latency should be greater than and equal to zero in microseconds unit. +* +* @return +* 0 on success. Otherwise negative value is returned. +*/ +__rte_experimental +int rte_power_qos_set_cpu_resume_latency(uint16_t lcore_id, int latency); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Get the current resume latency of this logical core. +* The default value in kernel is @see RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT +* if don't set it. +* +* @return +* Negative value on failure. +* >= 0 means the actual resume latency limit on this core. +*/ +__rte_experimental +int rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_QOS_H */ lib/power/version.map +4
-1@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; }; --2.22.0
PATCH v11 2/2 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiAdd PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
examples/l3fwd-power/main.c +24 -0
@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h"
@@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }
@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; }
Signature · 1 line
2.22.0
RE: [PATCH v11 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 5 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
I still think it is worth to mention this behavior change somewhere in the docs. Probably release_notes or sample app guides.
Quoted 58 lines
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +24
-1@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
Re: [PATCH v11 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 5 lines · Konstantin Ananyev
Quoted 3 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
I still think it is worth to mention this behavior change somewhere in the docs. Probably
release_notesor sample app guides.
I already added this influence to power_man.rst.
ok, I will add some comments about this into l3_forward_power_man.rst. How about put this comments at the end of "Overview"?
Quoted 57 lines
Quoted 57 lines
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +24
-1@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
RE: [PATCH v11 2/2] examples/l3fwd-power: add PM QoS configuration
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
I still think it is worth to mention this behavior change somewhere in the docs. Probably
release_notesor sample app guides.I already added this influence to
power_man.rst.
ok, I will add some comments about this intol3_forward_power_man.rst. How about put this comments at the end of "Overview"?
Works for me.
Konstantin
Quoted 57 lines
Quoted 57 lines
Quoted 57 lines
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +24
-1@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -2260,6 +2261,22 @@ init_power_library(void)return -1 ; } } + +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the worker lcore's to have strict latency limit to allow +* the CPU to enter the shallowest idle state. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_STRICT_LATENCY_VALUE ); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set strict resume latency on core%u.\n" , + lcore_id); +return ret; + } + } +return ret; }@@ -2299,6 +2316,13 @@ deinit_power_library(void) } } } + +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT ); + } +return ret; } --2.22.0
Re: [PATCH v11 2/2] examples/l3fwd-power: add PM QoS configuration
In reply to Konstantin AnanyevHi Konstantin,
Quoted 5 lines · Konstantin Ananyev
Quoted 3 lines
Add PM QoS configuration to declease the delay after sleep in case of entering deeper idle state.
I still think it is worth to mention this behavior change somewhere in the docs. Probably
release_notesor sample app guides.
I see some descriptions that application may enter deeper C-state in the "Overview" chapter of l3_forward_power_man.rst. So I feel it's better to add a new command parameter for it as you suggested.
Please have a look again, thanks.😁
Quoted 15 lines
Quoted 15 lines
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>--- examples/l3fwd-power/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)examples/l3fwd-power/main.c +1
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h>
<...>
Quoted 4 lines
Quoted 4 lines
}--
2.22.0
v12 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
---
v12:
- add Acked-by Chengwen and Konstantin
- fix overflow issue in l3fwd-power when parse command line
- add a command parameter to set CPU resume latency
v11:
- operate the cpu id the lcore mapped by the new function power_get_lcore_mapped_cpu_id().
v10:
- replace LINE_MAX with a custom macro and fix two typos.
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (3):
power: introduce PM QoS API on CPU wide examples/l3fwd-power: fix data overflow when parse command line examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 19 +++ doc/guides/rel_notes/release_24_11.rst | 5 + .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 92 +++++++++++-- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 ++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++ lib/power/version.map | 4 + 8 files changed, 308 insertions(+), 15 deletions(-) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v12 1/3 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +19 -0
@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -237,6 +237,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value to
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_qos.c new file +123 -0
123 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; };
Signature · 1 line
2.22.0
PATCH v12 2/3 examples/l3fwd-power: fix data overflow when parse command line
In reply to Huisong LiMany variables are 'uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They use parse_int() to parse it from command line. But overflow problem occurs when this function return.
--- examples/l3fwd-power/main.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
examples/l3fwd-power/main.c +16 -20
@@ -1525,7 +1525,7 @@ print_usage(const char *prgname) }static int -parse_int (const char *opt) +parse_uint32 (const char *opt,uint32_t *res) {char *end =NULL ;unsigned long val;
@@ -1535,23 +1535,14 @@ parse_int(const char *opt)if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return -1 ; -return val; -} - -static int parse_max_pkt_len (const char *pktlen) -{ -char *end =NULL ; -unsigned long len; - -/* parse decimal string */ - len =strtoul (pktlen, &end,10 ); -if ((pktlen[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +if (val >UINT32_MAX ) { +RTE_LOG (ERR ,L3FWD_POWER ,"parameter shouldn't exceed %u.\n" ,UINT32_MAX );return -1 ; + } -if (len ==0 ) -return -1 ; + *res = val; -return len; +return 0 ; } static int
@@ -1898,8 +1889,9 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_PKT_LEN ,sizeof (CMD_LINE_OPT_MAX_PKT_LEN ))) { +if (parse_uint32 (optarg, &max_pkt_len) !=0 ) +return -1 ;printf ("Custom frame size is configured\n" ); - max_pkt_len =parse_max_pkt_len (optarg); } if (!strncmp(lgopts[option_index].name,
@@ -1912,29 +1904,33 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_EMPTY_POLLS ,sizeof (CMD_LINE_OPT_MAX_EMPTY_POLLS ))) { +if (parse_uint32 (optarg, &max_empty_polls) !=0 ) +return -1 ;printf ("Maximum empty polls configured\n" ); - max_empty_polls =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PAUSE_DURATION ,sizeof (CMD_LINE_OPT_PAUSE_DURATION ))) { +if (parse_uint32 (optarg, &pause_duration) !=0 ) +return -1 ;printf ("Pause duration configured\n" ); - pause_duration =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MIN ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MIN ))) { +if (parse_uint32 (optarg, &scale_freq_min) !=0 ) +return -1 ;printf ("Scaling frequency minimum configured\n" ); - scale_freq_min =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MAX ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MAX ))) { +if (parse_uint32 (optarg, &scale_freq_max) !=0 ) +return -1 ;printf ("Scaling frequency maximum configured\n" ); - scale_freq_max =parse_int (optarg); }break ;
Signature · 1 line
2.22.0
RE: [PATCH v12 2/3] examples/l3fwd-power: fix data overflow when parse command line
Quoted 10 lines
Many variables are '
uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They useparse_int()to parse it from command line. But overflow problem occurs when this function return.Fixes 59f2853c4cae ("examples/l3fwd_power: add configuration options")Signed-off-by Huisong Li <[email protected]>---
Quoted 1 line
2.22.0
PATCH v12 3/3 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiThe '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 68 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-)
doc/guides/sample_app_ug/l3_forward_power_man.rst +4 -1
@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase power consumption of platform. .. note::
@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awareness
examples/l3fwd-power/main.c +68 -0
122 lines not on this page · raw message
Signature · 1 line
2.22.0
RE: [PATCH v12 3/3] examples/l3fwd-power: add PM QoS configuration
Quoted 116 lines
The '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 68 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/l3_forward_power_man.rst +2
-1@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase powerconsumption of platform.
.. note::
doc/guides/sample_app_ug/l3_forward_power_man.rst +2
-0@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awarenessexamples/l3fwd-power/main.c +30
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -265,6 +266,9 @@ static uint32_t pause_duration = 1;static uint32_t scale_freq_min;static uint32_t scale_freq_max; +static int cpu_resume_latency; +static bool pm_qos_en; +static struct rte_mempool * pktmbuf_pool[NB_SOCKETS ];@@ -1501,6 +1505,8 @@ print_usage(const char *prgname)" -U: set min/max frequency for uncore to maximum value\n" " -i (frequency index): set min/max frequency for uncore to specified frequency index\n" " --config (port,queue,lcore): rx queues configuration\n" +" --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection," +" 0 : just allow to enter C0-state\n" " --high-perf-cores CORELIST: list of high performance cores\n" " --perf-config: similar as config, cores specified as indices" " for bins containing high or regular performance cores\n" @@ -1545,6 +1551,28 @@ parse_uint32(const char *opt, uint32_t *res)return 0 ; } +static int +parse_int (const char *opt,int *res) +{ +char *end =NULL ; +signed long val; + +/* parse integer string */ + val =strtol (opt, &end,10 ); +if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +return -1 ; + +if (val <INT_MIN || val >INT_MAX ) { +RTE_LOG (ERR ,L3FWD_POWER ,"parameter should be range from %d to %d.\n" , +INT_MIN ,INT_MAX ); +return -1 ; + } + + *res = val; + +return 0 ; +} +static int parse_uncore_options (enum uncore_choice choice,const char *argument) {@@ -1734,6 +1762,7 @@ parse_pmd_mgmt_config(const char *name)#define CMD_LINE_OPT_PAUSE_DURATION "pause-duration"#define CMD_LINE_OPT_SCALE_FREQ_MIN "scale-freq-min"#define CMD_LINE_OPT_SCALE_FREQ_MAX "scale-freq-max" +#define CMD_LINE_OPT_CPU_RESUME_LATENCY "cpu-resume-latency"/* Parse the argument given in the command line of the application */ static int@@ -1748,6 +1777,7 @@ parse_args(int argc, char **argv) {"perf-config", 1, 0, 0}, {"high-perf-cores", 1, 0, 0}, {"no-numa", 0, 0, 0}, + {CMD_LINE_OPT_CPU_RESUME_LATENCY, 1, 0, 0}, {CMD_LINE_OPT_MAX_PKT_LEN, 1, 0, 0}, {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, {CMD_LINE_OPT_LEGACY, 0, 0, 0},
examples/l3fwd-power/main.c parse_args(int argc, char **argv) · line 1969
Quoted 7 lines
examples/l3fwd-power/main.c +4
-0@@ -1933,6 +1963,15 @@ parse_args(int argc, char **argv)printf ("Scaling frequency maximum configured\n" ); } +if (!strncmp (lgopts[option_index].name, +CMD_LINE_OPT_CPU_RESUME_LATENCY , +sizeof (CMD_LINE_OPT_CPU_RESUME_LATENCY ))) { +if (parse_int (optarg, &cpu_resume_latency) !=0 )
Do you really need a to support a negative values for that variable?
Quoted 36 lines
examples/l3fwd-power/main.c +25
-0+return -1 ; +printf ("PM QoS configured\n" ); + pm_qos_en = true; + } +break ;default :@@ -2256,6 +2295,26 @@ init_power_library(void)return -1 ; } } + +if (pm_qos_en) { +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the cpu resume latency of the worker lcore based +* on user's request. If set strict latency (0), just +* allow the CPU to enter the shallowest idle state to +* improve performance. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, + cpu_resume_latency); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set cpu resume latency on lcore-%u.\n" , + lcore_id); +return ret; + } + } + } +return ret; }
examples/l3fwd-power/main.c deinit_power_library(void) · line 2362
Quoted 9 lines
examples/l3fwd-power/main.c +6
-0@@ -2295,6 +2354,15 @@ deinit_power_library(void) } } } + +if (pm_qos_en) { +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT );
If we are going to 'restore original' shouldn't we:
At startup old_value=get()
At termination: set(old_value)
?
Quoted 8 lines
examples/l3fwd-power/main.c +3
-1+ } + } +return ret; } --2.22.0
Re: [PATCH v12 3/3] examples/l3fwd-power: add PM QoS configuration
Quoted 118 lines · Konstantin Ananyev
Quoted 118 lines
The '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 68 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/l3_forward_power_man.rst +2
-1@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase powerconsumption of platform.
.. note::
doc/guides/sample_app_ug/l3_forward_power_man.rst +2
-0@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awarenessexamples/l3fwd-power/main.c +30
-0@@ -47,6 +47,7 @@#include <rte_telemetry.h> #include <rte_power_pmd_mgmt.h> #include <rte_power_uncore.h> +#include <rte_power_qos.h> #include "perf_core.h" #include "main.h" @@ -265,6 +266,9 @@ static uint32_t pause_duration = 1;static uint32_t scale_freq_min;static uint32_t scale_freq_max; +static int cpu_resume_latency; +static bool pm_qos_en; +static struct rte_mempool * pktmbuf_pool[NB_SOCKETS ];@@ -1501,6 +1505,8 @@ print_usage(const char *prgname)" -U: set min/max frequency for uncore to maximum value\n" " -i (frequency index): set min/max frequency for uncore to specified frequency index\n" " --config (port,queue,lcore): rx queues configuration\n" +" --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection," +" 0 : just allow to enter C0-state\n" " --high-perf-cores CORELIST: list of high performance cores\n" " --perf-config: similar as config, cores specified as indices" " for bins containing high or regular performance cores\n" @@ -1545,6 +1551,28 @@ parse_uint32(const char *opt, uint32_t *res)return 0 ; } +static int +parse_int (const char *opt,int *res) +{ +char *end =NULL ; +signed long val; + +/* parse integer string */ + val =strtol (opt, &end,10 ); +if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +return -1 ; + +if (val <INT_MIN || val >INT_MAX ) { +RTE_LOG (ERR ,L3FWD_POWER ,"parameter should be range from %d to %d.\n" , +INT_MIN ,INT_MAX ); +return -1 ; + } + + *res = val; + +return 0 ; +} +static int parse_uncore_options (enum uncore_choice choice,const char *argument) {@@ -1734,6 +1762,7 @@ parse_pmd_mgmt_config(const char *name)#define CMD_LINE_OPT_PAUSE_DURATION "pause-duration"#define CMD_LINE_OPT_SCALE_FREQ_MIN "scale-freq-min"#define CMD_LINE_OPT_SCALE_FREQ_MAX "scale-freq-max" +#define CMD_LINE_OPT_CPU_RESUME_LATENCY "cpu-resume-latency"/* Parse the argument given in the command line of the application */ static int@@ -1748,6 +1777,7 @@ parse_args(int argc, char **argv) {"perf-config", 1, 0, 0}, {"high-perf-cores", 1, 0, 0}, {"no-numa", 0, 0, 0}, + {CMD_LINE_OPT_CPU_RESUME_LATENCY, 1, 0, 0}, {CMD_LINE_OPT_MAX_PKT_LEN, 1, 0, 0}, {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, {CMD_LINE_OPT_LEGACY, 0, 0, 0},@@ -1933,6 +1963,15 @@ parse_args(int argc, char **argv)printf ("Scaling frequency maximum configured\n" ); }
Quoted 5 lines
examples/l3fwd-power/main.c parse_args(int argc, char **argv) · line 1969
Quoted 4 lines
examples/l3fwd-power/main.c +4
-0+if (!strncmp (lgopts[option_index].name, +CMD_LINE_OPT_CPU_RESUME_LATENCY , +sizeof (CMD_LINE_OPT_CPU_RESUME_LATENCY ))) { +if (parse_int (optarg, &cpu_resume_latency) !=0 )Do you really need a to support a negative values for that variable?
will fix it.
Quoted 36 lines
Quoted 36 lines
examples/l3fwd-power/main.c +25
-0+return -1 ; +printf ("PM QoS configured\n" ); + pm_qos_en = true; + } +break ;default :@@ -2256,6 +2295,26 @@ init_power_library(void)return -1 ; } } + +if (pm_qos_en) { +RTE_LCORE_FOREACH (lcore_id) { +/* +* Set the cpu resume latency of the worker lcore based +* on user's request. If set strict latency (0), just +* allow the CPU to enter the shallowest idle state to +* improve performance. +*/ + ret =rte_power_qos_set_cpu_resume_latency (lcore_id, + cpu_resume_latency); +if (ret !=0 ) { +RTE_LOG (ERR ,L3FWD_POWER , +"Failed to set cpu resume latency on lcore-%u.\n" , + lcore_id); +return ret; + } + } + } +return ret; }
Quoted 14 lines
examples/l3fwd-power/main.c deinit_power_library(void) · line 2362
Quoted 10 lines
examples/l3fwd-power/main.c +6
-0@@ -2295,6 +2354,15 @@ deinit_power_library(void) } } } + +if (pm_qos_en) { +RTE_LCORE_FOREACH (lcore_id) { +/* Restore the original value in kernel. */ +rte_power_qos_set_cpu_resume_latency (lcore_id, +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT );If we are going to 'restore original' shouldn't we:
At startup old_value=get()
At termination:set(old_value)
?
Ack
Quoted 9 lines
Quoted 9 lines
examples/l3fwd-power/main.c +3
-1+ } + } +return ret; } --2.22.0
v13 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
---
v13:
- not allow negative value for --cpu-resume-latency.
- restore to the original value as Konstantin suggested.
v12:
- add Acked-by Chengwen and Konstantin
- fix overflow issue in l3fwd-power when parse command line
- add a command parameter to set CPU resume latency
v11:
- operate the cpu id the lcore mapped by the new function power_get_lcore_mapped_cpu_id().
v10:
- replace LINE_MAX with a custom macro and fix two typos.
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (3):
power: introduce PM QoS API on CPU wide examples/l3fwd-power: fix data overflow when parse command line examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 19 +++ doc/guides/rel_notes/release_24_11.rst | 5 + .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 115 ++++++++++++++-- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 ++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++ lib/power/version.map | 4 + 8 files changed, 331 insertions(+), 15 deletions(-) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v13 1/3 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +19 -0
@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -237,6 +237,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value to
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_qos.c new file +123 -0
123 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; };
Signature · 1 line
2.22.0
RE: [PATCH v13 1/3] power: introduce PM QoS API on CPU wide
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Huisong,
LGTM! One comment to update the doxygen documentation for the new APIs.
Quoted 352 lines
-----Original Message-----
From: Huisong Li <[email protected]>
Sent: Friday, October 25, 2024 2:49 PM
To: [email protected]
Cc: [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Tummala, Sivaprasad <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v13 1/3] power: introduce PM QoS API on CPU wideCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644
lib/power/rte_power_qos.hdoc/guides/prog_guide/power_man.rst +0
-0@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3forwarding.
doc/guides/prog_guide/power_man.rst +18
-0+PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX +for userspace. Each cpuidle governor in Linux select which idle state +to enter based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the +longer the resume time. Some service are latency sensitive and very +except the low resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and +``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) +by the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume +latency and get better performance (instead, the power consumption of platformmay increase).
doc/guides/prog_guide/power_man.rst +2
-0+ + Ethernet PMD Power Management API ---------------------------------doc/guides/rel_notes/release_24_11.rst +5
-0@@ -237,6 +237,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with privatearguments.**
A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque
value to diff --git a/lib/power/meson.build b/lib/power/meson.build index2f0f3d26e9..9b5d3e8315100644lib/power/meson.build +2
-0@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']lib/power/rte_power_qos.c new file mode renamed from lib/power/rte_power_qos.c +0
-0100644 index 0000000000..4dd0532b36
lib/power/rte_power_qos.c new file +40
-0@@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <rte_lcore.h> +#include <rte_log.h> + +#include "power_common.h" +#include "rte_power_qos.h" + +#define PM_QOS_SYSFILE_RESUME_LATENCY_US \ + "/sys/devices/system/cpu/cpu%u/power/pm_qos_resume_latency_us" + +#define PM_QOS_CPU_RESUME_LATENCY_BUF_LEN 32 + +int +rte_power_qos_set_cpu_resume_latency (uint16_t lcore_id,int latency) { +char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN ]; +uint32_t cpu_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 ; + } + ret =power_get_lcore_mapped_cpu_id (lcore_id, &cpu_id); +if (ret !=0 ) +return ret; + +if (latency <0 ) { +POWER_LOG (ERR ,"latency should be greater than and equal to 0" ); +return -EINVAL ; + } + + ret = open_core_sysfs_file(&f, "w",
PM_QOS_SYSFILE_RESUME_LATENCY_US,cpu_id);lib/power/rte_power_qos.c new file +2
-0+if (ret !=0 ) { + POWER_LOG(ERR, "Failed to open"
PM_QOS_SYSFILE_RESUME_LATENCY_US" : %s",lib/power/rte_power_qos.c new file +7
-0+ cpu_id, strerror(errno)); +return ret; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning
lib/power/rte_power_qos.c new file +8
-0+* is as follows for different input string. +* 1> the resume latency is 0 if the input is "n/a". +* 2> the resume latency is no constraint if the input is "0". +* 3> the resume latency is the actual value to be set. +*/ +if (latency ==RTE_POWER_QOS_STRICT_LATENCY_VALUE ) +snprintf (buf,sizeof (buf),"%s" ,"n/a" ); + else if (latency ==
RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT)lib/power/rte_power_qos.c new file +7
-0+snprintf (buf,sizeof (buf),"%u" ,0 ); + else + snprintf(buf, sizeof(buf), "%u", latency); + + ret =write_core_sysfs_s (f, buf); +if (ret !=0 ) + POWER_LOG(ERR, "Failed to write"
PM_QOS_SYSFILE_RESUME_LATENCY_US" : %s",lib/power/rte_power_qos.c new file +24
-0+ cpu_id, strerror(errno)); + +fclose (f); + +return ret; +} + +int +rte_power_qos_get_cpu_resume_latency (uint16_t lcore_id) { +char buf[PM_QOS_CPU_RESUME_LATENCY_BUF_LEN ]; +int latency =-1 ; +uint32_t cpu_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 ; + } + ret =power_get_lcore_mapped_cpu_id (lcore_id, &cpu_id); +if (ret !=0 ) +return ret; + + ret = open_core_sysfs_file(&f, "r",
PM_QOS_SYSFILE_RESUME_LATENCY_US,cpu_id);lib/power/rte_power_qos.c new file +2
-0+if (ret !=0 ) { + POWER_LOG(ERR, "Failed to open"
PM_QOS_SYSFILE_RESUME_LATENCY_US" : %s",lib/power/rte_power_qos.c new file +7
-0+ cpu_id, strerror(errno)); +return ret; + } + + ret =read_core_sysfs_s (f, buf,sizeof (buf)); +if (ret !=0 ) { + POWER_LOG(ERR, "Failed to read"
PM_QOS_SYSFILE_RESUME_LATENCY_US" : %s",lib/power/rte_power_qos.c new file +7
-0+ cpu_id, strerror(errno)); + goto out; + } + +/* +* Based on the sysfs interface pm_qos_resume_latency_us under +* @PM_QOS_SYSFILE_RESUME_LATENCY_US directory in kernel, their meaning
lib/power/rte_power_qos.c new file +10
-0+* is as follows for different output string. +* 1> the resume latency is 0 if the output is "n/a". +* 2> the resume latency is no constraint if the output is "0". +* 3> the resume latency is the actual value in used for other string. +*/ +if (strcmp (buf,"n/a" ) ==0 ) + latency =RTE_POWER_QOS_STRICT_LATENCY_VALUE ; +else { + latency =strtoul (buf,NULL ,10 ); + latency = latency == 0 ?
RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT: latency;lib/power/rte_power_qos.c new file +6
-0+ } + +out: +fclose (f); + +return latency !=-1 ? latency : ret; }lib/power/rte_power_qos.h new file mode renamed from lib/power/rte_power_qos.h +0
-0100644 index 0000000000..7a8dab9272
lib/power/rte_power_qos.h new file +43
-0@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2024 HiSilicon Limited +*/ + +#ifndef RTE_POWER_QOS_H +#define RTE_POWER_QOS_H + +#include <stdint.h> + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file rte_power_qos.h + * + * PM QoS API. + * + * The CPU-wide resume latency limit has a positive impact on this +CPU's idle + * state selection in each cpuidle governor. + * Please see the PM QoS on CPU wide in the following link: + * +https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html?hig +hlight=pm_qos_resume_latency_us#abi-sys-devices-power-pm-qos-resume-lat +ency-us + * + * The deeper the idle state, the lower the power consumption, but the + * longer the resume time. Some service are delay sensitive and very +except the + * low resume time, like interrupt packet receiving mode. + * + * In these case, per-CPU PM QoS API can be used to control this CPU's +idle + * state selection and limit just enter the shallowest idle state to +low the + * delay after sleep by setting strict resume latency (zero value). + */ + +#define RTE_POWER_QOS_STRICT_LATENCY_VALUE 0 +#define RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT
INT32_MAXlib/power/rte_power_qos.h new file +39
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* @param lcore_id +* target logical core id +* +* @param latency +* The latency should be greater than and equal to zero in microseconds unit. +* +* @return +* 0 on success. Otherwise negative value is returned. +*/ +__rte_experimental +int rte_power_qos_set_cpu_resume_latency(uint16_t lcore_id, int +latency); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Get the current resume latency of this logical core. +* The default value in kernel is @see +RTE_POWER_QOS_RESUME_LATENCY_NO_CONSTRAINT +* if don't set it. +* +* @return +* Negative value on failure. +* >= 0 means the actual resume latency limit on this core. +*/ +__rte_experimental +int rte_power_qos_get_cpu_resume_latency(uint16_t lcore_id); + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_QOS_H */ lib/power/version.map index renamed from lib/power/version.map +0
-0
c9a226614e..08f178a39d100644lib/power/version.map +4
-1@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; }; --
Quoted 1 line
2.22.0
PATCH v13 2/3 examples/l3fwd-power: fix data overflow when parse command line
In reply to Huisong LiMany variables are 'uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They use parse_int() to parse it from command line. But overflow problem occurs when this function return.
--- examples/l3fwd-power/main.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
examples/l3fwd-power/main.c +16 -20
@@ -1525,7 +1525,7 @@ print_usage(const char *prgname) }static int -parse_int (const char *opt) +parse_uint32 (const char *opt,uint32_t *res) {char *end =NULL ;unsigned long val;
@@ -1535,23 +1535,14 @@ parse_int(const char *opt)if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return -1 ; -return val; -} - -static int parse_max_pkt_len (const char *pktlen) -{ -char *end =NULL ; -unsigned long len; - -/* parse decimal string */ - len =strtoul (pktlen, &end,10 ); -if ((pktlen[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +if (val >UINT32_MAX ) { +RTE_LOG (ERR ,L3FWD_POWER ,"parameter shouldn't exceed %u.\n" ,UINT32_MAX );return -1 ; + } -if (len ==0 ) -return -1 ; + *res = val; -return len; +return 0 ; } static int
@@ -1898,8 +1889,9 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_PKT_LEN ,sizeof (CMD_LINE_OPT_MAX_PKT_LEN ))) { +if (parse_uint32 (optarg, &max_pkt_len) !=0 ) +return -1 ;printf ("Custom frame size is configured\n" ); - max_pkt_len =parse_max_pkt_len (optarg); } if (!strncmp(lgopts[option_index].name,
@@ -1912,29 +1904,33 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_EMPTY_POLLS ,sizeof (CMD_LINE_OPT_MAX_EMPTY_POLLS ))) { +if (parse_uint32 (optarg, &max_empty_polls) !=0 ) +return -1 ;printf ("Maximum empty polls configured\n" ); - max_empty_polls =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PAUSE_DURATION ,sizeof (CMD_LINE_OPT_PAUSE_DURATION ))) { +if (parse_uint32 (optarg, &pause_duration) !=0 ) +return -1 ;printf ("Pause duration configured\n" ); - pause_duration =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MIN ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MIN ))) { +if (parse_uint32 (optarg, &scale_freq_min) !=0 ) +return -1 ;printf ("Scaling frequency minimum configured\n" ); - scale_freq_min =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MAX ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MAX ))) { +if (parse_uint32 (optarg, &scale_freq_max) !=0 ) +return -1 ;printf ("Scaling frequency maximum configured\n" ); - scale_freq_max =parse_int (optarg); }break ;
Signature · 1 line
2.22.0
Re: [PATCH v13 2/3] examples/l3fwd-power: fix data overflow when parse command line
Quoted 10 lines · Huisong Li
Many variables are '
uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They useparse_int()to parse it from command line. But overflow problem occurs when this function return.Fixes 59f2853c4cae ("examples/l3fwd_power: add configuration options")Signed-off-by Huisong Li <[email protected]>---
RE: [PATCH v13 2/3] examples/l3fwd-power: fix data overflow when parse command line
In reply to Huisong Li[AMD Official Use Only - AMD Internal Distribution Only]
Hi Huisong,
LGTM!
Quoted 121 lines
-----Original Message-----
From: Huisong Li <[email protected]>
Sent: Friday, October 25, 2024 2:49 PM
To: [email protected]
Cc: [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Tummala, Sivaprasad <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v13 2/3] examples/l3fwd-power: fix data overflow when parse command lineCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Many variables are '
uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They useparse_int()to parse it from command line. But overflow problem occurs when this function return.Fixes 59f2853c4cae ("examples/l3fwd_power: add configuration options")Signed-off-by Huisong Li <[email protected]>--- examples/l3fwd-power/main.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)examples/l3fwd-power/main.c index renamed from examples/l3fwd-power/main.c +0
-0
2bb6b092c3..0ce4aa04d4100644examples/l3fwd-power/main.c +17
-20@@ -1525,7 +1525,7 @@ print_usage(const char *prgname) }static int -parse_int (const char *opt) +parse_uint32 (const char *opt,uint32_t *res) {char *end =NULL ;unsigned long val;@@ -1535,23 +1535,14 @@ parse_int(const char *opt)if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return -1 ; -return val; -} - -static int parse_max_pkt_len(const char *pktlen) -{ -char *end =NULL ; -unsigned long len; - -/* parse decimal string */ - len =strtoul (pktlen, &end,10 ); -if ((pktlen[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +if (val >UINT32_MAX ) { + RTE_LOG(ERR, L3FWD_POWER, "parameter shouldn't exceed + %u.\n", UINT32_MAX);return -1 ; + } -if (len ==0 ) -return -1 ; + *res = val; -return len; +return 0 ; } static int@@ -1898,8 +1889,9 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_PKT_LEN ,sizeof (CMD_LINE_OPT_MAX_PKT_LEN ))) { +if (parse_uint32 (optarg, &max_pkt_len) !=0 ) +return -1 ;printf ("Custom frame size is configured\n" ); - max_pkt_len =parse_max_pkt_len (optarg); } if (!strncmp(lgopts[option_index].name,@@ -1912,29 +1904,33 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_EMPTY_POLLS ,sizeof (CMD_LINE_OPT_MAX_EMPTY_POLLS ))) { +if (parse_uint32 (optarg, &max_empty_polls) !=0 ) +return -1 ;printf ("Maximum empty polls configured\n" ); - max_empty_polls =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PAUSE_DURATION ,sizeof (CMD_LINE_OPT_PAUSE_DURATION ))) { +if (parse_uint32 (optarg, &pause_duration) !=0 ) +return -1 ;printf ("Pause duration configured\n" ); - pause_duration =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MIN ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MIN ))) { +if (parse_uint32 (optarg, &scale_freq_min) !=0 ) +return -1 ;printf ("Scaling frequency minimum configured\n" ); - scale_freq_min =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MAX ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MAX ))) { +if (parse_uint32 (optarg, &scale_freq_max) !=0 ) +return -1 ;printf ("Scaling frequency maximum configured\n" ); - scale_freq_max =parse_int (optarg); }break ; --
Quoted 1 line
2.22.0
PATCH v13 3/3 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiThe '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 91 +++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-)
doc/guides/sample_app_ug/l3_forward_power_man.rst +4 -1
@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase power consumption of platform. .. note::
@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awareness
examples/l3fwd-power/main.c +91 -0
145 lines not on this page · raw message
Signature · 1 line
2.22.0
v14 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
---
v14:
- use parse_uint to parse --cpu-resume-latency instead of adding a new
parse_int()
v13:
- not allow negative value for --cpu-resume-latency.
- restore to the original value as Konstantin suggested.
v12:
- add Acked-by Chengwen and Konstantin
- fix overflow issue in l3fwd-power when parse command line
- add a command parameter to set CPU resume latency
v11:
- operate the cpu id the lcore mapped by the new function power_get_lcore_mapped_cpu_id().
v10:
- replace LINE_MAX with a custom macro and fix two typos.
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (3):
power: introduce PM QoS API on CPU wide examples/l3fwd-power: fix data overflow when parse command line examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 19 +++ doc/guides/rel_notes/release_24_11.rst | 5 + .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 96 +++++++++++--- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 ++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++ lib/power/version.map | 4 + 8 files changed, 306 insertions(+), 21 deletions(-) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v14 1/3 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +19 -0
@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -237,6 +237,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value to
lib/power/meson.build +2 -0
@@ -23,12 +23,14 @@ sources = files( 'rte_power.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'rte_power.h', 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_qos.c new file +123 -0
123 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,4 +51,8 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; };
Signature · 1 line
2.22.0
PATCH v14 2/3 examples/l3fwd-power: fix data overflow when parse command line
In reply to Huisong LiMany variables are 'uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They use parse_int() to parse it from command line. But overflow problem occurs when this function return.
--- examples/l3fwd-power/main.c | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-)
examples/l3fwd-power/main.c +21 -20
@@ -1524,8 +1524,12 @@ print_usage(const char *prgname) prgname); } +/* +* Caller must give the right upper limit so as to ensure receiver variable +* doesn't overflow. +*/ static int -parse_int (const char *opt) +parse_uint (const char *opt,uint32_t max,uint32_t *res) {char *end =NULL ;unsigned long val;
@@ -1535,23 +1539,15 @@ parse_int(const char *opt)if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return -1 ; -return val; -} - -static int parse_max_pkt_len (const char *pktlen) -{ -char *end =NULL ; -unsigned long len; - -/* parse decimal string */ - len =strtoul (pktlen, &end,10 ); -if ((pktlen[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +if (val > max) { +RTE_LOG (ERR ,L3FWD_POWER ,"%s parameter shouldn't exceed %u.\n" , + opt, max);return -1 ; + } -if (len ==0 ) -return -1 ; + *res = val; -return len; +return 0 ; } static int
@@ -1898,8 +1894,9 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_PKT_LEN ,sizeof (CMD_LINE_OPT_MAX_PKT_LEN ))) { +if (parse_uint (optarg,UINT32_MAX , &max_pkt_len) !=0 ) +return -1 ;printf ("Custom frame size is configured\n" ); - max_pkt_len =parse_max_pkt_len (optarg); } if (!strncmp(lgopts[option_index].name,
@@ -1912,29 +1909,33 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_EMPTY_POLLS ,sizeof (CMD_LINE_OPT_MAX_EMPTY_POLLS ))) { +if (parse_uint (optarg,UINT32_MAX , &max_empty_polls) !=0 ) +return -1 ;printf ("Maximum empty polls configured\n" ); - max_empty_polls =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PAUSE_DURATION ,sizeof (CMD_LINE_OPT_PAUSE_DURATION ))) { +if (parse_uint (optarg,UINT32_MAX , &pause_duration) !=0 ) +return -1 ;printf ("Pause duration configured\n" ); - pause_duration =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MIN ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MIN ))) { +if (parse_uint (optarg,UINT32_MAX , &scale_freq_min) !=0 ) +return -1 ;printf ("Scaling frequency minimum configured\n" ); - scale_freq_min =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MAX ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MAX ))) { +if (parse_uint (optarg,UINT32_MAX , &scale_freq_max) !=0 ) +return -1 ;printf ("Scaling frequency maximum configured\n" ); - scale_freq_max =parse_int (optarg); }break ;
Signature · 1 line
2.22.0
PATCH v14 3/3 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiThe '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-)
doc/guides/sample_app_ug/l3_forward_power_man.rst +4 -1
@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase power consumption of platform. .. note::
@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awareness
examples/l3fwd-power/main.c +55 -0
103 lines not on this page · raw message
Signature · 1 line
2.22.0
RE: [PATCH v14 3/3] examples/l3fwd-power: add PM QoS configuration
Quoted 32 lines
The '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
Signed-off-by Huisong Li <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Chengwen Feng <[email protected]>--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/l3_forward_power_man.rst +2
-1@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase powerconsumption of platform.
.. note::
doc/guides/sample_app_ug/l3_forward_power_man.rst where, · line 113
Quoted 8 lines
doc/guides/sample_app_ug/l3_forward_power_man.rst +2
-0@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awareness
Quoted 2 lines
--
2.22.0
Re: [PATCH v14 0/3] power: introduce PM QoS interface
In reply to Huisong LiHi Ferruh and Thomas,
Kindly ping for merge.
Quoted 70 lines · Huisong Li
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
---
v14:
- useparse_uintto parse --cpu-resume-latency instead of adding a newparse_int()v13:
- not allow negative value for --cpu-resume-latency.
- restore to the original value as Konstantin suggested.
v12:
- add Acked-by Chengwen and Konstantin
- fix overflow issue in l3fwd-power when parse command line
- add a command parameter to set CPU resume latency
v11:
- operate the cpu id the lcore mapped by the new functionpower_get_lcore_mapped_cpu_id().
v10:
- replaceLINE_MAXwith a custom macro and fix two typos.
v9:
- move new feature description fromrelease_24_07.rsttorelease_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead coderte_lcore_is_enabledin patch[2/2]
v6:
- updaterelease_24_07.rstbased on dpdk repo to resolve CI warning.
v5:
- useLINE_MAXto replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- addstdint.hinclude
- add Acked-by Morten Brørup <[email protected]>
v3:
- addRTE_POWER_xxxprefix for some macro in header
- add the check forlcore_idwithrte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wideHuisong Li (3):
power: introduce PM QoS API on CPU wide examples/l3fwd-power: fix data overflow when parse command line examples/l3fwd-power: add PM QoS configurationdoc/guides/prog_guide/power_man.rst | 19 +++ doc/guides/rel_notes/release_24_11.rst | 5 + .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 96 +++++++++++--- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 ++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++ lib/power/version.map | 4 + 8 files changed, 306 insertions(+), 21 deletions(-)create mode 100644
lib/power/rte_power_qos.c
create mode 100644lib/power/rte_power_qos.h
v15 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
---
v15:
- fix conflicts due to the new merged patches that rework power lib.
- add Acked-by: Konstantin Ananyev for patch 3/3.
v14:
- use parse_uint to parse --cpu-resume-latency instead of adding a new
parse_int()
v13:
- not allow negative value for --cpu-resume-latency.
- restore to the original value as Konstantin suggested.
v12:
- add Acked-by Chengwen and Konstantin
- fix overflow issue in l3fwd-power when parse command line
- add a command parameter to set CPU resume latency
v11:
- operate the cpu id the lcore mapped by the new function power_get_lcore_mapped_cpu_id().
v10:
- replace LINE_MAX with a custom macro and fix two typos.
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (3):
power: introduce PM QoS API on CPU wide examples/l3fwd-power: fix data overflow when parse command line examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 19 +++ doc/guides/rel_notes/release_24_11.rst | 5 + .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 96 +++++++++++--- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 ++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++ lib/power/version.map | 4 + 8 files changed, 306 insertions(+), 21 deletions(-) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH v15 1/3 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +19 -0
@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -276,6 +276,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value to
lib/power/meson.build +2 -0
@@ -16,6 +16,7 @@ sources = files( 'rte_power_cpufreq.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'power_cpufreq.h',
@@ -24,6 +25,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_qos.c new file +123 -0
123 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,6 +51,10 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; }; INTERNAL {
Signature · 1 line
2.22.0
Re: [PATCH v15 1/3] power: introduce PM QoS API on CPU wide
11/11/2024 03:25, Huisong Li:
Quoted 2 lines
Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
I don't understand this sentence.
Are you sure about "very except"?
It is also in the guide.
If something needs a reword, please send a patch.
Re: [PATCH v15 1/3] power: introduce PM QoS API on CPU wide
Quoted 8 lines · Thomas Monjalon
11/11/2024 03:25, Huisong Li:
Quoted 2 lines
Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
I don't understand this sentence.
Are you sure about "very except"?
It is also in the guide.
If something needs a reword, please send a patch.
Sorry, it's a typo. except-->expect.
I will send a patch to fix it.
Quoted 2 lines
.
PATCH v15 2/3 examples/l3fwd-power: fix data overflow when parse command line
In reply to Huisong LiMany variables are 'uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They use parse_int() to parse it from command line. But overflow problem occurs when this function return.
--- examples/l3fwd-power/main.c | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-)
examples/l3fwd-power/main.c +21 -20
@@ -1520,8 +1520,12 @@ print_usage(const char *prgname) prgname); } +/* +* Caller must give the right upper limit so as to ensure receiver variable +* doesn't overflow. +*/ static int -parse_int (const char *opt) +parse_uint (const char *opt,uint32_t max,uint32_t *res) {char *end =NULL ;unsigned long val;
@@ -1531,23 +1535,15 @@ parse_int(const char *opt)if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return -1 ; -return val; -} - -static int parse_max_pkt_len (const char *pktlen) -{ -char *end =NULL ; -unsigned long len; - -/* parse decimal string */ - len =strtoul (pktlen, &end,10 ); -if ((pktlen[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +if (val > max) { +RTE_LOG (ERR ,L3FWD_POWER ,"%s parameter shouldn't exceed %u.\n" , + opt, max);return -1 ; + } -if (len ==0 ) -return -1 ; + *res = val; -return len; +return 0 ; } static int
@@ -1894,8 +1890,9 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_PKT_LEN ,sizeof (CMD_LINE_OPT_MAX_PKT_LEN ))) { +if (parse_uint (optarg,UINT32_MAX , &max_pkt_len) !=0 ) +return -1 ;printf ("Custom frame size is configured\n" ); - max_pkt_len =parse_max_pkt_len (optarg); } if (!strncmp(lgopts[option_index].name,
@@ -1908,29 +1905,33 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_EMPTY_POLLS ,sizeof (CMD_LINE_OPT_MAX_EMPTY_POLLS ))) { +if (parse_uint (optarg,UINT32_MAX , &max_empty_polls) !=0 ) +return -1 ;printf ("Maximum empty polls configured\n" ); - max_empty_polls =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PAUSE_DURATION ,sizeof (CMD_LINE_OPT_PAUSE_DURATION ))) { +if (parse_uint (optarg,UINT32_MAX , &pause_duration) !=0 ) +return -1 ;printf ("Pause duration configured\n" ); - pause_duration =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MIN ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MIN ))) { +if (parse_uint (optarg,UINT32_MAX , &scale_freq_min) !=0 ) +return -1 ;printf ("Scaling frequency minimum configured\n" ); - scale_freq_min =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MAX ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MAX ))) { +if (parse_uint (optarg,UINT32_MAX , &scale_freq_max) !=0 ) +return -1 ;printf ("Scaling frequency maximum configured\n" ); - scale_freq_max =parse_int (optarg); }break ;
Signature · 1 line
2.22.0
PATCH v15 3/3 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiThe '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-)
doc/guides/sample_app_ug/l3_forward_power_man.rst +4 -1
@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase power consumption of platform. .. note::
@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awareness
examples/l3fwd-power/main.c +55 -0
103 lines not on this page · raw message
Signature · 1 line
2.22.0
Thomas Monjalon
AppliedRe: [PATCH v15 0/3] power: introduce PM QoS interface
In reply to Huisong Li11/11/2024 03:25, Huisong Li:
Quoted 10 lines
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "
/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
Quoted 5 lines
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
Applied, thanks.
v15 cover power: introduce PM QoS interface
In reply to Huisong LiThe deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Please see the description in kernel document[1]. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from idle state by setting strict resume latency (zero value).
---
v15:
- fix conflicts due to the new merged patches that rework power lib.
- add Acked-by: Konstantin Ananyev for patch 3/3.
v14:
- use parse_uint to parse --cpu-resume-latency instead of adding a new
parse_int()
v13:
- not allow negative value for --cpu-resume-latency.
- restore to the original value as Konstantin suggested.
v12:
- add Acked-by Chengwen and Konstantin
- fix overflow issue in l3fwd-power when parse command line
- add a command parameter to set CPU resume latency
v11:
- operate the cpu id the lcore mapped by the new function power_get_lcore_mapped_cpu_id().
v10:
- replace LINE_MAX with a custom macro and fix two typos.
v9:
- move new feature description from release_24_07.rst to release_24_11.rst.
v8:
- update the latest code to resolve CI warning
v7:
- remove a dead code rte_lcore_is_enabled in patch[2/2]
v6:
- update release_24_07.rst based on dpdk repo to resolve CI warning.
v5:
- use LINE_MAX to replace BUFSIZ, and use snprintf to replace sprintf.
v4:
- fix some comments basd on Stephen
- add stdint.h include
- add Acked-by Morten Brørup <[email protected]>
v3:
- add RTE_POWER_xxx prefix for some macro in header
- add the check for lcore_id with rte_lcore_is_enabled
v2:
- use PM QoS on CPU wide to replace the one on system wide
Huisong Li (3):
power: introduce PM QoS API on CPU wide examples/l3fwd-power: fix data overflow when parse command line examples/l3fwd-power: add PM QoS configuration
doc/guides/prog_guide/power_man.rst | 19 +++ doc/guides/rel_notes/release_24_11.rst | 5 + .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 96 +++++++++++--- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 ++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++ lib/power/version.map | 4 + 8 files changed, 306 insertions(+), 21 deletions(-) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Signature · 1 line
2.22.0
PATCH RESEND v15 1/3 power: introduce PM QoS API on CPU wide
The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode.
And the "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs interface is used to set and get the resume latency limit on the cpuX for userspace. Each cpuidle governor in Linux select which idle state to enter based on this CPU resume latency in their idle task.
The per-CPU PM QoS API can be used to control this CPU's idle state selection and limit just enter the shallowest idle state to low the delay when wake up from by setting strict resume latency (zero value).
--- doc/guides/prog_guide/power_man.rst | 19 ++++ doc/guides/rel_notes/release_24_11.rst | 5 + lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 123 +++++++++++++++++++++++++ lib/power/rte_power_qos.h | 73 +++++++++++++++ lib/power/version.map | 4 + 6 files changed, 226 insertions(+) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
doc/guides/prog_guide/power_man.rst +19 -0
@@ -107,6 +107,25 @@ User Cases The power management mechanism is used to save power when performing L3 forwarding. +PM QoS +------ + +The "/sys/devices/system/cpu/cpuX/power/pm_qos_resume_latency_us" sysfs +interface is used to set and get the resume latency limit on the cpuX for +userspace. Each cpuidle governor in Linux select which idle state to enter +based on this CPU resume latency in their idle task. + +The deeper the idle state, the lower the power consumption, but the longer +the resume time. Some service are latency sensitive and very except the low +resume time, like interrupt packet receiving mode. + +Applications can set and get the CPU resume latency by the +``rte_power_qos_set_cpu_resume_latency()`` and ``rte_power_qos_get_cpu_resume_latency()`` +respectively. Applications can set a strict resume latency (zero value) by +the ``rte_power_qos_set_cpu_resume_latency()`` to low the resume latency and +get better performance (instead, the power consumption of platform may increase). + + Ethernet PMD Power Management API ---------------------------------
doc/guides/rel_notes/release_24_11.rst +5 -0
@@ -276,6 +276,11 @@ New Features This field is used to pass an extra configuration settings such as ability to lookup IPv4 addresses in network byte order. +* **Introduce per-CPU PM QoS interface.** + + * Add per-CPU PM QoS interface to low the resume latency when wake up from + idle state. + * **Added new API to register telemetry endpoint callbacks with private arguments.** A new ``rte_telemetry_register_cmd_arg`` function is available to pass an opaque value to
lib/power/meson.build +2 -0
@@ -16,6 +16,7 @@ sources = files( 'rte_power_cpufreq.c', 'rte_power_uncore.c', 'rte_power_pmd_mgmt.c', + 'rte_power_qos.c', ) headers = files( 'power_cpufreq.h',
@@ -24,6 +25,7 @@ headers = files( 'rte_power_guest_channel.h', 'rte_power_pmd_mgmt.h', 'rte_power_uncore.h', + 'rte_power_qos.h', ) deps += ['timer', 'ethdev']
lib/power/rte_power_qos.c new file +123 -0
123 lines not on this page · raw message
lib/power/rte_power_qos.h new file +73 -0
73 lines not on this page · raw message
lib/power/version.map +4 -0
@@ -51,6 +51,10 @@ EXPERIMENTAL { rte_power_set_uncore_env; rte_power_uncore_freqs; rte_power_unset_uncore_env; + + # added in 24.11 + rte_power_qos_get_cpu_resume_latency; + rte_power_qos_set_cpu_resume_latency; }; INTERNAL {
Signature · 1 line
2.22.0
PATCH RESEND v15 2/3 examples/l3fwd-power: fix data overflow when parse command line
In reply to Huisong LiMany variables are 'uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They use parse_int() to parse it from command line. But overflow problem occurs when this function return.
--- examples/l3fwd-power/main.c | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-)
examples/l3fwd-power/main.c +21 -20
@@ -1520,8 +1520,12 @@ print_usage(const char *prgname) prgname); } +/* +* Caller must give the right upper limit so as to ensure receiver variable +* doesn't overflow. +*/ static int -parse_int (const char *opt) +parse_uint (const char *opt,uint32_t max,uint32_t *res) {char *end =NULL ;unsigned long val;
@@ -1531,23 +1535,15 @@ parse_int(const char *opt)if ((opt[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))return -1 ; -return val; -} - -static int parse_max_pkt_len (const char *pktlen) -{ -char *end =NULL ; -unsigned long len; - -/* parse decimal string */ - len =strtoul (pktlen, &end,10 ); -if ((pktlen[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' )) +if (val > max) { +RTE_LOG (ERR ,L3FWD_POWER ,"%s parameter shouldn't exceed %u.\n" , + opt, max);return -1 ; + } -if (len ==0 ) -return -1 ; + *res = val; -return len; +return 0 ; } static int
@@ -1894,8 +1890,9 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_PKT_LEN ,sizeof (CMD_LINE_OPT_MAX_PKT_LEN ))) { +if (parse_uint (optarg,UINT32_MAX , &max_pkt_len) !=0 ) +return -1 ;printf ("Custom frame size is configured\n" ); - max_pkt_len =parse_max_pkt_len (optarg); } if (!strncmp(lgopts[option_index].name,
@@ -1908,29 +1905,33 @@ parse_args(int argc, char **argv)if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_MAX_EMPTY_POLLS ,sizeof (CMD_LINE_OPT_MAX_EMPTY_POLLS ))) { +if (parse_uint (optarg,UINT32_MAX , &max_empty_polls) !=0 ) +return -1 ;printf ("Maximum empty polls configured\n" ); - max_empty_polls =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PAUSE_DURATION ,sizeof (CMD_LINE_OPT_PAUSE_DURATION ))) { +if (parse_uint (optarg,UINT32_MAX , &pause_duration) !=0 ) +return -1 ;printf ("Pause duration configured\n" ); - pause_duration =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MIN ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MIN ))) { +if (parse_uint (optarg,UINT32_MAX , &scale_freq_min) !=0 ) +return -1 ;printf ("Scaling frequency minimum configured\n" ); - scale_freq_min =parse_int (optarg); }if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_SCALE_FREQ_MAX ,sizeof (CMD_LINE_OPT_SCALE_FREQ_MAX ))) { +if (parse_uint (optarg,UINT32_MAX , &scale_freq_max) !=0 ) +return -1 ;printf ("Scaling frequency maximum configured\n" ); - scale_freq_max =parse_int (optarg); }break ;
Signature · 1 line
2.22.0
PATCH RESEND v15 3/3 examples/l3fwd-power: add PM QoS configuration
In reply to Huisong LiThe '--cpu-resume-latency' can use to control C-state selection. Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which also may increase the power consumption of platform.
--- .../sample_app_ug/l3_forward_power_man.rst | 5 +- examples/l3fwd-power/main.c | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-)
doc/guides/sample_app_ug/l3_forward_power_man.rst +4 -1
@@ -67,7 +67,8 @@ based on the speculative sleep duration of the core. In this application, we introduce a heuristic algorithm that allows packet processing cores to sleep for a short period if there is no Rx packet received on recent polls. In this way, CPUIdle automatically forces the corresponding cores to enter deeper C-states -instead of always running to the C0 state waiting for packets. +instead of always running to the C0 state waiting for packets. But user can set the CPU resume latency to control C-state selection. +Setting the CPU resume latency to 0 can limit the CPU just to enter C0-state to improve performance, which may increase power consumption of platform. .. note::
@@ -105,6 +106,8 @@ where, * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. +* --cpu-resume-latency LATENCY: set CPU resume latency to control C-state selection, 0 : just allow to enter C0-state. + * --max-pkt-len: optional, maximum packet length in decimal (64-9600) * --no-numa: optional, disables numa awareness
examples/l3fwd-power/main.c +55 -0
103 lines not on this page · raw message
Signature · 1 line
2.22.0