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);