From patchwork Fri Jan 5 22:14:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 10147155 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 6998B60155 for ; Fri, 5 Jan 2018 22:14:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F774287B9 for ; Fri, 5 Jan 2018 22:14:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92FE42892C; Fri, 5 Jan 2018 22:14:43 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 337C4287B9 for ; Fri, 5 Jan 2018 22:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752720AbeAEWOm (ORCPT ); Fri, 5 Jan 2018 17:14:42 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35054 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752707AbeAEWOl (ORCPT ); Fri, 5 Jan 2018 17:14:41 -0500 Received: by mail-pg0-f68.google.com with SMTP id d6so1426953pgv.2; Fri, 05 Jan 2018 14:14:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cG/GHfyUvdgrhQBgseQxRfvS4WqiJMNLG4dNmcj6fA4=; b=k9QAKTwwWvkQ5PWI1t7/ON/cxoKIqKAFRKB/zWZP/1kq6hvsAVRMVmf5lsVYgPeF9t dFa+x24B9qdH6dFlYtiYZ6yI5hhiK5h8uCXTZaty5aoZFc4JanZ2Xqfp29DwspzVB0gV riHoZxiYjkV3F2Ry36AHYqimcSJmqt0ri8Bcd3FjVshkqxgO7le+0Sf4SSvmmfmNXmMG 1WOBqJWHw/0W/o9aYV7d4agomaWJG2Qig2CuxRjy2yCVgMYasJrB5vmp2BgfVF+vRTd8 +owTNszetAMCEkNhc6tOxVkrpm52F350PGoDLtPh+3fyfUm7HrfKd4IXk/6OW55hvz3r c/Ng== 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=cG/GHfyUvdgrhQBgseQxRfvS4WqiJMNLG4dNmcj6fA4=; b=De62sW4QBEUa3qLj477slF8/5s78OsMqcFR79cxT1saCK1DJwMrS6LQC4U+DbZeVHS UEus8qbFjPylpIbOufraWW7jrF4vVptYHJ0UnsV1ZxfHJ2fJ6g/SLRIyHsFLDnJDb5A8 jVmvdoMhE+IxvBFTMtpBFqDjzNoswjCY10wKjbGnTP/MK81yst3EnA5/gQYA9cuWUXzC pkATSpb+q8nipK3pB2LRzSv/6z9K3JloqTWKEX3CmTmkHIUMOes5rziBvzlcjq/El9nd 6IuZj2UznZQ+d3Sc/BAPe/+FoK8AJ+zgTNakeu+g4YV3ZIQOxYp74OxqRKMbhbps/heT WPfQ== X-Gm-Message-State: AKGB3mJso2r76MG6daE7IhtWT5a0Q2SqUCRbiY47bCvF3YTdzZXQDc+N BN9OXQ8w2Z/h6yv5vtoP928Qfg== X-Google-Smtp-Source: ACJfBov2wcCFIwx8t58Yl9gw/R379mIszSsnqJCxXtlf3AdemMPiP20+zlhu+BNlB/m+b7KeOEsIxQ== X-Received: by 10.98.236.93 with SMTP id k90mr4249194pfh.198.1515190480831; Fri, 05 Jan 2018 14:14:40 -0800 (PST) Received: from s15.smythies.com (mail.smythies.com. [173.180.45.4]) by smtp.gmail.com with ESMTPSA id 13sm15795188pfs.112.2018.01.05.14.14.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 14:14:40 -0800 (PST) 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 V4] cpufreq: intel_pstate: allow trace in passive mode Date: Fri, 5 Jan 2018 14:14:04 -0800 Message-Id: <1515190444-3254-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. Sometimes, in passive mode, the driver is not called for many tens or even hundreds of seconds. The user needs to understand, and not be confused by, this limitation. V4: Only execute the trace specific overhead code if trace is enabled. Suggested by Srinivas Pandruvada. V3: Move largely duplicate code to a subroutine. Suggested by Rafael J. Wysocki. V2: prepare for resend. Rebase to current kernel, 4.15-rc3. Signed-off-by: Doug Smythies --- drivers/cpufreq/intel_pstate.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 93a0e88..53bb953 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1943,13 +1943,40 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) return 0; } +static void intel_cpufreq_trace(struct cpudata *cpu, int fast, int from) +{ + struct sample *sample; + u64 time; + + time = ktime_get(); + if (trace_pstate_sample_enabled()) { + if (intel_pstate_sample(cpu, time)) { + sample = &cpu->sample; + /* In passvie mode the trace core_busy field is + * re-assigned to indicate if the driver call + * was via the normal or fast switch path. + * The scaled_busy field is not used, set to 0. + */ + trace_pstate_sample(fast, + 0, + from, + cpu->pstate.current_pstate, + sample->mperf, + sample->aperf, + sample->tsc, + get_avg_frequency(cpu), + fp_toint(cpu->iowait_boost * 100)); + } + } +} + static int intel_cpufreq_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { struct cpudata *cpu = all_cpu_data[policy->cpu]; struct cpufreq_freqs freqs; - int target_pstate; + int target_pstate, from; update_turbo_state(); @@ -1969,12 +1996,14 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy, break; } target_pstate = intel_pstate_prepare_request(cpu, target_pstate); + from = cpu->pstate.current_pstate; 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; + intel_cpufreq_trace(cpu, 0, from); cpufreq_freq_transition_end(policy, &freqs, false); return 0; @@ -1984,13 +2013,15 @@ 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; + int target_pstate, from; 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; intel_pstate_update_pstate(cpu, target_pstate); + intel_cpufreq_trace(cpu, 100, from); return target_pstate * cpu->pstate.scaling; }