[v2,2/2] examples/l3fwd-power: add PM QoS configuration

Message ID 20240613112038.14271-3-lihuisong@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series power: introduce PM QoS interface |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

lihuisong (C) June 13, 2024, 11:20 a.m. UTC
Add PM QoS configuration to declease the delay after sleep in case of
entering deeper idle state.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 examples/l3fwd-power/main.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
  

Patch

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index fba11da7ca..96980352ee 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -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;
 }