From patchwork Thu Apr 22 14:40:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 92030 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 C408AA0548; Thu, 22 Apr 2021 16:40:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 921E441D91; Thu, 22 Apr 2021 16:40:40 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 1AC0C41C9D; Thu, 22 Apr 2021 16:40:38 +0200 (CEST) IronPort-SDR: HCj0/zsp1fkbG+mlscpsBYQQyD9nxGNXzO/XIAhv03wF3rKsqubwM0HsHW0yWMmg6d9mVRCMMY gfpWVwggOZCQ== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="192709701" X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="192709701" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 07:40:35 -0700 IronPort-SDR: IQ3c7t0hvunniWJmrZ/iIwgJlndNeuJ0aKiSsxcRSqCk/qry+Id5JGTHeYOJpTJNDRp0rqT8OX BiiRkZuvf+hw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="453273986" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2021 07:40:34 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Thu, 22 Apr 2021 15:40:27 +0100 Message-Id: <20210422144030.16746-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1 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 --- 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 Thu Apr 22 14:40:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 92032 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 D03ADA0548; Thu, 22 Apr 2021 16:40:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A52841DA1; Thu, 22 Apr 2021 16:40:44 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id BA89041D95; Thu, 22 Apr 2021 16:40:40 +0200 (CEST) IronPort-SDR: i98DdvLhazpalhyDrHRHj2LAQOkOBNNhwGZhfX0N4KZ0FZF3tw2vGa20wRekdepeSinW9mbubg H/3a2LHzT3uw== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="192709703" X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="192709703" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 07:40:36 -0700 IronPort-SDR: xL4WC5lJGQifxSY7nUJUZz+eeC/uPoxdAFPgADUazlgTGBrW+4gvozKvYlMlYrPLkBUra5uosz Ak1TGjhE5YKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="453273992" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2021 07:40:35 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Thu, 22 Apr 2021 15:40:28 +0100 Message-Id: <20210422144030.16746-2-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 v1 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 --- 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..33a68cf645 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, int 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, 0); 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, 0); 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, 0); 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, 0); 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, 0); 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, 1); 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, 1); 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, 0); 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, 1); 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, 0); if (ret < 0) return -1; From patchwork Thu Apr 22 14:40:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 92031 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 2E510A0548; Thu, 22 Apr 2021 16:40:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9AEA41D99; Thu, 22 Apr 2021 16:40:42 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 98A9041D92; Thu, 22 Apr 2021 16:40:40 +0200 (CEST) IronPort-SDR: HioFjt4vyKaQ5Qyj8WnCc6Oza9Y8FmxlrEXPkFCoYTR9stvj5N5o/cddKBjWnQRX6LCEd5//C4 cmY6SN2bXrPQ== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="192709708" X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="192709708" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 07:40:37 -0700 IronPort-SDR: dHq2LbwW3Ya/tqauEk1VYOPccnufcP2atLgmpiCS/hnvnsfqpy4P2VZXOBfbmnXUTdkp0CiHA+ 6uuNeIyqIzNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="453274000" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2021 07:40:36 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Thu, 22 Apr 2021 15:40:29 +0100 Message-Id: <20210422144030.16746-3-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 v1 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 --- 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 33a68cf645..e2be807318 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 Thu Apr 22 14:40:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 92033 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 6BFFEA0548; Thu, 22 Apr 2021 16:41:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 442F541DA5; Thu, 22 Apr 2021 16:40:45 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 5E96241D92; Thu, 22 Apr 2021 16:40:41 +0200 (CEST) IronPort-SDR: TUX8+pkifgNVXEoBKsSiCxWusf+O8++YWDaL8Qmyq6kO8ETHHxgEeYQ9Xd/JqDvTFMPqpS7lIr ZtWHif2Pa7iA== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="192709713" X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="192709713" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 07:40:39 -0700 IronPort-SDR: Kn1Fh05hrIedZh1zJ/HZAxAYfkixeuuqNd6Wu8eleErGGhFiFwsP2G79B1vAzFcyq7jgWMpJUB B7KgvFE8DYWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="453274005" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2021 07:40:37 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Thu, 22 Apr 2021 15:40:30 +0100 Message-Id: <20210422144030.16746-4-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 v1 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 --- 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 e2be807318..ceffebc428 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, 1); @@ -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, 0);