public inbox for powertop@lists.linux.dev
 help / color / mirror / Atom feed
From: Cheng, Michael <michael.cheng at intel.com>
To: powertop@lists.01.org
Subject: [Powertop] [PATCH] Add more descriptive column headers for Idle Stats Tab
Date: Fri, 20 Apr 2018 11:45:08 -0700	[thread overview]
Message-ID: <20180420184508.13552-1-michael.cheng@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 4405 bytes --]

From: Michael Cheng <michael.cheng(a)intel.com>

This patch introduces a more descriptive column headers to show where
Powertop gets these values from (OS versus model specific registers).

Signed-off-by: Michael Cheng <michael.cheng(a)intel.com>
---
 src/cpu/cpu.cpp         | 25 +++++++++++++++++++------
 src/cpu/cpu.h           |  3 ++-
 src/cpu/cpu_core.cpp    |  6 ++----
 src/cpu/cpu_linux.cpp   |  2 +-
 src/cpu/cpu_package.cpp |  3 +--
 5 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index f3711f5..f6bae03 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -68,11 +68,15 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int
 	char packagename[128];
 	if (strcmp(vendor, "GenuineIntel") == 0)
 		if (family == 6)
-			if (is_supported_intel_cpu(model))
+			if (is_supported_intel_cpu(model)) {
 				ret = new class nhm_package(model);
+				ret->set_intel_MSR(true);
+			}
 
-	if (!ret)
+	if (!ret) {
 		ret = new class cpu_package;
+		ret->set_intel_MSR(false);
+	}
 
 	ret->set_number(package, cpu);
 	ret->set_type("Package");
@@ -105,11 +109,16 @@ static class abstract_cpu * new_core(int core, int cpu, char * vendor, int famil
 
 	if (strcmp(vendor, "GenuineIntel") == 0)
 		if (family == 6)
-			if (is_supported_intel_cpu(model))
+			if (is_supported_intel_cpu(model)) {
 				ret = new class nhm_core(model);
+				ret->set_intel_MSR(true);
+			}
 
-	if (!ret)
+	if (!ret) {
 		ret = new class cpu_core;
+		ret->set_intel_MSR(false);
+	}
+
 	ret->set_number(core, cpu);
 	ret->childcount = 0;
 	ret->set_type("Core");
@@ -134,11 +143,15 @@ static class abstract_cpu * new_cpu(int number, char * vendor, int family, int m
 
 	if (strcmp(vendor, "GenuineIntel") == 0)
 		if (family == 6)
-			if (is_supported_intel_cpu(model))
+			if (is_supported_intel_cpu(model)) {
 				ret = new class nhm_cpu;
+				ret->set_intel_MSR(true);
+			}
 
-	if (!ret)
+	if (!ret) {
 		ret = new class cpu_linux;
+		ret->set_intel_MSR(false);
+	}
 	ret->set_number(number, number);
 	ret->set_type("CPU");
 	ret->childcount = 0;
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index 6b4aed8..9b04018 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -93,7 +93,7 @@ public:
 	int	number;
 	int	childcount;
 	const char*    name;
-	bool	idle, old_idle;
+	bool	idle, old_idle, has_intel_MSR;
 	uint64_t	current_frequency;
 	uint64_t	effective_frequency;
 
@@ -108,6 +108,7 @@ public:
 
 	int	get_first_cpu() { return first_cpu; }
 	void	set_number(int _number, int cpu) {this->number = _number; this->first_cpu = cpu;};
+	void	set_intel_MSR(bool _bool_value) {this->has_intel_MSR =  _bool_value;};
 	void	set_type(const char* _name) {this->name = _name;};
 	int	get_number(void) { return number; };
 	const char* get_type(void) { return name; };
diff --git a/src/cpu/cpu_core.cpp b/src/cpu/cpu_core.cpp
index 65c2718..e1372f7 100644
--- a/src/cpu/cpu_core.cpp
+++ b/src/cpu/cpu_core.cpp
@@ -33,10 +33,8 @@ char * cpu_core::fill_cstate_line(int line_nr, char *buffer, const char *separat
 	unsigned int i;
 	buffer[0] = 0;
 
-	if (line_nr == LEVEL_HEADER) {
-		sprintf(buffer,_("  Core"));
-		return buffer;
-	}
+	if (line_nr == LEVEL_HEADER)
+		sprintf(buffer, this->has_intel_MSR ? _(" Core(HW)"): _(" Core(OS)"));
 
 	for (i = 0; i < cstates.size(); i++) {
 		if (cstates[i]->line_level != line_nr)
diff --git a/src/cpu/cpu_linux.cpp b/src/cpu/cpu_linux.cpp
index 2e8dba3..d7ce93d 100644
--- a/src/cpu/cpu_linux.cpp
+++ b/src/cpu/cpu_linux.cpp
@@ -239,7 +239,7 @@ char * cpu_linux::fill_cstate_line(int line_nr, char *buffer, const char *separa
 	buffer[0] = 0;
 
 	if (line_nr == LEVEL_HEADER) {
-		sprintf(buffer,_(" CPU %i"), number);
+		sprintf(buffer,_(" CPU(OS) %i"), number);
 		return buffer;
 	}
 
diff --git a/src/cpu/cpu_package.cpp b/src/cpu/cpu_package.cpp
index c264e54..926a484 100644
--- a/src/cpu/cpu_package.cpp
+++ b/src/cpu/cpu_package.cpp
@@ -44,8 +44,7 @@ char * cpu_package::fill_cstate_line(int line_nr, char *buffer, const char *sepa
 	buffer[0] = 0;
 
 	if (line_nr == LEVEL_HEADER) {
-		sprintf(buffer,_("Package"));
-		return buffer;
+		sprintf(buffer, this->has_intel_MSR ? _(" Pkg(HW)"): _(" Pkg(OS)"));
 	}
 
 	for (i = 0; i < cstates.size(); i++) {
-- 
2.14.1


                 reply	other threads:[~2018-04-20 18:45 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=20180420184508.13552-1-michael.cheng@intel.com \
    --to=powertop@lists.01.org \
    /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