From patchwork Fri Jan 5 20:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 10147019 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 D17B160134 for ; Fri, 5 Jan 2018 20:17:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5D3728446 for ; Fri, 5 Jan 2018 20:17:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA47328857; Fri, 5 Jan 2018 20:17:54 +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 483D628446 for ; Fri, 5 Jan 2018 20:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752736AbeAEURx (ORCPT ); Fri, 5 Jan 2018 15:17:53 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:42583 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbeAEURw (ORCPT ); Fri, 5 Jan 2018 15:17:52 -0500 Received: by mail-pl0-f68.google.com with SMTP id bd8so3666947plb.9; Fri, 05 Jan 2018 12:17:51 -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=s5sqq1ouncONXxcYlXa5u/KRQ0v5RWdyu4ZBd+UZ7jc=; b=NSkPzN2zJNuNRwYIZ9CREGmlbgbyvzIaoe4Vv8AwP7uX1fXjeTx3J9FB3nhMMPQECG qseQi+ywi1lwstM2EQTUVWABB3AzEYSeqcE5JlgTtJMaw88h1x3A6RJ8ScsFZFmQp3PG ai3FgtktS65ilrmQmP0BEGNyEJcEu1JS0tUGjjPC11ne5PAbre+KzT8R3fBWf4EeZvX2 XGRfT04fQZLWUH/GBwgjdX+uQox59sb3Nz5TGH9G3oMmLNPeBletneTMfcMU2+bs0GQH pYr5gHYY2fUtGiX/FpGB6+LdObX/dz81uQfTlRJqYfDrQJ3PO7OQyaWJGRXnhJZqY3Ia izZA== 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=s5sqq1ouncONXxcYlXa5u/KRQ0v5RWdyu4ZBd+UZ7jc=; b=fANvawctwtGyPC8Qu4xRCEu2cZbIXlfMdFwMbdmz7Wtxm5rJNrHQi/8Zp3eCwYI5H4 kmuENzk9aHgWC/Ha+ITOTrCKHrEydVcv8fnGeoLzr46Am0TdN628VnEY+iw2qHBS7Mu5 JnlH5iGpfIXEqj7oRm+z/se1WS876+n0Q580Jum8WCGEOyUtvS3gVqQgcR8BgaWhNqT4 3Zl1QPFJP8N6EeAWJ8HBH15RCjrVp0hRlbwVzbi9p4IcP8N3gIPCeaYNxOHYX6mIj3ax +KfgExxFxR8/OWZG+WpFbHTLxjbLazvbNh9IyZFhdE/J7TJIU7nduQ20r4uMTZfIrHr+ Yh5g== X-Gm-Message-State: AKGB3mJZeUHiLmkCZteHaoTYzyuNZyICWr+XxGRM8l3uTnpKxjgNfZDt dqGoNeLSp0qI6xfVjvMENCM= X-Google-Smtp-Source: ACJfBotWBoPRlXmiwJ0NaS8ugsT813Exgk2MwF/QIjgD/Z9bgmHSA78FIOKCCoUPeiASfpuX2huUEw== X-Received: by 10.84.177.129 with SMTP id x1mr4215987plb.361.1515183471533; Fri, 05 Jan 2018 12:17:51 -0800 (PST) Received: from s15.smythies.com (mail.smythies.com. [173.180.45.4]) by smtp.gmail.com with ESMTPSA id y7sm12006485pgr.64.2018.01.05.12.17.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 12:17:50 -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 V3] cpufreq: intel_pstate: allow trace in passive mode Date: Fri, 5 Jan 2018 12:17:10 -0800 Message-Id: <1515183430-7646-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. V3: Move largely duplicate code to a subroutine, as per feedback from V2. V2: prepare for resend. Rebase to current kernel, 4.15-rc3. Signed-off-by: Doug Smythies --- drivers/cpufreq/intel_pstate.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 93a0e88..2bb922e 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1943,13 +1943,38 @@ 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 (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 +1994,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 +2011,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; }