From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D4B843CFF; Wed, 20 Mar 2024 12:02:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FEBC410FC; Wed, 20 Mar 2024 12:02:46 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id B6E6D402A2 for ; Wed, 20 Mar 2024 12:02:43 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4V05Gf0VMlz1Q9lj; Wed, 20 Mar 2024 19:00:26 +0800 (CST) Received: from kwepemm600004.china.huawei.com (unknown [7.193.23.242]) by mail.maildlp.com (Postfix) with ESMTPS id 18FCF18007B; Wed, 20 Mar 2024 19:02:42 +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.35; Wed, 20 Mar 2024 19:02:41 +0800 From: Huisong Li To: CC: , , , , , , Subject: [PATCH 2/2] examples/l3fwd-power: add PM QoS request configuration Date: Wed, 20 Mar 2024 18:55:29 +0800 Message-ID: <20240320105529.5626-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20240320105529.5626-1-lihuisong@huawei.com> References: <20240320105529.5626-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: dggems706-chm.china.huawei.com (10.3.19.183) 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add PM QoS request configuration to declease the process resume latency. Signed-off-by: Huisong Li --- 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 #include #include +#include #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