Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751196AbdGYHEK (ORCPT ); Tue, 25 Jul 2017 03:04:10 -0400 Received: from mail1.bemta8.messagelabs.com ([216.82.243.199]:40475 "EHLO mail1.bemta8.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750781AbdGYHEI (ORCPT ); Tue, 25 Jul 2017 03:04:08 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA1WSa0hTYRjH955bx3LxNhOfVnZZdLM0K6iBX7p Bg4guhGBEddTTtthFztnW/FIWYaWZfkizZSW0ImZliqDOgjCz5rouNKigNMNmN8rsomady7p9 +z/P78//fd6HhyV1Nxg9y3tdvODgbAZmLGWe2r8gNfedJyv9RWmGsbn7HWN8FKxijAMlbch4J xyhjWVn68YY6wZNyxlTfeAwY3rWdZUxnQ5tNDV0HqRMA/VTN9BbaKsj2+ndQVsCjUyef5X3Ub CNLkANK4vQWFaH+xCU1zQhtWhH8OSGXykofISEcN01SiWVBAx1PozZehEMhz+QRSiOZfA8CL3 tUvREbIaBwkHFROIhBN/D7bQMEnAuBC52SCZWMvGwv2iP6s+E4bM/GVlTeBYM3mqlZK3FOyBy 7j0TG5CAT29+EjKIw0uhr+a7kolwMlT0PFf6JE6CUxU+pQ8Yg//qfVLViRB9OUrL7yK8Cd43b FPb06C0poRSdTJEzhQrMwN+iaDZX0aoxXkGThYdiwWtg2j5A1oFvQT0POxm5FTAC+DmxxTVkw KH2nyEqp1QfOB4LKidhqYLP2JBU+B8qFXROmyBUf8IUYbm+/75hE+KJaWt1gYXqu0ZcKy4e4x PWcwECJ3opaoRFUBzRV7w8ELq4iVp2YLVbHHZOastdVG6Mc3OiyJn5m1ctpiW47TXI+mU9mo0 qAlVtqxpRZNYwpCoNQc9Wbrx2c7cfAsnWrYLbhsvtqIpLGsAbcUbiU0QeDPv3Wm1Sff4GwMbb 5io/SRjrZjH2UWrWUUdaAlbfb3xM8E2DN/+Sugoh9PB65O0zbIVy1aL2/En6PdtR1CyPkGLNB qNLj6PF+xW1/+8HyWxyJCgzXgrpcRbHa4/7/VLoxDSKFWVbnkUF/cX6QvQ5q0pW57me8e55ja 2TD7asju64viXntXzJu0bOtC3bPK+iyM3dyUWBHLcs/M9aPrrV51V52pDq7IKK7dlrc791rTV k+HWp1u62Y6SOI7sXZ8/OtoWHJ45fcYl1hHNKR15Yq6edbRQY6wRnk1bK97dn2ntOnP9cvuV6 OOwL3J/jqn8noESLdyiFFIQuV/9FesK1gMAAA== X-Env-Sender: yehs1@lenovo.com X-Msg-Ref: server-11.tower-128.messagelabs.com!1500966238!65736890!1 X-Originating-IP: [103.30.234.44] X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked From: Huaisheng HS1 Ye To: Srinivas Pandruvada , "Rafael J. Wysocki" CC: "lenb@kernel.org" , "viresh.kumar@linaro.org" , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , NingTing Cheng Subject: RE: [PATCH] cpufreq: intel_pstate: Fix cpuinfo_cur_freq after performance governor changes Thread-Topic: [PATCH] cpufreq: intel_pstate: Fix cpuinfo_cur_freq after performance governor changes Thread-Index: AQHTBD++fCU7C/LFX0qBYd13GtU46aJi2Z6AgAAwqJCAAJzUgIAAGC3ggAAbzYCAAD2iAA== Date: Tue, 25 Jul 2017 07:03:36 +0000 Message-ID: References: <1500875013-123321-1-git-send-email-yehs1@lenovo.com> <7185077.O26hx51RqR@aspire.rjw.lan> <13292124.r3mFCOTPK8@aspire.rjw.lan> <1500951465.4920.2.camel@linux.intel.com> In-Reply-To: <1500951465.4920.2.camel@linux.intel.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [57.197.58.2] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1PR0302MB2469;20:JYpzCwowmurdveyqnFm8r6hKPOoFClRxLLz7KQ6BHto5CDl2CZQHw9MbcC4awlL5pfZ0RMyHn4UvS3eatT2XtT/yKqhWfwdCT/xN+bxAisz66KjRcTtP0V+p3vWxgotbvBtYMD1M3lG9axmrZbY6qB900o4V1QmUzsdQxMZbqXg= x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(6009001)(39450400003)(39400400002)(39840400002)(39410400002)(377454003)(377424004)(199003)(189002)(24454002)(43544003)(2950100002)(99286003)(66066001)(229853002)(33656002)(2906002)(68736007)(55016002)(189998001)(8936002)(6436002)(6246003)(14454004)(3660700001)(4326008)(9686003)(54906002)(53936002)(81166006)(81156014)(8676002)(97736004)(305945005)(105586002)(76176999)(106356001)(54356999)(7696004)(6506006)(74316002)(38730400002)(50986999)(107886003)(86362001)(3280700002)(93886004)(53546010)(3846002)(6116002)(2900100001)(25786009)(478600001)(102836003)(5250100002)(7736002)(5660300001)(101416001);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1PR0302MB2469;H:KL1PR0302MB2502.apcprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; x-ms-office365-filtering-correlation-id: 2d8eaec1-cf5a-4932-4361-08d4d32b4513 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:KL1PR0302MB2469; x-ms-traffictypediagnostic: KL1PR0302MB2469: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6041248)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1PR0302MB2469;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1PR0302MB2469; x-forefront-prvs: 03793408BA spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2017 07:03:36.0777 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5c7d0b28-bdf8-410c-aa93-4df372b16203 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0302MB2469 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v6P74HFU010348 Content-Length: 6219 Lines: 155 Hi Srinivas, Your idea is great, but your patch at cpufreq.c will force all platforms to use scaling_cur_freq as first choice when userspace wants to access cpuinfo_cur_freq. It is ok for intel x86 platfrom but hard to say with other platforms. I modified it like that, it looks more reasonable. How about that? Hi Rafael, Deleting "get" function pointer within intel_pstate would lead to sysfs interface cpuinfo_cur_freq disappearing, because of cpufreq_add_dev_interface will check "cpufreq_driver->get" for it. Perhaps just return 0 with in intel_pstate_get would be a workaround for this issue, how about it? I have tested this patch based on Purley platform, both Hardware and Software P-states works correct, we could get accurate and same frequency from cpuinfo_cur_freq and scaling_cur_freq. drivers/cpufreq/cpufreq.c | 4 ++++ drivers/cpufreq/intel_pstate.c | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9bf97a3..922f9d9 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -694,6 +694,10 @@ static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy, if (cur_freq) return sprintf(buf, "%u\n", cur_freq); + cur_freq = arch_freq_get_on_cpu(policy->cpu); + if (cur_freq) + return sprintf(buf, "%u\n", cur_freq); + return sprintf(buf, "\n"); } diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 6cd5035..33e6c10 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1924,9 +1924,11 @@ static int intel_pstate_init_cpu(unsigned int cpunum) static unsigned int intel_pstate_get(unsigned int cpu_num) { - struct cpudata *cpu = all_cpu_data[cpu_num]; - - return cpu ? get_avg_frequency(cpu) : 0; + /* + * Use frequency from scaling_cur_freq, reserve this function + * for existing of sysfs cpuinfo_cur_freq. + */ + return 0; } static void intel_pstate_set_update_util_hook(unsigned int cpu_num) > On Tue, 2017-07-25 at 01:46 +0000, Huaisheng HS1 Ye wrote: > > Hi Rafael, > > > > If you delete "get" function implement within intel_pstate, the sysfs > > interface cpuinfo_cur_freq will display all the time. > cpuinfo_cur_freq by definition should show actual frequency HW frequency. > Unless I missed something. So Len Brown's patch should also take care of this > to get from arch specific function is available. > So in addition to Rafael's change, what about this? > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index > 9bf97a3..29ec687 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -689,8 +689,13 @@ store_one(scaling_max_freq, max); >  static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy, >                                         char *buf) >  { > -       unsigned int cur_freq = __cpufreq_get(policy); > +       unsigned int cur_freq; > > +       cur_freq = arch_freq_get_on_cpu(policy->cpu); > +       if (cur_freq) > +               return sprintf(buf, "%u\n", cur_freq); > + > +       cur_freq = __cpufreq_get(policy); >         if (cur_freq) >                 return sprintf(buf, "%u\n", cur_freq); > > > > Thanks, > Srinivas > > > To be honest, at the beginning I have consider this way like you > > patched, but based two reasons below, it is conservative for us to do > > that. > > > > 1. I am worried about whether it would lead to confusion for customers > > or Linux OS venders who are accustomed to cpuinfo_cur_freq. > > 2. This is the first time for me to offer patch to intel_pstate, not > > sure whether it could be accepted by you. > > > > > > > > On Monday, July 24, 2017 03:32:47 PM Huaisheng HS1 Ye wrote: > > > > > > > > Hi Rafael, > > > > Thanks for your reply. > > > > > > > > > > > > > > On Monday, July 24, 2017 05:43:14 AM Huaisheng HS1 Ye wrote: > > > > > > > > > > > > After commit 82b4e03e01bc (intel_pstate: skip scheduler hook > > > > > > when in "performance" mode) Software P-state control modes > > > > > > couldn't get dynamic value during performance mode, > > > > > Please explain what you mean here. > > > > > > > > > commit 82b4e03e01bc (intel_pstate: skip scheduler hook when in > > > > "performance" mode) disables intel_pstate_set_update_util_hook > > > > when current policy is performance within function > > > > intel_pstate_set_policy. > > > > It leads to Software P-states couldn't update sysfs interface > > > > cpuinfo_cur_freq's value during performance mode, because of > > > > pstate_funcs.update_util couldn't set for the given CPU. > > > > > > > > > > > > > > I guess you carried out some tests and the results were not as > > > > > expected, so what was the test? > > > > Exactly, we check the sysfs interface cpuinfo_cur_freq and the > > > > output of cpupower frequency-info both with performance mode. > > > OK, so what about the change below: > > > > > > --- > > >  drivers/cpufreq/intel_pstate.c |    8 -------- > > >  1 file changed, 8 deletions(-) > > > > > > Index: linux-pm/drivers/cpufreq/intel_pstate.c > > > > ============================================================== > > > ===== > > > --- linux-pm.orig/drivers/cpufreq/intel_pstate.c > > > +++ linux-pm/drivers/cpufreq/intel_pstate.c > > > @@ -1674,13 +1674,6 @@ static int intel_pstate_init_cpu(unsigne > > >   return 0; > > >  } > > > > > > -static unsigned int intel_pstate_get(unsigned int cpu_num) -{ > > > - struct cpudata *cpu = all_cpu_data[cpu_num]; > > > - > > > - return cpu ? get_avg_frequency(cpu) : 0; > > > -} > > > - > > >  static void intel_pstate_set_update_util_hook(unsigned int > > > cpu_num)  { > > >   struct cpudata *cpu = all_cpu_data[cpu_num]; @@ -1921,7 > > > +1914,6 @@ > > > static struct cpufreq_driver intel_pstat > > >   .setpolicy = intel_pstate_set_policy, > > >   .suspend = intel_pstate_hwp_save_state, > > >   .resume = intel_pstate_resume, > > > - .get = intel_pstate_get, > > >   .init = intel_pstate_cpu_init, > > >   .exit = intel_pstate_cpu_exit, > > >   .stop_cpu = intel_pstate_stop_cpu,