From patchwork Wed Apr 19 21:16:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 9689003 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 C142C602C9 for ; Wed, 19 Apr 2017 21:16:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B20B22842E for ; Wed, 19 Apr 2017 21:16:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A57D828438; Wed, 19 Apr 2017 21:16:47 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 97B9D2842E for ; Wed, 19 Apr 2017 21:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966777AbdDSVQp (ORCPT ); Wed, 19 Apr 2017 17:16:45 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:35552 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966699AbdDSVQn (ORCPT ); Wed, 19 Apr 2017 17:16:43 -0400 Received: by mail-io0-f196.google.com with SMTP id d203so7620775iof.2; Wed, 19 Apr 2017 14:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LnH2xxiUJmWeS8ZTM4yht6hlGyg0EKRUkOJ0oRSX/7k=; b=qqpCsNFnWPa0yuiYL4f7wNt/EuG2ukk67YLzgC64WV0KSK/5LG6pKBancLvoXxgxoj vi5N1Cvp9hsMCXvFUunbDfhEQac62fIEFhULaTWR2DNx7iIRM6MGYPEw+H38jZj0gBxT YL4OVXarZkseZbdeq5H1ofTrQvFZigTOmJFYY89kEqCp4RxOa1KR2O/MPSafKykvb2W+ vuTkwxbPLMB/UkPn9ZkQhvllZdiMyd3j15Xs1YfbTILU2oOXweHj75tLLqMBMpCOn9bN CdaSLo/d/RJ0wROzZSnXr8aNwYky5WEmtBaY7LoLAQQrFwhVdgbKmRS2oj+uag2WF/lK rkdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LnH2xxiUJmWeS8ZTM4yht6hlGyg0EKRUkOJ0oRSX/7k=; b=NsArgPayHXfzU981+enZHjLyLgzZPOQksGeGJ1fY8nKXvxgTcIM9yS79RwwLo4N+j8 SaZbqWzFBesXW9zHjlK8QQoon0eLPCFSG0XByavqxJbf3CvMT1qIk4b3/xbuiygrFpXi qjsCxboU4nfmWr6BOkncjZKyWik7OE6XjfkR2LDI8AHPw4gDgkDN/ait8MvznD9lXev7 ckEMa2ihiv14vAHvbEAPFBKr3zmcDQ97l0ny/CivzCsSF18KCI/0jl6mdx6XWL6rRVdi L2Vwa7RQoDYkUeAgHjPGxfO9iyPKHUGvu/ysCgL03pQjavPeIxxEescmpDFy33NVrdGz 3C3w== X-Gm-Message-State: AN3rC/57O1kDD3Uu3OGoPJk+icTiRVxfg2IgjheYrgNLPVoWYPRx0vDH Gh+yozagbRKlcw== X-Received: by 10.98.159.16 with SMTP id g16mr4915362pfe.189.1492636603017; Wed, 19 Apr 2017 14:16:43 -0700 (PDT) Received: from s15.smythies.com (mail.smythies.com. [173.180.45.4]) by smtp.gmail.com with ESMTPSA id 206sm6186624pfu.132.2017.04.19.14.16.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Apr 2017 14:16:42 -0700 (PDT) From: Doug Smythies X-Google-Original-From: Doug Smythies To: srinivas.pandruvada@linux.intel.com, rjw@rjwysocki.net Cc: dsmythies@telus.net, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH] cpufreq: intel_pstate: allow trace in passive mode Date: Wed, 19 Apr 2017 14:16:17 -0700 Message-Id: <1492636577-8507-1-git-send-email-dsmythies@telus.net> X-Mailer: git-send-email 2.7.4 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 Allow use of the trace_pstate_sample trace function when the intel_pstate driver is in passive mode. Since the core_busy and scaled_busy fields are not used, and it might be desirable to know which path through the driver was used, either intel_cpufreq_target or intel_cpufreq_fast_switch, re-task the core_busy field as a flag indicator. The user can then use the intel_pstate_tracer.py utility to summarize and plot the trace. In Passive mode the driver is only called if there is a need to change the target frequency, so durations (time gaps between calls) can be very very long. The user needs to understand, and not be confused by, this limitation. Signed-off-by: Doug Smythies --- drivers/cpufreq/intel_pstate.c | 50 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 283491f..04e91ed 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -2271,7 +2271,10 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy, { struct cpudata *cpu = all_cpu_data[policy->cpu]; struct cpufreq_freqs freqs; - int target_pstate; + struct sample *sample; + int target_pstate, from; + u64 time; + bool sample_taken; update_turbo_state(); @@ -2291,12 +2294,32 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy, break; } target_pstate = intel_pstate_prepare_request(cpu, target_pstate); + + from = cpu->pstate.current_pstate; + time = ktime_get(); + sample_taken = intel_pstate_sample(cpu, time); + if (target_pstate != cpu->pstate.current_pstate) { cpu->pstate.current_pstate = target_pstate; wrmsrl_on_cpu(policy->cpu, MSR_IA32_PERF_CTL, pstate_funcs.get_val(cpu, target_pstate)); } freqs.new = target_pstate * cpu->pstate.scaling; + + if (sample_taken) { + intel_pstate_calc_avg_perf(cpu); + sample = &cpu->sample; + trace_pstate_sample(0, + 0, + from, + cpu->pstate.current_pstate, + sample->mperf, + sample->aperf, + sample->tsc, + get_avg_frequency(cpu), + fp_toint(cpu->iowait_boost * 100)); + } + cpufreq_freq_transition_end(policy, &freqs, false); return 0; @@ -2306,13 +2329,36 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy, unsigned int target_freq) { struct cpudata *cpu = all_cpu_data[policy->cpu]; - int target_pstate; + struct sample *sample; + int target_pstate, from; + u64 time; + bool sample_taken; update_turbo_state(); target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); target_pstate = intel_pstate_prepare_request(cpu, target_pstate); + + from = cpu->pstate.current_pstate; + time = ktime_get(); + sample_taken = intel_pstate_sample(cpu, time); + intel_pstate_update_pstate(cpu, target_pstate); + + if (sample_taken) { + intel_pstate_calc_avg_perf(cpu); + sample = &cpu->sample; + trace_pstate_sample(100, + 0, + from, + cpu->pstate.current_pstate, + sample->mperf, + sample->aperf, + sample->tsc, + get_avg_frequency(cpu), + fp_toint(cpu->iowait_boost * 100)); + } + return target_pstate * cpu->pstate.scaling; }