From patchwork Sat Dec 16 00:43:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 10116753 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 62B03603FA for ; Sat, 16 Dec 2017 00:43:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 534A12A1EB for ; Sat, 16 Dec 2017 00:43:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47FC62A1ED; Sat, 16 Dec 2017 00:43:51 +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 198982A1EB for ; Sat, 16 Dec 2017 00:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755872AbdLPAnt (ORCPT ); Fri, 15 Dec 2017 19:43:49 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:42788 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755824AbdLPAnr (ORCPT ); Fri, 15 Dec 2017 19:43:47 -0500 Received: by mail-pg0-f65.google.com with SMTP id e14so6879095pgr.9; Fri, 15 Dec 2017 16:43:47 -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=p4VPcpjibzzbnZu1bdraMA92V1uWzWc5+WNhYKxh6bQ=; b=NIez6bzTwCKw0o4N9sPG9B1FMkiQLDg3jJ8h46DOCUFpMNIQxwC4/3jDmXzMjMIvJZ V/3FrsJRnGwEGwqXTOo1SJsH2w7Kepnv/B2Rquejcgz79ZH9goEOUdlpspfyI0TsO84G GkmyqJJ4xFATa2Gby4IkqMXlVdyj8elWoyezrzerr5vvxAtB40GuVmBcE7RDhb6yohmu JYt0FFwoN6409kfB4RrOcDL2QeQ+pA9J75+dgfdK1cUN2mdB8n1k2E0SF+51xfGN+Ily BrXtP4Zjs2Ouy2fwz0dBThiq4k0TWanatatmr+egXq+qiDnnPZZZbZ8GKm7R+5aenyrZ 0Gow== 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=p4VPcpjibzzbnZu1bdraMA92V1uWzWc5+WNhYKxh6bQ=; b=eNJc5TH0jcMUDGCYPzkjhavGkwqRaZYEW+KSrjAUy8joavL4eqeK6xV99TISF1VUCS lMp369zvqZPbJMVuwam0IXCA9U00XbIZ381/A/wlpFtzFQmq9F7+Sy6rzHK5DRaNAVhs TqczeDqlXIsJP+Y8oxxsPiEb74H8bODHAHV7NySS2lZ20JL/VsziE6JeB2xBO0h5kTHj OHQwmdFOArPlRlUhHQco420JCebZzdjKuUyB7edDpFvux8g/iomBYBSW36XkW/Kp/6Xc 94KAcOfu/fsb0UtqL7xuta4kILX7kT0sYcHNk45NsaOaY5qrIuKocVZPjJ/UfQjYmAoU X++g== X-Gm-Message-State: AKGB3mKXbDSlfuM89o/uXHr5dpxrzkfl+zWYbHgWGcXX5rzZTtVSvheX DQUbPMgJdzeWZOpb/Bn2i5E= X-Google-Smtp-Source: ACJfBou4htWuc4PPjpKZGOmvWDTSw9eohD38dhse+3srm4S/gn66AIPtCeyJZAWJ2zqPDYBemd+qaw== X-Received: by 10.101.99.213 with SMTP id n21mr13907547pgv.64.1513385027341; Fri, 15 Dec 2017 16:43:47 -0800 (PST) Received: from s15.smythies.com (mail.smythies.com. [173.180.45.4]) by smtp.gmail.com with ESMTPSA id 73sm15596871pfr.145.2017.12.15.16.43.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Dec 2017 16:43:46 -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: [Resend][PATCH V2] cpufreq: intel_pstate: allow trace in passive mode Date: Fri, 15 Dec 2017 16:43:00 -0800 Message-Id: <1513384980-3428-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. V2: prepare for resend. Rebase to current kernel, 4.15-rc3. 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 93a0e88..fe25d69 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1949,7 +1949,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(); @@ -1969,12 +1972,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; @@ -1984,13 +2007,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; }