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