From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id B4708454A5;
	Wed, 19 Jun 2024 08:40:27 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7A2BF40A4B;
	Wed, 19 Jun 2024 08:40:27 +0200 (CEST)
Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190])
 by mails.dpdk.org (Postfix) with ESMTP id C773B4014F
 for <dev@dpdk.org>; Wed, 19 Jun 2024 08:40:26 +0200 (CEST)
Received: from mail.maildlp.com (unknown [172.19.88.163])
 by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4W3v675bCvz2Ck3h;
 Wed, 19 Jun 2024 14:36:31 +0800 (CST)
Received: from kwepemm600004.china.huawei.com (unknown [7.193.23.242])
 by mail.maildlp.com (Postfix) with ESMTPS id 694B218001E;
 Wed, 19 Jun 2024 14:40:25 +0800 (CST)
Received: from localhost.localdomain (10.28.79.22) by
 kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2507.39; Wed, 19 Jun 2024 14:40:24 +0800
From: Huisong Li <lihuisong@huawei.com>
To: <dev@dpdk.org>
CC: <mb@smartsharesystems.com>, <thomas@monjalon.net>, <ferruh.yigit@amd.com>, 
 <anatoly.burakov@intel.com>, <david.hunt@intel.com>,
 <sivaprasad.tummala@amd.com>, <david.marchand@redhat.com>,
 <liuyonglong@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH v3 2/2] examples/l3fwd-power: add PM QoS configuration
Date: Wed, 19 Jun 2024 14:31:44 +0800
Message-ID: <20240619063144.20733-3-lihuisong@huawei.com>
X-Mailer: git-send-email 2.22.0
In-Reply-To: <20240619063144.20733-1-lihuisong@huawei.com>
References: <20240320105529.5626-1-lihuisong@huawei.com>
 <20240619063144.20733-1-lihuisong@huawei.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [10.28.79.22]
X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To
 kwepemm600004.china.huawei.com (7.193.23.242)
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

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(+)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index fba11da7ca..d263cfef0a 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,
+					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;
 }
 
-- 
2.22.0