[Powertop] [PATCH] Bug-fix: html & csv report core indexes

Alexandra Yates <alexandra.yates at linux.intel.com>
Newsgroups dev.linux.lists.powertop
Message-ID <1400716276-26453-2-git-send-email-alexandra.yates@linux.intel.com>
This patch allows the supported no Intel CPUs to be included on html &
CSV reports.  It fixes the rows index needed for package data.
Additionally, fixes the calculation of title indexes when cores are absent
from the CPU.  These changes are related to C-states and P-states
reports

Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/cpu/cpu.cpp |   30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 0a7c487..72d5726 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -466,7 +466,7 @@ void report_display_cpu_cstates(void)
 			continue;
 		/* Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
-		pkg_tbl_size.rows= cstates_num+1;
+		pkg_tbl_size.rows= ((cstates_num+1)-LEVEL_HEADER)+1;
 		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
@@ -608,12 +608,18 @@ void report_display_cpu_cstates(void)
 		}
 
 		/* Report Output */
-		title=title/core_num;
+		if(core_num > 0)
+			title=title/core_num;
+		else if( _core->children.size() > 0)
+			title=title/_core->children.size();
+
 		init_pkg_table_attr(&std_table_css, pkg_tbl_size.rows,  pkg_tbl_size.cols);
 		report.add_table(pkg_data, &std_table_css);
-		init_core_table_attr(&std_table_css, title+1, core_tbl_size.rows,
+		if (!_core->can_collapse()){
+			init_core_table_attr(&std_table_css, title+1, core_tbl_size.rows,
 				core_tbl_size.cols);
-		report.add_table(core_data, &std_table_css);
+			report.add_table(core_data, &std_table_css);
+		}
 		init_cpu_table_attr(&std_table_css, title+1, cpu_tbl_size.rows,
 				cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
@@ -625,7 +631,7 @@ void report_display_cpu_pstates(void)
 {
 	char buffer[512], buffer2[512], tmp_num[50];
 	unsigned int package, core, cpu;
-	int line;
+	int line, title=0;
 	class abstract_cpu *_package, * _core, * _cpu;
 	unsigned int i, pstates_num;
 	const char* core_type = NULL;
@@ -671,7 +677,7 @@ void report_display_cpu_pstates(void)
 
 		/*  Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
-		pkg_tbl_size.rows=pstates_num+2;
+		pkg_tbl_size.rows=((pstates_num+1)-LEVEL_HEADER)+2;
 		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
@@ -790,10 +796,16 @@ void report_display_cpu_pstates(void)
 		}
 		init_pkg_table_attr(&std_table_css, pkg_tbl_size.rows, pkg_tbl_size.cols);
 		report.add_table(pkg_data, &std_table_css);
-		init_core_table_attr(&std_table_css, (pstates_num+2),
+		if(!_core->can_collapse()){
+			title=pstates_num+2;
+			init_core_table_attr(&std_table_css, title,
 				core_tbl_size.rows, core_tbl_size.cols);
-		report.add_table(core_data, &std_table_css);
-		init_cpu_table_attr(&std_table_css, (pstates_num+2),
+			report.add_table(core_data, &std_table_css);
+		} else {
+			title=pstates_num+1;
+		}
+
+		init_cpu_table_attr(&std_table_css, title,
 				cpu_tbl_size.rows, cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
 	}
-- 
1.7.9.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.