DPDK patches and discussions
 help / color / mirror / Atom feed
From: Huisong Li <lihuisong@huawei.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <ferruh.yigit@amd.com>,
	<anatoly.burakov@intel.com>, <david.hunt@intel.com>,
	<sivaprasad.tummala@amd.com>, <liuyonglong@huawei.com>,
	<lihuisong@huawei.com>
Subject: [PATCH 2/2] examples/l3fwd-power: add PM QoS request configuration
Date: Wed, 20 Mar 2024 18:55:29 +0800	[thread overview]
Message-ID: <20240320105529.5626-3-lihuisong@huawei.com> (raw)
In-Reply-To: <20240320105529.5626-1-lihuisong@huawei.com>

Add PM QoS request configuration to declease the process resume latency.

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

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index f4adcf41b5..78f292ed02 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"
@@ -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);
-- 
2.22.0


  parent reply	other threads:[~2024-03-20 11:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 10:55 [PATCH 0/2] introduce PM QoS interface Huisong Li
2024-03-20 10:55 ` [PATCH 1/2] power: " Huisong Li
2024-03-20 10:55 ` Huisong Li [this message]
2024-03-20 14:05 ` [PATCH 0/2] " Morten Brørup
2024-03-21  3:04   ` lihuisong (C)
2024-03-21 13:30     ` Morten Brørup
2024-03-22  8:54       ` lihuisong (C)
2024-03-22 12:35         ` Morten Brørup
2024-03-26  2:11           ` lihuisong (C)
2024-03-26  8:27             ` Morten Brørup
2024-03-26 12:15               ` lihuisong (C)
2024-03-26 12:46                 ` Morten Brørup
2024-03-29  1:59                   ` lihuisong (C)
2024-03-22 17:55         ` Tyler Retzlaff
2024-03-26  2:20           ` lihuisong (C)
2024-03-26 16:04             ` Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240320105529.5626-3-lihuisong@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=anatoly.burakov@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=liuyonglong@huawei.com \
    --cc=sivaprasad.tummala@amd.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).