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 62120A0548; Tue, 20 Apr 2021 16:01:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EAA441749; Tue, 20 Apr 2021 16:01:45 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 9D22641735; Tue, 20 Apr 2021 16:01:43 +0200 (CEST) IronPort-SDR: PM9YSw3Sv7PyZbS5QY2D910y6pixKCP6yGpuNMrGlk6Gx2xgm17/rMFDKbyRzRfCKtkB5wBD8c lL+y8yGyFAiA== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="259465966" X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="259465966" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 07:01:42 -0700 IronPort-SDR: cQe7r3MTrkyhQhb8jW93lakRn6vM/YIpqJzBvJSp6OQ1GB0XT8KOP4kxl99kI29od0WAy8EIbL g5wcLjuyEisQ== X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="426962684" Received: from dhunt5-mobl5.ger.corp.intel.com (HELO [10.252.30.174]) ([10.252.30.174]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 07:01:40 -0700 To: Richael Zhuang , dev@dpdk.org Cc: nd@arm.com, alan.carew@intel.com, stable@dpdk.org, Pablo de Lara References: <20210407074636.26891-2-richael.zhuang@arm.com> <20210415055930.3899-1-richael.zhuang@arm.com> <20210415055930.3899-3-richael.zhuang@arm.com> From: David Hunt Message-ID: <97bb26af-2863-5828-9c7a-2409278ee7b6@intel.com> Date: Tue, 20 Apr 2021 15:01:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <20210415055930.3899-3-richael.zhuang@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [dpdk-dev] [PATCH v5 2/2] test/power: round cpuinfo cur freq value in cpufreq autotest 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" On 15/4/2021 6:59 AM, Richael Zhuang wrote: > The value in "/sys/.../cpuinfo_cur_freq" may not be exactly the > same as what was set. For example, if "2400000" is written to > "/sys/.../cpufreq/scaling_setspeed" to set the frequency, then the > value in "/sys/.../cpuinfo_cur_freq" may be "2401222". So need to > round the value. > > Fixes: ed7c51a6a680 ("app/test: vm power management") > Cc: alan.carew@intel.com > Cc: stable@dpdk.org > > Signed-off-by: Richael Zhuang > --- > app/test/test_power_cpufreq.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c > index d47b3e0a1..f753d24ac 100644 > --- a/app/test/test_power_cpufreq.c > +++ b/app/test/test_power_cpufreq.c > @@ -35,6 +35,10 @@ test_power_caps(void) > #define TEST_POWER_LCORE_INVALID ((unsigned)RTE_MAX_LCORE) > #define TEST_POWER_FREQS_NUM_MAX ((unsigned)RTE_MAX_LCORE_FREQS) > > +/* macros used for rounding frequency to nearest 100000 */ > +#define TEST_FREQ_ROUNDING_DELTA 50000 > +#define TEST_ROUND_FREQ_TO_N_100000 100000 > + > #define TEST_POWER_SYSFILE_CUR_FREQ \ > "/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_cur_freq" > > @@ -67,7 +71,17 @@ check_cur_freq(unsigned lcore_id, uint32_t idx) > goto fail_all; > > cur_freq = strtoul(buf, NULL, TEST_POWER_CONVERT_TO_DECIMAL); > - ret = (freqs[idx] == cur_freq ? 0 : -1); > + > + /* convert the frequency to nearest 100000 value > + * Ex: if cur_freq=1396789 then freq_conv=1400000 > + * Ex: if cur_freq=800030 then freq_conv=800000 > + */ > + unsigned int freq_conv = 0; > + freq_conv = (cur_freq + TEST_FREQ_ROUNDING_DELTA) > + / TEST_ROUND_FREQ_TO_N_100000; > + freq_conv = freq_conv * TEST_ROUND_FREQ_TO_N_100000; > + > + ret = (freqs[idx] == freq_conv ? 0 : -1); > > if (ret == 0) > break; Hi Richael,    I played around with this, rounds nicely. I found an unrelated issue around turbo mode that I need to look at but this patch looks fine. Reviewed-by: David Hunt