public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, cpufreq@vger.kernel.org,
	venkatesh.pallipadi@intel.com, Thomas Renninger <trenn@suse.de>
Subject: [PATCH 6/8] CPUFREQ: Add average frequency to sysfs exported files of cpufreq_stats
Date: Fri, 17 Apr 2009 16:22:10 +0200	[thread overview]
Message-ID: <1239978132-6261-7-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1239978132-6261-1-git-send-email-trenn@suse.de>

Average frequency can now be monitored easily (e.g. every second) by:
watch -n1 cat /sys/devices/system/cpu/cpu*/cpufreq/stats/average_freq
if CONFIG_CPU_FREQ_STAT is compiled and the cpufreq_stats module got
loaded.

Signed-off-by: Thomas Renninger <trenn@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>
Cc: <cpufreq@vger.kernel.org>
---
 drivers/cpufreq/cpufreq_stats.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 5a62d67..64542dd 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -20,6 +20,9 @@
 #include <linux/spinlock.h>
 #include <linux/notifier.h>
 #include <asm/cputime.h>
+#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
+#include <asm/processor.h>
+#endif
 
 static spinlock_t cpufreq_stats_lock;
 
@@ -44,6 +47,10 @@ struct cpufreq_stats {
 };
 
 static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table);
+#ifdef CONFIG_X86_AVERAGE_FREQUENCY
+static DEFINE_PER_CPU(u64, saved_aperf);
+static DEFINE_PER_CPU(u64, saved_mperf);
+#endif
 
 struct cpufreq_stats_attribute {
 	struct attribute attr;
@@ -139,6 +146,28 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
 CPUFREQ_STATDEVICE_ATTR(trans_table, 0444, show_trans_table);
 #endif
 
+#ifdef CONFIG_X86_AVERAGE_FREQUENCY
+static ssize_t show_average_freq(struct cpufreq_policy *policy, char *buf)
+{
+	ssize_t len;
+	unsigned int average_perf;
+
+	if (!cpu_has(&current_cpu_data, X86_FEATURE_IDA)) {
+		len = sprintf(buf, "not supported\n");
+		return len;
+	}
+
+	average_perf = get_average_perf(policy, policy->cpu,
+					&per_cpu(saved_aperf, policy->cpu),
+					&per_cpu(saved_mperf, policy->cpu));
+
+	len = sprintf(buf, "%d\n", average_perf);
+	return len;
+}
+CPUFREQ_STATDEVICE_ATTR(average_freq, 0444, show_average_freq);
+#endif
+
+
 CPUFREQ_STATDEVICE_ATTR(total_trans, 0444, show_total_trans);
 CPUFREQ_STATDEVICE_ATTR(time_in_state, 0444, show_time_in_state);
 
@@ -148,6 +177,9 @@ static struct attribute *default_attrs[] = {
 #ifdef CONFIG_CPU_FREQ_STAT_DETAILS
 	&_attr_trans_table.attr,
 #endif
+#ifdef CONFIG_X86_AVERAGE_FREQUENCY
+	&_attr_average_freq.attr,
+#endif
 	NULL
 };
 static struct attribute_group stats_attr_group = {
-- 
1.6.0.2


  parent reply	other threads:[~2009-04-17 14:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-17 14:22 acpi-cpufreq: Move average performance code and make it available to userspace and several cleanups in this area Thomas Renninger
2009-04-17 14:22 ` [PATCH 1/8] Fix for a regression that was introduced by earlier commit Thomas Renninger
2009-04-18  5:30   ` Len Brown
2009-04-17 14:22 ` [PATCH 2/8] acpi-cpufreq: Cleanup: Use printk_once Thomas Renninger
2009-04-18  5:31   ` Len Brown
2009-04-17 14:22 ` [PATCH 3/8] acpi-cpufreq: First multiply then divide to avoid zero results Thomas Renninger
2009-04-17 17:10   ` Pallipadi, Venkatesh
2009-04-18  5:37     ` Len Brown
2009-04-17 14:22 ` [PATCH 4/8] acpi-cpufreq: Do not let get_measured perf depend on internal variable Thomas Renninger
2009-04-17 17:24   ` Pallipadi, Venkatesh
2009-04-18  9:49     ` Thomas Renninger
2009-04-17 14:22 ` [PATCH 5/8] acpi-cpufreq: Move average performance funtions into separate file and KConfig Thomas Renninger
2009-04-17 17:32   ` Pallipadi, Venkatesh
2009-04-20 11:41     ` Thomas Renninger
2009-04-20 17:04       ` Pallipadi, Venkatesh
2009-04-17 14:22 ` Thomas Renninger [this message]
2009-04-17 14:22 ` [PATCH 7/8] acpi-cpufreq: Use already defined IDA feature flag instead of checking cpuid Thomas Renninger
2009-04-17 17:35   ` Pallipadi, Venkatesh
2009-04-17 14:22 ` [PATCH 8/8] CPUFREQ: Add documentation for new average_freq cpufreq_stats sysfs file Thomas Renninger

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=1239978132-6261-7-git-send-email-trenn@suse.de \
    --to=trenn@suse.de \
    --cc=cpufreq@vger.kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=venkatesh.pallipadi@intel.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox