linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Smythies <doug.smythies@gmail.com>
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	[thread overview]
Message-ID: <1492636577-8507-1-git-send-email-dsmythies@telus.net> (raw)

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 <dsmythies@telus.net>
---
 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;
 }
 
-- 
2.7.4

                 reply	other threads:[~2017-04-19 21:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492636577-8507-1-git-send-email-dsmythies@telus.net \
    --to=doug.smythies@gmail.com \
    --cc=dsmythies@telus.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=srinivas.pandruvada@linux.intel.com \
    --subject='Re: [PATCH] cpufreq: intel_pstate: allow trace in passive mode' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).