From patchwork Thu Aug 25 17:00:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 9299603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16D8060757 for ; Thu, 25 Aug 2016 17:00:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1463293A7 for ; Thu, 25 Aug 2016 17:00:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5EC4293A9; Thu, 25 Aug 2016 17:00:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70A61293A7 for ; Thu, 25 Aug 2016 17:00:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755129AbcHYRAs (ORCPT ); Thu, 25 Aug 2016 13:00:48 -0400 Received: from cmta20.telus.net ([209.171.16.93]:55930 "EHLO cmta20.telus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754739AbcHYRAr (ORCPT ); Thu, 25 Aug 2016 13:00:47 -0400 Received: from dougxps ([173.180.45.4]) by cmsmtp with SMTP id cy1DbAomWwZSEcy1FbCv3Z; Thu, 25 Aug 2016 11:00:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=neo; t=1472144446; bh=ZJMTYPik6nmjlzk+KP3T5eDHdoSQ0vNwzA75+bpp0pc=; h=From:To:Cc:References:In-Reply-To:Subject:Date; b=cBrvd+88ITHKHRELn5oRqJJaVzno/Pgy64Dh7KkinjuSQQIdElgvvWfih3+c7tpfB V/1L/rdnpKR/z+6rpV1zjOOPxHQz++4uK5qjbEDDMngJ5Dde0pwsfwCerrQUVKxZlw /I3/7rQ5IXZM5I6NECd2rAM0OIQxooIU8peOtaBonJrUKf6MIn/eXX2Nh0LRdG6FO/ AyMMzxv0CgruG6V5IcIZV/vzQb+exv5ybCXDWZK28y/8hdXBF7oIeNVleom4HfCRF3 CSio87Ck4DPJV5nijeKAGH9k2E0A4rU9HtEn1frVTAaulLbC+AU9IQcuMVn+DNPth4 B1XI1J8obHjkQ== X-Authority-Analysis: v=2.2 cv=Jo8elIwC c=1 sm=1 tr=0 a=zJWegnE7BH9C0Gl4FFgQyA==:117 a=zJWegnE7BH9C0Gl4FFgQyA==:17 a=Pyq9K9CWowscuQLKlpiwfMBGOR0=:19 a=kj9zAlcOel0A:10 a=63M_e5Nw8hX17HW27YUA:9 a=XNtG6Jy-SyFJb-0N:21 a=Q65tOp-LEFLgivxv:21 a=CjuIK1q_8ugA:10 From: "Doug Smythies" To: Cc: , References: <1471907493-26639-1-git-send-email-dsmythies@telus.net> In-Reply-To: <1471907493-26639-1-git-send-email-dsmythies@telus.net> Subject: RE: [RFC][PATCH 8 of 7] cpufreq: intel_pstate: add iir filter to pstate. Date: Thu, 25 Aug 2016 10:00:40 -0700 Message-ID: <000d01d1fef2$36ff5960$a4fe0c20$@net> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdH8ypoiGysJTFHaRsKYJGuzrd6HjgCJUXMA Content-Language: en-ca X-CMAE-Envelope: MS4wfGQGymp0Q8GzhzzNr7NQpNw1qTdvLN6qmaBIVOmY/OYakrGDAKUdIFpbcVl+ICkKPuieeqIUqmk9FJ1giv4SrF3cw5b91NpqTBwifV8ks/WEadsgM/VL S/ISuxq2JiB/ZS8Hy72h9NcLRJdygqT/KvkWymrZqY4ViZYfzFeK5ViRg9aPORs1QhQEtz2W18c/j4v1Ibog7i7U0ew6ywYHWOm7xFOrJfy/jHLETrmvKLXl O5QjK6Jg5DtyYjaP6XTgRw== Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Srinivas: On 2016.08.22 16:12 Doug Smythies wrote: ...[cut]... + * + * no clamps. Pre-filter clamping was needed in past implementations. + * To Do: Is any pre-filter clamping needed here? */ Yes, clamping is needed, otherwise, and for example, the target pstate can "stick" low at high load for a few sample periods, until the filtered value gets high enough. For the fix, I clamped the post-filter output value (perhaps not in the best way, but for now): doug@s15:~/temp-k-git/linux/drivers/cpufreq$ git diff I'll send an updated patch in a few hours. ...[cut]... + * + * To Do: Often the actual pstate the system ran at over the last + * interval is not what was asked for, due to influence from + * other CPUs. It might make sense to use the average pstate + * (get_avg_pstate) as the old_output here (as per previous + * work by Philippe Longepe and Stephane Gasparini on the + * get_target_pstate_use_cpu_load method). Test it. + */ I have a version of this working. More on that it at a later date. ... Doug --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index ab5c004..56c09ef8f 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1307,6 +1307,7 @@ static inline int32_t get_target_pstate_default(struct cpudata *cpu) int64_t scaled_gain, unfiltered_target; int32_t busy_frac; int pstate; + int max_perf, min_perf; u64 duration_ns; busy_frac = div_fp(sample->mperf, sample->tsc); @@ -1399,6 +1400,14 @@ static inline int32_t get_target_pstate_default(struct cpudata *cpu) cpu->sample.target = div_u64((int_tofp(100) - scaled_gain) * cpu->sample.target + scaled_gain * unfiltered_target, int_tofp(100)); + /* + * Clamp the filtered value. + */ + intel_pstate_get_min_max(cpu, &min_perf, &max_perf); + if (cpu->sample.target < int_tofp(min_perf)) + cpu->sample.target = int_tofp(min_perf); + if (cpu->sample.target > int_tofp(max_perf)) + cpu->sample.target = int_tofp(max_perf); return fp_toint(cpu->sample.target + (1 << (FRAC_BITS-1))); }