From patchwork Wed May 12 16:32:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 93231 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37B87A0C41; Wed, 12 May 2021 18:33:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1FB15410DE; Wed, 12 May 2021 18:33:18 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id AF44A4003E; Wed, 12 May 2021 18:33:15 +0200 (CEST) IronPort-SDR: A01DM1sCHJ+m4P9Qd/ZXK6nbv5e6sytyDjyoGSFE0sX8Jjc/YiYgpAOOxVDVxjgoSRcg9ptPnv EnFotJmvN5Sg== X-IronPort-AV: E=McAfee;i="6200,9189,9982"; a="180014975" X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="180014975" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2021 09:33:03 -0700 IronPort-SDR: aJ+i+y6TceAUTGk0m/bb+lV90aUJVn4p66M+a+repsrJnmi061PHVcAT8oNMQr3+J2ODdxjpMN YQ6TgK3ZuxBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="430816381" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by orsmga007.jf.intel.com with ESMTP; 12 May 2021 09:33:02 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Wed, 12 May 2021 17:32:51 +0100 Message-Id: <20210512163254.9945-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210422144030.16746-1-david.hunt@intel.com> References: <20210422144030.16746-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2 1/4] test/power: fix check for cpu frequency 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 Sender: "dev" Different drivers present the current cpu core frequency in different sysfs iles. Some present it in cpuinfo_cur_freq, some in scaling_cur_freq, and some actually present it in both. This patch attempts to open one, if that fails, tries the other. Fixes: d550a8cc31f3 ("app/test: enhance power manager unit tests") Cc: stable@dpdk.org Signed-off-by: David Hunt --- changes in v2 none --- app/test/test_power_cpufreq.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c index f753d24ac5..52f58ef8b2 100644 --- a/app/test/test_power_cpufreq.c +++ b/app/test/test_power_cpufreq.c @@ -39,8 +39,10 @@ test_power_caps(void) #define TEST_FREQ_ROUNDING_DELTA 50000 #define TEST_ROUND_FREQ_TO_N_100000 100000 -#define TEST_POWER_SYSFILE_CUR_FREQ \ +#define TEST_POWER_SYSFILE_CPUINFO_FREQ \ "/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_cur_freq" +#define TEST_POWER_SYSFILE_SCALING_FREQ \ + "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq" static uint32_t total_freq_num; static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX]; @@ -58,12 +60,19 @@ check_cur_freq(unsigned lcore_id, uint32_t idx) int i; if (snprintf(fullpath, sizeof(fullpath), - TEST_POWER_SYSFILE_CUR_FREQ, lcore_id) < 0) { + TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) { return 0; } f = fopen(fullpath, "r"); if (f == NULL) { - return 0; + if (snprintf(fullpath, sizeof(fullpath), + TEST_POWER_SYSFILE_CPUINFO_FREQ, lcore_id) < 0) { + return 0; + } + f = fopen(fullpath, "r"); + if (f == NULL) { + return 0; + } } for (i = 0; i < MAX_LOOP; i++) { fflush(f); From patchwork Wed May 12 16:32:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 93232 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2188FA0C41; Wed, 12 May 2021 18:33:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6D1E841103; Wed, 12 May 2021 18:33:19 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 105D14003E; Wed, 12 May 2021 18:33:16 +0200 (CEST) IronPort-SDR: ETgnjyEGqqH6R/V97ryHtfuRrbTblXVFN6U9NEyyB5US0xopRY/vgtr2WtiE+vf4AYbiPSluvX CRSlDdaIF6qQ== X-IronPort-AV: E=McAfee;i="6200,9189,9982"; a="180014977" X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="180014977" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2021 09:33:05 -0700 IronPort-SDR: DSNGqAwT7w365B5xNBI0i3PTH1+fETI0PY8B6U0KTrOanO6r74++/JJKpu7BpE8AkEgHTjIAXZ hvrauCpJDodw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="430816390" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by orsmga007.jf.intel.com with ESMTP; 12 May 2021 09:33:03 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Wed, 12 May 2021 17:32:52 +0100 Message-Id: <20210512163254.9945-2-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512163254.9945-1-david.hunt@intel.com> References: <20210422144030.16746-1-david.hunt@intel.com> <20210512163254.9945-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2 2/4] test/power: add turbo mode to freq check function 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 Sender: "dev" With the intel_pstate driver and turbo enabled, the top frequency in the frequency array is the P1+1, i.e. 2300001, whereas the frequency shown in scaling_cur_freq could be a lot higher. This patch adds a flag to the check_cur_freq function so that we can specify if a frequency is greater than expected (turbo mode), in which case the check should be successful. Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature") Cc: stable@dpdk.org Signed-off-by: David Hunt --- changes in v2 changed check_cur_freq() to take a bool instead of an int, as suggested by Anatoly, and changed all the calls to use true/false. --- app/test/test_power_cpufreq.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c index 52f58ef8b2..2b4728d2e1 100644 --- a/app/test/test_power_cpufreq.c +++ b/app/test/test_power_cpufreq.c @@ -48,7 +48,7 @@ static uint32_t total_freq_num; static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX]; static int -check_cur_freq(unsigned lcore_id, uint32_t idx) +check_cur_freq(unsigned int lcore_id, uint32_t idx, bool turbo) { #define TEST_POWER_CONVERT_TO_DECIMAL 10 #define MAX_LOOP 100 @@ -90,7 +90,10 @@ check_cur_freq(unsigned lcore_id, uint32_t idx) / TEST_ROUND_FREQ_TO_N_100000; freq_conv = freq_conv * TEST_ROUND_FREQ_TO_N_100000; - ret = (freqs[idx] == freq_conv ? 0 : -1); + if (turbo) + ret = (freqs[idx] <= freq_conv ? 0 : -1); + else + ret = (freqs[idx] == freq_conv ? 0 : -1); if (ret == 0) break; @@ -183,7 +186,7 @@ check_power_get_freq(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, count); + ret = check_cur_freq(TEST_POWER_LCORE_ID, count, false); if (ret < 0) return -1; @@ -233,7 +236,7 @@ check_power_set_freq(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1); + ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, false); if (ret < 0) return -1; @@ -269,7 +272,7 @@ check_power_freq_down(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1); + ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, false); if (ret < 0) return -1; @@ -288,7 +291,7 @@ check_power_freq_down(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, 1); + ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, false); if (ret < 0) return -1; @@ -324,7 +327,7 @@ check_power_freq_up(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2); + ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2, false); if (ret < 0) return -1; @@ -343,7 +346,7 @@ check_power_freq_up(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, 0); + ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true); if (ret < 0) return -1; @@ -371,7 +374,7 @@ check_power_freq_max(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, 0); + ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true); if (ret < 0) return -1; @@ -399,7 +402,7 @@ check_power_freq_min(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1); + ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, false); if (ret < 0) return -1; @@ -433,7 +436,7 @@ check_power_turbo(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, 0); + ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true); if (ret < 0) return -1; @@ -452,7 +455,7 @@ check_power_turbo(void) } /* Check the current frequency */ - ret = check_cur_freq(TEST_POWER_LCORE_ID, 1); + ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, false); if (ret < 0) return -1; From patchwork Wed May 12 16:32:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 93234 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9BB54A0C41; Wed, 12 May 2021 18:33:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0A2B4110F; Wed, 12 May 2021 18:33:21 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 123734003E; Wed, 12 May 2021 18:33:17 +0200 (CEST) IronPort-SDR: Iyy50WjvByWTTGBicaC6mqcvqoCw6HP3TqPNaDh1R8y+I6fPjpY0f5A1le7JPhujjxnRf54WEF J7zR9Wqi4K3Q== X-IronPort-AV: E=McAfee;i="6200,9189,9982"; a="180014979" X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="180014979" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2021 09:33:06 -0700 IronPort-SDR: dc1sR3xrDvbFsh/icKnhpITYrKJLmGYlL4ARBINm1BDaYIQz6e9BnDIpQ9McGoQCYyOIsYrg95 GACHIaPDAgZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="430816422" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by orsmga007.jf.intel.com with ESMTP; 12 May 2021 09:33:05 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Wed, 12 May 2021 17:32:53 +0100 Message-Id: <20210512163254.9945-3-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512163254.9945-1-david.hunt@intel.com> References: <20210422144030.16746-1-david.hunt@intel.com> <20210512163254.9945-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2 3/4] test/power: fix low freq test when turbo enabled 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 Sender: "dev" With the intel_pstate driver and turbo enabled, indexing is slightly different to normal, so to get the test to work properly, enable turbo at the start. Fixes: ed7c51a6a680 ("app/test: vm power management") Cc: stable@dpdk.org Signed-off-by: David Hunt --- changes in v2 none --- app/test/test_power_cpufreq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c index 2b4728d2e1..c24b706f4f 100644 --- a/app/test/test_power_cpufreq.c +++ b/app/test/test_power_cpufreq.c @@ -249,6 +249,8 @@ check_power_freq_down(void) { int ret; + rte_power_freq_enable_turbo(TEST_POWER_LCORE_ID); + /* test with an invalid lcore id */ ret = rte_power_freq_down(TEST_POWER_LCORE_INVALID); if (ret >= 0) { From patchwork Wed May 12 16:32:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 93233 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73373A0C41; Wed, 12 May 2021 18:33:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E79C410FF; Wed, 12 May 2021 18:33:20 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 8A8AD4003F; Wed, 12 May 2021 18:33:17 +0200 (CEST) IronPort-SDR: ctFRmRksIE2t8HEEFMaAEj4RwcAzroxnVpOBhmS7s0gTK1lRa6DvvXaYWypkILSfvUrArD7U7m wiK660qzEHRg== X-IronPort-AV: E=McAfee;i="6200,9189,9982"; a="180014981" X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="180014981" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2021 09:33:07 -0700 IronPort-SDR: VEsk1dMMcAZva/QwFsFVYQ09kIicQXyF6JS3otRZT7jrgHYtYCHITREXpWBNXKKTPclPhaf+Sh jUzRH5FwrQxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="430816430" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by orsmga007.jf.intel.com with ESMTP; 12 May 2021 09:33:06 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Wed, 12 May 2021 17:32:54 +0100 Message-Id: <20210512163254.9945-4-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512163254.9945-1-david.hunt@intel.com> References: <20210422144030.16746-1-david.hunt@intel.com> <20210512163254.9945-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2 4/4] test/power: fix turbo test 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 Sender: "dev" when turbo is enabled or disabled, the frequency is set to a low non-turbo frequency, so we need to set to the frequency expected by the test before checking. Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature") Cc: stable@dpdk.org Signed-off-by: David Hunt --- changes in v2 none --- app/test/test_power_cpufreq.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c index c24b706f4f..0c3adc5f33 100644 --- a/app/test/test_power_cpufreq.c +++ b/app/test/test_power_cpufreq.c @@ -436,6 +436,12 @@ check_power_turbo(void) TEST_POWER_LCORE_ID); return -1; } + ret = rte_power_freq_max(TEST_POWER_LCORE_ID); + if (ret < 0) { + printf("Fail to scale up the freq to max on lcore %u\n", + TEST_POWER_LCORE_ID); + return -1; + } /* Check the current frequency */ ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true); @@ -455,6 +461,12 @@ check_power_turbo(void) TEST_POWER_LCORE_ID); return -1; } + ret = rte_power_freq_max(TEST_POWER_LCORE_ID); + if (ret < 0) { + printf("Fail to scale up the freq to max on lcore %u\n", + TEST_POWER_LCORE_ID); + return -1; + } /* Check the current frequency */ ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, false);