cpufreq.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] cpupower enhancements for 3.7
@ 2012-10-09 13:20 Thomas Renninger
  2012-10-09 13:21 ` [PATCH 1/8] cpupower tools: Remove brace expansion from clean target Thomas Renninger
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:20 UTC (permalink / raw)
  To: cpufreq; +Cc: Thomas Renninger, linux, rjw

Hope it's not too late already...

Palmer Cox (6):
  cpupower tools: Remove brace expansion from clean target
  cpupower tools: Update .gitignore for files created in the debug
    directories
  cpupower tools: Fix minor warnings
  cpupower tools: Fix issues with sysfs_topology_read_file
  cpupower tools: Fix malloc of cpu_info structure
  cpupower tools: Fix warning and a bug with the cpu package count

Thomas Renninger (2):
  cpupower: Provide -c param for cpupower monitor to schedule process
    on all cores
  patch cpupower_ivy_bridge_support.patch

 tools/power/cpupower/.gitignore                    |    7 +++
 tools/power/cpupower/Makefile                      |    3 +-
 tools/power/cpupower/debug/i386/Makefile           |    5 ++-
 tools/power/cpupower/man/cpupower-monitor.1        |   15 +++++-
 tools/power/cpupower/utils/helpers/helpers.h       |   18 ++++---
 tools/power/cpupower/utils/helpers/sysfs.c         |   19 -------
 tools/power/cpupower/utils/helpers/topology.c      |   53 +++++++++++---------
 .../cpupower/utils/idle_monitor/cpupower-monitor.c |   21 +++++++-
 .../cpupower/utils/idle_monitor/cpupower-monitor.h |   17 ++++++
 tools/power/cpupower/utils/idle_monitor/snb_idle.c |   10 +++-
 10 files changed, 108 insertions(+), 60 deletions(-)

-- 
1.7.6.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/8] cpupower tools: Remove brace expansion from clean target
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-10-09 13:21 ` [PATCH 2/8] cpupower tools: Update .gitignore for files created in the debug directories Thomas Renninger
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Palmer Cox, linux, rjw, Thomas Renninger

From: Palmer Cox <p@lmercox.com>

The clean targets from the cpupower tools' Makefiles use brace expansion to
remove some generated files. However, the default shells on many systems do
not support this feature resulting in some generated files not being removed
by clean.

Signed-off-by: Palmer Cox <p@lmercox.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 tools/power/cpupower/Makefile            |    3 ++-
 tools/power/cpupower/debug/i386/Makefile |    5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index a93e06c..44b7a06 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -253,7 +253,8 @@ clean:
 	 | xargs rm -f
 	-rm -f $(OUTPUT)cpupower
 	-rm -f $(OUTPUT)libcpupower.so*
-	-rm -rf $(OUTPUT)po/*.{gmo,pot}
+	-rm -rf $(OUTPUT)po/*.gmo
+	-rm -rf $(OUTPUT)po/*.pot
 	$(MAKE) -C bench O=$(OUTPUT) clean
 
 
diff --git a/tools/power/cpupower/debug/i386/Makefile b/tools/power/cpupower/debug/i386/Makefile
index 3ba158f..c05cc0a 100644
--- a/tools/power/cpupower/debug/i386/Makefile
+++ b/tools/power/cpupower/debug/i386/Makefile
@@ -26,7 +26,10 @@ $(OUTPUT)powernow-k8-decode: powernow-k8-decode.c
 all: $(OUTPUT)centrino-decode $(OUTPUT)dump_psb $(OUTPUT)intel_gsic $(OUTPUT)powernow-k8-decode
 
 clean:
-	rm -rf $(OUTPUT){centrino-decode,dump_psb,intel_gsic,powernow-k8-decode}
+	rm -rf $(OUTPUT)centrino-decode
+	rm -rf $(OUTPUT)dump_psb
+	rm -rf $(OUTPUT)intel_gsic
+	rm -rf $(OUTPUT)powernow-k8-decode
 
 install:
 	$(INSTALL) -d $(DESTDIR)${bindir}
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/8] cpupower tools: Update .gitignore for files created in the debug directories
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
  2012-10-09 13:21 ` [PATCH 1/8] cpupower tools: Remove brace expansion from clean target Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-10-09 13:21 ` [PATCH 3/8] cpupower tools: Fix minor warnings Thomas Renninger
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Palmer Cox, linux, rjw, Thomas Renninger

From: Palmer Cox <p@lmercox.com>

The files generated by the Makefiles in the debug directories aren't listed
in the .gitignore file in the root of the cpupower tool which causes these
files to show up in the output of 'git status'.

Signed-off-by: Palmer Cox <p@lmercox.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 tools/power/cpupower/.gitignore |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/tools/power/cpupower/.gitignore b/tools/power/cpupower/.gitignore
index 8a83dd2..d42073f 100644
--- a/tools/power/cpupower/.gitignore
+++ b/tools/power/cpupower/.gitignore
@@ -20,3 +20,10 @@ utils/cpufreq-set.o
 utils/cpufreq-aperf.o
 cpupower
 bench/cpufreq-bench
+debug/kernel/Module.symvers
+debug/i386/centrino-decode
+debug/i386/dump_psb
+debug/i386/intel_gsic
+debug/i386/powernow-k8-decode
+debug/x86_64/centrino-decode
+debug/x86_64/powernow-k8-decode
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/8] cpupower tools: Fix minor warnings
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
  2012-10-09 13:21 ` [PATCH 1/8] cpupower tools: Remove brace expansion from clean target Thomas Renninger
  2012-10-09 13:21 ` [PATCH 2/8] cpupower tools: Update .gitignore for files created in the debug directories Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-10-09 13:21 ` [PATCH 4/8] cpupower tools: Fix issues with sysfs_topology_read_file Thomas Renninger
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Palmer Cox, linux, rjw, Thomas Renninger

From: Palmer Cox <p@lmercox.com>

Fix minor warnings reported with GCC 4.6:
* The sysfs_write_file function is unused - remove it.
* The pr_mon_len in the print_header function is unsed - remove it.

Signed-off-by: Palmer Cox <p@lmercox.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 tools/power/cpupower/utils/helpers/sysfs.c         |   19 -------------------
 .../cpupower/utils/idle_monitor/cpupower-monitor.c |    3 +--
 2 files changed, 1 insertions(+), 21 deletions(-)

diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c
index 96e28c1..38ab916 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.c
+++ b/tools/power/cpupower/utils/helpers/sysfs.c
@@ -37,25 +37,6 @@ unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen)
 	return (unsigned int) numread;
 }
 
-static unsigned int sysfs_write_file(const char *path,
-				     const char *value, size_t len)
-{
-	int fd;
-	ssize_t numwrite;
-
-	fd = open(path, O_WRONLY);
-	if (fd == -1)
-		return 0;
-
-	numwrite = write(fd, value, len);
-	if (numwrite < 1) {
-		close(fd);
-		return 0;
-	}
-	close(fd);
-	return (unsigned int) numwrite;
-}
-
 /*
  * Detect whether a CPU is online
  *
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
index 0d6571e..7a657f3 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -84,7 +84,7 @@ int fill_string_with_spaces(char *s, int n)
 void print_header(int topology_depth)
 {
 	int unsigned mon;
-	int state, need_len, pr_mon_len;
+	int state, need_len;
 	cstate_t s;
 	char buf[128] = "";
 	int percent_width = 4;
@@ -93,7 +93,6 @@ void print_header(int topology_depth)
 	printf("%s|", buf);
 
 	for (mon = 0; mon < avail_monitors; mon++) {
-		pr_mon_len = 0;
 		need_len = monitors[mon]->hw_states_num * (percent_width + 3)
 			- 1;
 		if (mon != 0) {
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/8] cpupower tools: Fix issues with sysfs_topology_read_file
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
                   ` (2 preceding siblings ...)
  2012-10-09 13:21 ` [PATCH 3/8] cpupower tools: Fix minor warnings Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-10-09 13:21 ` [PATCH 5/8] cpupower tools: Fix malloc of cpu_info structure Thomas Renninger
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Palmer Cox, linux, rjw, Thomas Renninger

From: Palmer Cox <p@lmercox.com>

Fix a variety of issues with sysfs_topology_read_file:
* The return value of sysfs_topology_read_file function was not properly
  being checked for failure.
* The function was reading int valued sysfs variables and then returning
  their value. So, even if a function was trying to check the return value
  of this function, a caller would not be able to tell an failure code apart
  from reading a negative value. This also conflicted with the comment on the
  function which said that a return value of 0 indicated success.
* The function was parsing int valued sysfs values with strtoul instead of
  strtol.
* The function was non-static even though it was only used in the
  file it was declared in.

Signed-off-by: Palmer Cox <p@lmercox.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 tools/power/cpupower/utils/helpers/topology.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c
index 4eae2c4..216f3e3 100644
--- a/tools/power/cpupower/utils/helpers/topology.c
+++ b/tools/power/cpupower/utils/helpers/topology.c
@@ -20,9 +20,8 @@
 #include <helpers/sysfs.h>
 
 /* returns -1 on failure, 0 on success */
-int sysfs_topology_read_file(unsigned int cpu, const char *fname)
+static int sysfs_topology_read_file(unsigned int cpu, const char *fname, int *result)
 {
-	unsigned long value;
 	char linebuf[MAX_LINE_LEN];
 	char *endp;
 	char path[SYSFS_PATH_MAX];
@@ -31,10 +30,10 @@ int sysfs_topology_read_file(unsigned int cpu, const char *fname)
 			 cpu, fname);
 	if (sysfs_read_file(path, linebuf, MAX_LINE_LEN) == 0)
 		return -1;
-	value = strtoul(linebuf, &endp, 0);
+	*result = strtol(linebuf, &endp, 0);
 	if (endp == linebuf || errno == ERANGE)
 		return -1;
-	return value;
+	return 0;
 }
 
 struct cpuid_core_info {
@@ -82,13 +81,19 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
 	for (cpu = 0; cpu < cpus; cpu++) {
 		cpu_top->core_info[cpu].cpu = cpu;
 		cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu);
-		cpu_top->core_info[cpu].pkg =
-			sysfs_topology_read_file(cpu, "physical_package_id");
+		if(sysfs_topology_read_file(
+			cpu,
+			"physical_package_id",
+			&(cpu_top->core_info[cpu].pkg)) < 0)
+			return -1;
 		if ((int)cpu_top->core_info[cpu].pkg != -1 &&
 		    cpu_top->core_info[cpu].pkg > cpu_top->pkgs)
 			cpu_top->pkgs = cpu_top->core_info[cpu].pkg;
-		cpu_top->core_info[cpu].core =
-			sysfs_topology_read_file(cpu, "core_id");
+		if(sysfs_topology_read_file(
+			cpu,
+			"core_id",
+			&(cpu_top->core_info[cpu].core)) < 0)
+			return -1;
 	}
 	cpu_top->pkgs++;
 
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/8] cpupower tools: Fix malloc of cpu_info structure
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
                   ` (3 preceding siblings ...)
  2012-10-09 13:21 ` [PATCH 4/8] cpupower tools: Fix issues with sysfs_topology_read_file Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-10-09 13:21 ` [PATCH 6/8] cpupower tools: Fix warning and a bug with the cpu package count Thomas Renninger
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Palmer Cox, linux, rjw, Thomas Renninger

From: Palmer Cox <p@lmercox.com>

The cpu_info member of cpupower_topology was being declared as an unnamed
structure. This member was then being malloced using the size of the
parent cpupower_topology * the number of cpus. This works
because cpu_info is smaller than cpupower_topology. However, there is
no guarantee that will always be the case. Making cpu_info its own
top level structure (named cpuid_core_info) allows for mallocing the actual
size of this structure. This also lets us get rid of a redefinition of
the structure in topology.c with slightly different field names.

Signed-off-by: Palmer Cox <p@lmercox.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 tools/power/cpupower/utils/helpers/helpers.h  |   17 +++++++++--------
 tools/power/cpupower/utils/helpers/topology.c |   14 +++-----------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index 2eb584c..f84985f 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -92,6 +92,14 @@ extern int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info);
 extern struct cpupower_cpu_info cpupower_cpu_info;
 /* cpuid and cpuinfo helpers  **************************/
 
+struct cpuid_core_info {
+	int pkg;
+	int core;
+	int cpu;
+
+	/* flags */
+	unsigned int is_online:1;
+};
 
 /* CPU topology/hierarchy parsing ******************/
 struct cpupower_topology {
@@ -101,14 +109,7 @@ struct cpupower_topology {
 	unsigned int threads; /* per core */
 
 	/* Array gets mallocated with cores entries, holding per core info */
-	struct {
-		int pkg;
-		int core;
-		int cpu;
-
-		/* flags */
-		unsigned int is_online:1;
-	} *core_info;
+	struct cpuid_core_info *core_info;
 };
 
 extern int get_cpu_topology(struct cpupower_topology *cpu_top);
diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c
index 216f3e3..4e2b583 100644
--- a/tools/power/cpupower/utils/helpers/topology.c
+++ b/tools/power/cpupower/utils/helpers/topology.c
@@ -36,14 +36,6 @@ static int sysfs_topology_read_file(unsigned int cpu, const char *fname, int *re
 	return 0;
 }
 
-struct cpuid_core_info {
-	unsigned int pkg;
-	unsigned int thread;
-	unsigned int cpu;
-	/* flags */
-	unsigned int is_online:1;
-};
-
 static int __compare(const void *t1, const void *t2)
 {
 	struct cpuid_core_info *top1 = (struct cpuid_core_info *)t1;
@@ -52,9 +44,9 @@ static int __compare(const void *t1, const void *t2)
 		return -1;
 	else if (top1->pkg > top2->pkg)
 		return 1;
-	else if (top1->thread < top2->thread)
+	else if (top1->core < top2->core)
 		return -1;
-	else if (top1->thread > top2->thread)
+	else if (top1->core > top2->core)
 		return 1;
 	else if (top1->cpu < top2->cpu)
 		return -1;
@@ -74,7 +66,7 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
 {
 	int cpu, cpus = sysconf(_SC_NPROCESSORS_CONF);
 
-	cpu_top->core_info = malloc(sizeof(struct cpupower_topology) * cpus);
+	cpu_top->core_info = malloc(sizeof(struct cpuid_core_info) * cpus);
 	if (cpu_top->core_info == NULL)
 		return -ENOMEM;
 	cpu_top->pkgs = cpu_top->cores = 0;
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/8] cpupower tools: Fix warning and a bug with the cpu package count
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
                   ` (4 preceding siblings ...)
  2012-10-09 13:21 ` [PATCH 5/8] cpupower tools: Fix malloc of cpu_info structure Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-10-09 13:21 ` [PATCH 7/8] cpupower: Provide -c param for cpupower monitor to schedule process on all cores Thomas Renninger
  2012-10-09 13:21 ` [PATCH 8/8] patch cpupower_ivy_bridge_support.patch Thomas Renninger
  7 siblings, 0 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Palmer Cox, linux, rjw, Thomas Renninger

From: Palmer Cox <p@lmercox.com>

The pkgs member of cpupower_topology is being used as the number of
cpu packages. As the comment in get_cpu_topology notes, the package ids
are not guaranteed to be contiguous. So, simply setting pkgs to the value
of the highest physical_package_id doesn't actually provide a count of
the number of cpu packages. Instead, calculate pkgs by setting it to
the number of distinct physical_packge_id values which is pretty easy
to do after the core_info structs are sorted. Calculating pkgs this
way also has the nice benefit of getting rid of a sign comparison warning
that GCC 4.6 was reporting.

Signed-off-by: Palmer Cox <p@lmercox.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 tools/power/cpupower/utils/helpers/topology.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c
index 4e2b583..c13120a 100644
--- a/tools/power/cpupower/utils/helpers/topology.c
+++ b/tools/power/cpupower/utils/helpers/topology.c
@@ -64,7 +64,7 @@ static int __compare(const void *t1, const void *t2)
  */
 int get_cpu_topology(struct cpupower_topology *cpu_top)
 {
-	int cpu, cpus = sysconf(_SC_NPROCESSORS_CONF);
+	int cpu, last_pkg, cpus = sysconf(_SC_NPROCESSORS_CONF);
 
 	cpu_top->core_info = malloc(sizeof(struct cpuid_core_info) * cpus);
 	if (cpu_top->core_info == NULL)
@@ -78,20 +78,28 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
 			"physical_package_id",
 			&(cpu_top->core_info[cpu].pkg)) < 0)
 			return -1;
-		if ((int)cpu_top->core_info[cpu].pkg != -1 &&
-		    cpu_top->core_info[cpu].pkg > cpu_top->pkgs)
-			cpu_top->pkgs = cpu_top->core_info[cpu].pkg;
 		if(sysfs_topology_read_file(
 			cpu,
 			"core_id",
 			&(cpu_top->core_info[cpu].core)) < 0)
 			return -1;
 	}
-	cpu_top->pkgs++;
 
 	qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
 	      __compare);
 
+	/* Count the number of distinct pkgs values. This works
+	   because the primary sort of the core_info struct was just
+	   done by pkg value. */
+	last_pkg = cpu_top->core_info[0].pkg;
+	for(cpu = 1; cpu < cpus; cpu++) {
+		if(cpu_top->core_info[cpu].pkg != last_pkg) {
+			last_pkg = cpu_top->core_info[cpu].pkg;
+			cpu_top->pkgs++;
+		}
+	}
+	cpu_top->pkgs++;
+
 	/* Intel's cores count is not consecutively numbered, there may
 	 * be a core_id of 3, but none of 2. Assume there always is 0
 	 * Get amount of cores by counting duplicates in a package
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/8] cpupower: Provide -c param for cpupower monitor to schedule process on all cores
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
                   ` (5 preceding siblings ...)
  2012-10-09 13:21 ` [PATCH 6/8] cpupower tools: Fix warning and a bug with the cpu package count Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-10-09 13:21 ` [PATCH 8/8] patch cpupower_ivy_bridge_support.patch Thomas Renninger
  7 siblings, 0 replies; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Thomas Renninger, linux, rjw

If an MSR based monitor is run in parallel this is not needed. This is the
default case on all/most Intel machines.

But when only sysfs info is read via cpupower monitor -m Idle_Stats (typically
the case for non root users) or when other monitors are PCI based (AMD),
Idle_Stats, read from sysfs can be totally bogus:

cpupower monitor -m Idle_Stats
PKG |CORE|CPU | POLL | C1-N | C3-N | C6-N
   0|   0|   0|  0.00|  0.00|  0.24| 99.81
   0|   0|  32|  0.00|  0.00|  0.00| 100.7
...
   0|  17|  20|  0.00|  0.00|  0.00| 173.1
   0|  17|  52|  0.00|  0.00|  0.07| 173.0
   0|  18|  68|  0.00|  0.00|  0.00|  0.00
   0|  18|  76|  0.00|  0.00|  0.00|  0.00
...


With the -c option all cores are woken up and the kernel
did update cpuidle statistics before reading out sysfs.
This causes some overhead. Therefore avoid if possible, use
if needed:

cpupower monitor -c -m Idle_Stats
PKG |CORE|CPU | POLL | C1-N | C3-N | C6-N
   0|   0|   0|  0.00|  0.00|  0.00| 100.2
   0|   0|  32|  0.00|  0.00|  0.00| 100.2
...
   0|   8|   8|  0.00|  0.00|  0.00| 99.82
   0|   8|  40|  0.00|  0.00|  0.00| 99.81
   0|   9|  24|  0.00|  0.00|  0.00| 100.3
   0|   9|  56|  0.00|  0.00|  0.00| 100.2
   0|  16|   4|  0.00|  0.00|  0.00| 99.75
   0|  16|  36|  0.00|  0.00|  0.00| 99.38
...

Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 tools/power/cpupower/man/cpupower-monitor.1        |   15 +++++++++++++--
 tools/power/cpupower/utils/helpers/helpers.h       |    1 +
 .../cpupower/utils/idle_monitor/cpupower-monitor.c |   18 +++++++++++++++++-
 .../cpupower/utils/idle_monitor/cpupower-monitor.h |   17 +++++++++++++++++
 4 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/tools/power/cpupower/man/cpupower-monitor.1 b/tools/power/cpupower/man/cpupower-monitor.1
index 1141c20..e01c35d 100644
--- a/tools/power/cpupower/man/cpupower-monitor.1
+++ b/tools/power/cpupower/man/cpupower-monitor.1
@@ -7,11 +7,11 @@ cpupower\-monitor \- Report processor frequency and idle statistics
 .RB "\-l"
 
 .B cpupower monitor
-.RB [ "\-m <mon1>," [ "<mon2>,..." ] ]
+.RB [ -c ] [ "\-m <mon1>," [ "<mon2>,..." ] ]
 .RB [ "\-i seconds" ]
 .br
 .B cpupower monitor
-.RB [ "\-m <mon1>," [ "<mon2>,..." ] ]
+.RB [ -c ][ "\-m <mon1>," [ "<mon2>,..." ] ]
 .RB command
 .br
 .SH DESCRIPTION
@@ -64,6 +64,17 @@ Only display specific monitors. Use the monitor string(s) provided by \-l option
 Measure intervall.
 .RE
 .PP
+\-c
+.RS 4
+Schedule the process on every core before starting and ending measuring.
+This could be needed for the Idle_Stats monitor when no other MSR based
+monitor (has to be run on the core that is measured) is run in parallel.
+This is to wake up the processors from deeper sleep states and let the
+kernel re
+-account its cpuidle (C-state) information before reading the
+cpuidle timings from sysfs.
+.RE
+.PP
 command
 .RS 4
 Measure idle and frequency characteristics of an arbitrary command/workload.
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index f84985f..aa9e954 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -114,6 +114,7 @@ struct cpupower_topology {
 
 extern int get_cpu_topology(struct cpupower_topology *cpu_top);
 extern void cpu_topology_release(struct cpupower_topology cpu_top);
+
 /* CPU topology/hierarchy parsing ******************/
 
 /* X86 ONLY ****************************************/
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
index 7a657f3..c4bae92 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -39,6 +39,7 @@ static int mode;
 static int interval = 1;
 static char *show_monitors_param;
 static struct cpupower_topology cpu_top;
+static unsigned int wake_cpus;
 
 /* ToDo: Document this in the manpage */
 static char range_abbr[RANGE_MAX] = { 'T', 'C', 'P', 'M', };
@@ -314,16 +315,28 @@ int fork_it(char **argv)
 int do_interval_measure(int i)
 {
 	unsigned int num;
+	int cpu;
+
+	if (wake_cpus)
+		for (cpu = 0; cpu < cpu_count; cpu++)
+			bind_cpu(cpu);
 
 	for (num = 0; num < avail_monitors; num++) {
 		dprint("HW C-state residency monitor: %s - States: %d\n",
 		       monitors[num]->name, monitors[num]->hw_states_num);
 		monitors[num]->start();
 	}
+
 	sleep(i);
+
+	if (wake_cpus)
+		for (cpu = 0; cpu < cpu_count; cpu++)
+			bind_cpu(cpu);
+
 	for (num = 0; num < avail_monitors; num++)
 		monitors[num]->stop();
 
+
 	return 0;
 }
 
@@ -332,7 +345,7 @@ static void cmdline(int argc, char *argv[])
 	int opt;
 	progname = basename(argv[0]);
 
-	while ((opt = getopt(argc, argv, "+li:m:")) != -1) {
+	while ((opt = getopt(argc, argv, "+lci:m:")) != -1) {
 		switch (opt) {
 		case 'l':
 			if (mode)
@@ -351,6 +364,9 @@ static void cmdline(int argc, char *argv[])
 			mode = show;
 			show_monitors_param = optarg;
 			break;
+		case 'c':
+			wake_cpus = 1;
+			break;
 		default:
 			print_wrong_arg_exit();
 		}
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
index 9312ee1..9e43f33 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
@@ -65,4 +65,21 @@ extern long long timespec_diff_us(struct timespec start, struct timespec end);
 				"could be inaccurate\n"), mes, ov);		\
 }
 
+
+/* Taken over from x86info project sources  -> return 0 on success */
+#include <sched.h>
+#include <sys/types.h>
+#include <unistd.h>
+static inline int bind_cpu(int cpu)
+{
+	cpu_set_t set;
+
+	if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) {
+		CPU_ZERO(&set);
+		CPU_SET(cpu, &set);
+		return sched_setaffinity(getpid(), sizeof(set), &set);
+	}
+	return 1;
+}
+
 #endif /* __CPUIDLE_INFO_HW__ */
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/8] patch cpupower_ivy_bridge_support.patch
  2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
                   ` (6 preceding siblings ...)
  2012-10-09 13:21 ` [PATCH 7/8] cpupower: Provide -c param for cpupower monitor to schedule process on all cores Thomas Renninger
@ 2012-10-09 13:21 ` Thomas Renninger
  2012-11-24  9:49   ` Rafael J. Wysocki
  7 siblings, 1 reply; 12+ messages in thread
From: Thomas Renninger @ 2012-10-09 13:21 UTC (permalink / raw)
  To: cpufreq; +Cc: Thomas Renninger, linux, rjw

---
 tools/power/cpupower/utils/idle_monitor/snb_idle.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/power/cpupower/utils/idle_monitor/snb_idle.c b/tools/power/cpupower/utils/idle_monitor/snb_idle.c
index a1bc07c..9913a60 100644
--- a/tools/power/cpupower/utils/idle_monitor/snb_idle.c
+++ b/tools/power/cpupower/utils/idle_monitor/snb_idle.c
@@ -150,9 +150,15 @@ static struct cpuidle_monitor *snb_register(void)
 	    || cpupower_cpu_info.family != 6)
 		return NULL;
 
-	if (cpupower_cpu_info.model != 0x2A
-	    && cpupower_cpu_info.model != 0x2D)
+	switch (cpupower_cpu_info.model) {
+	case 0x2A: /* SNB */
+	case 0x2D: /* SNB Xeon */
+	case 0x3A: /* IVB */
+	case 0x3D: /* IVB Xeon */
+		break;
+	default:
 		return NULL;
+	}
 
 	is_valid = calloc(cpu_count, sizeof(int));
 	for (num = 0; num < SNB_CSTATE_COUNT; num++) {
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 8/8] patch cpupower_ivy_bridge_support.patch
  2012-10-09 13:21 ` [PATCH 8/8] patch cpupower_ivy_bridge_support.patch Thomas Renninger
@ 2012-11-24  9:49   ` Rafael J. Wysocki
  2012-11-26 15:46     ` Thomas Renninger
  0 siblings, 1 reply; 12+ messages in thread
From: Rafael J. Wysocki @ 2012-11-24  9:49 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: cpufreq, linux

Please add (1) a useful subject, (2) a changelog and (3) a sign-off tag.

Thanks,
Rafael


On Tuesday, October 09, 2012 03:21:07 PM Thomas Renninger wrote:
> ---
>  tools/power/cpupower/utils/idle_monitor/snb_idle.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/power/cpupower/utils/idle_monitor/snb_idle.c b/tools/power/cpupower/utils/idle_monitor/snb_idle.c
> index a1bc07c..9913a60 100644
> --- a/tools/power/cpupower/utils/idle_monitor/snb_idle.c
> +++ b/tools/power/cpupower/utils/idle_monitor/snb_idle.c
> @@ -150,9 +150,15 @@ static struct cpuidle_monitor *snb_register(void)
>  	    || cpupower_cpu_info.family != 6)
>  		return NULL;
>  
> -	if (cpupower_cpu_info.model != 0x2A
> -	    && cpupower_cpu_info.model != 0x2D)
> +	switch (cpupower_cpu_info.model) {
> +	case 0x2A: /* SNB */
> +	case 0x2D: /* SNB Xeon */
> +	case 0x3A: /* IVB */
> +	case 0x3D: /* IVB Xeon */
> +		break;
> +	default:
>  		return NULL;
> +	}
>  
>  	is_valid = calloc(cpu_count, sizeof(int));
>  	for (num = 0; num < SNB_CSTATE_COUNT; num++) {
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 8/8] patch cpupower_ivy_bridge_support.patch
  2012-11-24  9:49   ` Rafael J. Wysocki
@ 2012-11-26 15:46     ` Thomas Renninger
  2012-11-26 20:49       ` Rafael J. Wysocki
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Renninger @ 2012-11-26 15:46 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: cpufreq, linux

On Saturday, November 24, 2012 10:49:52 AM Rafael J. Wysocki wrote:
> Please add (1) a useful subject, (2) a changelog and (3) a sign-off tag.
Sure, sorry about that.
But be careful, this one is wrong:

> > +	case 0x2D: /* SNB Xeon */
> > +	case 0x3A: /* IVB */
> > +	case 0x3D: /* IVB Xeon */
It's family 0x3E
a copy and paste bug that has been taken over from
turbostat, there it already got adjusted from 0x3D to 0x3E.

I resend the whole series today or tomorrow.

Thanks,

  Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 8/8] patch cpupower_ivy_bridge_support.patch
  2012-11-26 15:46     ` Thomas Renninger
@ 2012-11-26 20:49       ` Rafael J. Wysocki
  0 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2012-11-26 20:49 UTC (permalink / raw)
  To: linux-pm; +Cc: Thomas Renninger, cpufreq, linux

On Monday, November 26, 2012 04:46:16 PM Thomas Renninger wrote:
> On Saturday, November 24, 2012 10:49:52 AM Rafael J. Wysocki wrote:
> > Please add (1) a useful subject, (2) a changelog and (3) a sign-off tag.
> Sure, sorry about that.
> But be careful, this one is wrong:
> 
> > > +	case 0x2D: /* SNB Xeon */
> > > +	case 0x3A: /* IVB */
> > > +	case 0x3D: /* IVB Xeon */
> It's family 0x3E
> a copy and paste bug that has been taken over from
> turbostat, there it already got adjusted from 0x3D to 0x3E.
> 
> I resend the whole series today or tomorrow.

OK

Should I drop the current one for now?

Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-11-26 20:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-09 13:20 [PATCH 0/8] cpupower enhancements for 3.7 Thomas Renninger
2012-10-09 13:21 ` [PATCH 1/8] cpupower tools: Remove brace expansion from clean target Thomas Renninger
2012-10-09 13:21 ` [PATCH 2/8] cpupower tools: Update .gitignore for files created in the debug directories Thomas Renninger
2012-10-09 13:21 ` [PATCH 3/8] cpupower tools: Fix minor warnings Thomas Renninger
2012-10-09 13:21 ` [PATCH 4/8] cpupower tools: Fix issues with sysfs_topology_read_file Thomas Renninger
2012-10-09 13:21 ` [PATCH 5/8] cpupower tools: Fix malloc of cpu_info structure Thomas Renninger
2012-10-09 13:21 ` [PATCH 6/8] cpupower tools: Fix warning and a bug with the cpu package count Thomas Renninger
2012-10-09 13:21 ` [PATCH 7/8] cpupower: Provide -c param for cpupower monitor to schedule process on all cores Thomas Renninger
2012-10-09 13:21 ` [PATCH 8/8] patch cpupower_ivy_bridge_support.patch Thomas Renninger
2012-11-24  9:49   ` Rafael J. Wysocki
2012-11-26 15:46     ` Thomas Renninger
2012-11-26 20:49       ` Rafael J. Wysocki

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).