Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932564AbdGXPdJ (ORCPT ); Mon, 24 Jul 2017 11:33:09 -0400 Received: from mail1.bemta8.messagelabs.com ([216.82.243.207]:12437 "EHLO mail1.bemta8.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259AbdGXPdC (ORCPT ); Mon, 24 Jul 2017 11:33:02 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA1WSa0hTYRjH9+5cOoVHXo+WT0MNBmapMy2oFRb 1IRpClEFEfijP8rgNdrGdaetDmiZkK0sky0vWSiuyC7gK05azoYIWjJQkIuw2yqZFZNGVaGdn Wn37v8/v/1zeh4chOC+tYgSnQ7BbebOankcaUkKZGk182c7sxrFYbffL97R2tOcMrZ2u7Ufah w9GKG1dW+ccbecX3Xpa5+k4QuuejXlp3dmhfN2tx4dJ3bQnZStVQJmsepuzkDK6rr1EJRdSnV 3fJ+YcRFMpLjSP4fBbBBef1hMuNDf8GETw6+gKCZD4GAHjbc8o2dWkhNaTE4T8CCKoCw5EUmi 8FIamxiI6AWdA67HhiInAbUr43RekJBCPi6DjmgSYsEmAKle5LNfAx28VkoPEqXC7uiHiZnEh 1IdaKMnC4WKoH1ZL4bk4G3w3JkhJI5wMp149V0qawInQeqo5kgoYQ7s3QMh6Prx7/TtSBuFt8 OHWLjm8CE5crSVlnQwj544iaWDArxEMeKaiuZvh8vgbSgajSvhxvD/aIBNCz+ui2Xkw3vc1Gr eB3x8g5IRBCg75HiEZJEGt+260UiUNNe+7kLxrI7jqr6A6lNH8zy9knQnuu59oWWfApfOTRHN kMXEw1BQk3YjsQEtEwV4m2DXLc7L0dpPB6LDwJrMmJ1ubZRFEkTcIZl4vZu2xWTwofEkVCgW6 g7oDm/xoIaNUz2c5ZdlOLlZvK9pv5EXjbnupWRD9KIlh1MB+iQuzOLtgEJzFJnP4HGcwMDHqB DaTC2NWLOEtoskgo2GkYdx9XZ+VHGm1WQVVIvtDqoElk7HUOlti5qhHULIqnkUKhYKLKRHsFp Pjfx5CiQxSx7OJUqsYk9Ux2ykUHkIZHuJMY6k0hIP/i1QHUXpVa9Lk7tWnp458creoCvTLNtx /YcjbWL5kb5pq4fbpspieuPQ7W9quOITJpIyqtI70mtx9nytr2nes8l/vKv95D1X0VHGealdl 59Xqt74nvcFCz4FF/CF23eLrweMFeMHDfF2vLzkX3fPdXOvUTmxo+b5yZfe4piEw6h30to8E1 KRo5HPSCbvI/wFaYapizwMAAA== X-Env-Sender: yehs1@lenovo.com X-Msg-Ref: server-16.tower-37.messagelabs.com!1500910374!94140891!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: "Rafael J. Wysocki" CC: "srinivas.pandruvada@linux.intel.com" , "lenb@kernel.org" , "viresh.kumar@linaro.org" , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" 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/LFX0qBYd13GtU46aJi2Z6AgAAwqJA= Date: Mon, 24 Jul 2017 15:32:47 +0000 Message-ID: References: <1500875013-123321-1-git-send-email-yehs1@lenovo.com> <7185077.O26hx51RqR@aspire.rjw.lan> In-Reply-To: <7185077.O26hx51RqR@aspire.rjw.lan> 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;KL1PR0302MB2616;20:sSKisxMJk11Sp+NCmtwRCLROQilTFuFv9vkEmUFj6TcWoc7m4XpY/lwYS0tLs82OPfez7kQCmUFKrc24O7Sz7HX5uLYdcQf2vliDcODdd9MDq5w4jcSo9QUDQi1lwdC7PcLG3LJKuyraM8CrRSNMs6QvzDQGSymQrkaotC6DKFk= x-ms-office365-filtering-correlation-id: 18dd1e33-b2f2-47d6-8070-08d4d2a93ca2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:KL1PR0302MB2616; x-ms-traffictypediagnostic: KL1PR0302MB2616: x-exchange-antispam-report-test: UriScan:(3940261145250)(265634631926514); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6041248)(20161123564025)(20161123555025)(20161123560025)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1PR0302MB2616;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1PR0302MB2616; x-forefront-prvs: 0378F1E47A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39400400002)(39410400002)(39840400002)(39450400003)(24454002)(189002)(199003)(377454003)(106356001)(105586002)(2906002)(3280700002)(3660700001)(66066001)(7696004)(14454004)(54356999)(76176999)(50986999)(101416001)(68736007)(74316002)(5250100002)(5660300001)(33656002)(6116002)(102836003)(3846002)(53546010)(55016002)(99286003)(189998001)(97736004)(2950100002)(6916009)(54906002)(305945005)(110136004)(86362001)(81156014)(81166006)(8676002)(8936002)(25786009)(9686003)(6506006)(4326008)(6246003)(229853002)(38730400002)(2900100001)(53936002)(7736002)(478600001)(6436002);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1PR0302MB2616;H:KL1PR0302MB2502.apcprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jul 2017 15:32:47.0921 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5c7d0b28-bdf8-410c-aa93-4df372b16203 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0302MB2616 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 quoted-printable to 8bit by nfs id v6OFXEDY014930 Content-Length: 4682 Lines: 112 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. For example, we list logic CPU 63's sysfs interface and output of cpupower with performance mode below, analyzing CPU 63: driver: intel_pstate CPUs which run at the same hardware frequency: 63 CPUs which need to have their frequency coordinated by software: 63 maximum transition latency: Cannot determine or is not supported. hardware limits: 1000 MHz - 3.70 GHz available cpufreq governors: performance powersave current policy: frequency should be within 1000 MHz and 3.70 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency: 1.07 GHz (asserted by call to hardware) <--------cpuinfo_cur_freq boost state support: Supported: yes Active: yes [root@localhost cpufreq]# pwd /sys/devices/system/cpu/cpu63/cpufreq [root@localhost cpufreq]# cat cpuinfo_cur_freq scaling_cur_freq 1070379 2796179 The value of cpuinfo_cur_freq is static always during performance mode, because of "cpu->sample.core_avg_perf" doesn't have chance to be updated when driver leaves from powersave mode. Its value equals to last sample result which comes from function intel_pstate_calc_avg_perf. commit f8475cef (x86: use common aperfmperf_khz_on_cpu() to calculate KHz using APERF/MPERF) offers a great method to help scaling_cur_freq gets accurate frequency. And for some tools like cpupower which would try to get cpuinfo_cur_freq at first to show current frequency, if it fails then it would move to scaling_cur_freq which represents the real value. > > > and it still in last value from powersave mode, so clear its value to > > get same behavior as Hardware P-state to avoid confusion. > > And please explain why it should be fixed the way you've done that. > In order to make sure that cpuinfo_cur_freq couldn't get an effective value, we clean up "sample.core_avg_perf" when cpu's policy set to performance mode. so the reading of sysfs cpuinfo_cur_freq would get "" always within performance mode, which is same with the status when HWP has been enabled. With this patch, logic CPU 63's sysfs interface and output of cpupower with performance mode would be like this, analyzing CPU 63: driver: intel_pstate CPUs which run at the same hardware frequency: 63 CPUs which need to have their frequency coordinated by software: 63 maximum transition latency: Cannot determine or is not supported. hardware limits: 1000 MHz - 3.70 GHz available cpufreq governors: performance powersave current policy: frequency should be within 1000 MHz and 3.70 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency: Unable to call hardware <--------cpuinfo_cur_freq current CPU frequency: 2.80 GHz (asserted by call to kernel) <--------scaling_cur_freq boost state support: Supported: yes Active: yes [root@localhost cpufreq]# pwd /sys/devices/system/cpu/cpu63/cpufreq [root@localhost cpufreq]# cat cpuinfo_cur_freq scaling_cur_freq 2800000 > > Signed-off-by: Huaisheng Ye > > --- > > drivers/cpufreq/intel_pstate.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/cpufreq/intel_pstate.c > > b/drivers/cpufreq/intel_pstate.c index 6cd5035..c675626 100644 > > --- a/drivers/cpufreq/intel_pstate.c > > +++ b/drivers/cpufreq/intel_pstate.c > > @@ -2050,6 +2050,7 @@ static int intel_pstate_set_policy(struct > cpufreq_policy *policy) > > */ > > intel_pstate_clear_update_util_hook(policy->cpu); > > intel_pstate_max_within_limits(cpu); > > + cpu->sample.core_avg_perf = 0; > > } else { > > intel_pstate_set_update_util_hook(policy->cpu); > > } > >