Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752458AbdGYPWj (ORCPT ); Tue, 25 Jul 2017 11:22:39 -0400 Received: from mail1.bemta8.messagelabs.com ([216.82.243.193]:21202 "EHLO mail1.bemta8.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752186AbdGYPWh (ORCPT ); Tue, 25 Jul 2017 11:22:37 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA1VSWUwTURTlzdaBMPosItdGIDYuqIAQRfphlEQ JTQy4femHdqpD26QLmSlSEzW4BBBEQRC1gpJAJCBqQAxC+FA0hIorIJqgMShKrIofuCFqnOkA 6vs6957zzj3v5bKktpPRsYLHLYhO3q5nQihLlD82brU5Z1tC8S/G0Db0kTH0tVcyhrHiO8hwr 6eXNpTUNGkMTV+MKYyxueEoY3w+0MEYz/s2G1ue5FPGseaoTfR22uY0uzwm2jox2kdklW31DL 8vonNRwZZCFMJq8QiC26dv02rRhaCn+2SgoPAxEgrf1iOVOUNA6aGOSdkwgrJHvzSFKJhl8BL wfRggFTwbW2As70vgBol/IBjv6aIVIgzvhobGu7KIlUUCHCo8oEIzvDwSoygovBCu55YGLDls Av+jOo06q5yC+u/9hEIE41WQf7gMKRjhSKh49TLQJ3EEVFV4A6MAY6jteEiqOBzevf5NK7MQ3 gKjLTvUdjScuFRMqTgSei8UBSIDfo2gPm+EVotKBmomjmhUVTq0FrQTKh4m4Mqt/SqOhVPl1y adlkLBHe+kxgXH6vpJ1aiLhhOXuycTzYOLvs4A1mIr/K79SZSgZd5/HuGVw5Lyp15tX66250N 50ZDGG/iYWeA7O0xVI6oBLZYEcY8gxq2MN4s2i9Xt4G32uMQEQ7xDkCTeIth5sxS/y+VoRvIm BcnnBnp+fF0nmssS+nDua1zONu0Ms2v3XisvWXeK2XZB6kTzWFYP3AOTzM0SBYvgybTZ5XWco oEN1c/mlvMyzUlZvEOyWVTqLlrBVt9s/UywLRPd3wgt5XQ5BV0El6hIsSK1ZjunjaZWuxdF6s I4JEfThmYJosPm/p/3owgW6cO4W0qeUJvTPT3PL0ch5CiVZ7KVKG7+L6XLRZrQp1cPJjd+8ht THWnhM5mE8VVfG71Bh6+1Jo1kxkQto9+/kZrI/Oaz0SlzNpasj93+c+3p/rENGRn1z8JyBvfY ryeVmFIzd3pf7Eo/N5Q1gO5XaRa1BZUuQAdbdjxODnIkf+PejvuqPWJaRGPBGkfwuvQ+v86w7 03wj8WDVUSGSU9JVj5xKSlK/B+eF6AV1QMAAA== X-Env-Sender: yehs1@lenovo.com X-Msg-Ref: server-16.tower-37.messagelabs.com!1500996149!94316978!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/LFX0qBYd13GtU46aJi2Z6AgAAwqJCAAJzUgIAAGC3ggAAbzYCAAD2iAIAAheMAgAAIctA= Date: Tue, 25 Jul 2017 15:22:17 +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> <1500993452.4920.9.camel@linux.intel.com> In-Reply-To: <1500993452.4920.9.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;KL1PR0302MB2437;20:PURBpgkZxSBO2j0Dla2Vn2BuF5GMl3bAYe+HfUXr5ALJmiB25OYo9md1mocpNuYx+LuWTSSDAtBeaT6TkhciDCNUf5OEIOy48fBvJdo8jbPMlzJyyWMKLrPItsO8Oo3LGBBdoOxvVo+VOnjl8s2z4frM8wXabStgYnu9vNIvb2E= x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(6009001)(39450400003)(39840400002)(39410400002)(39400400002)(189002)(199003)(377424004)(24454002)(377454003)(2950100002)(101416001)(25786009)(86362001)(229853002)(2906002)(2900100001)(33656002)(54356999)(50986999)(76176999)(105586002)(3846002)(106356001)(102836003)(14454004)(6116002)(93886004)(5250100002)(7696004)(107886003)(38730400002)(4326008)(53546010)(97736004)(478600001)(9686003)(53936002)(8936002)(8676002)(81166006)(81156014)(68736007)(6246003)(99286003)(55016002)(54906002)(3280700002)(189998001)(7736002)(5660300001)(3660700001)(6436002)(6506006)(305945005)(74316002)(66066001);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1PR0302MB2437;H:KL1PR0302MB2502.apcprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 50a84d1f-2afb-49f0-5c33-08d4d370efa4 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:KL1PR0302MB2437; x-ms-traffictypediagnostic: KL1PR0302MB2437: 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)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6041248)(20161123564025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1PR0302MB2437;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1PR0302MB2437; 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 15:22:17.5156 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5c7d0b28-bdf8-410c-aa93-4df372b16203 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0302MB2437 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 v6PFMkvh008384 Content-Length: 7676 Lines: 202 Hi Srinivas, Oh, I see. Originally I thought this function "arch_freq_get_on_cpu" would have chance to expand to other platforms in the future. Because I found that it appears at cpufreq.c as __weak. But if it is sure that this function only works for x86 all the time, I think it doesn't matter about its position within show_cpuinfo_cur_freq. Thanks Huaisheng > > Hi Huaisheng, > > On Tue, 2017-07-25 at 07:03 +0000, Huaisheng HS1 Ye wrote: > > 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. > arch_freq_get_on_cpu is only implemented on x86, for other platforms it will > not change behavior. I didn't understand your comment about first choice. > > Thanks, > Srinivas > > > > 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,