From 9cd0ed3730dcf2d62185b1f446ccc9180a88ec02 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 30 2018 05:10:55 +0000 Subject: import powertop-2.9-1.el7 --- diff --git a/.gitignore b/.gitignore index 265af4d..3094c20 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/powertop-2.3.tar.gz +SOURCES/powertop-v2.9.tar.gz diff --git a/.powertop.metadata b/.powertop.metadata index ed72933..d7851c2 100644 --- a/.powertop.metadata +++ b/.powertop.metadata @@ -1 +1 @@ -0bb26b38a87f45cdb61acc8dc233e4391220c8b4 SOURCES/powertop-2.3.tar.gz +0b49a0fe9fd8a1026faf731a959146ed93d83153 SOURCES/powertop-v2.9.tar.gz diff --git a/SOURCES/powertop-2.3-always-create-params.patch b/SOURCES/powertop-2.3-always-create-params.patch deleted file mode 100644 index 044bb71..0000000 --- a/SOURCES/powertop-2.3-always-create-params.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/src/parameters/persistent.cpp b/src/parameters/persistent.cpp -index 483227b..5e4a5fd 100644 ---- a/src/parameters/persistent.cpp -+++ b/src/parameters/persistent.cpp -@@ -130,9 +130,6 @@ void save_parameters(const char *filename) - - // printf("result size is %i, #parameters is %i \n", (int)past_results.size(), (int)all_parameters.parameters.size()); - -- if (!global_power_valid()) -- return; -- - pathname = get_param_directory(filename); - - file.open(pathname, ios::out); -@@ -141,12 +138,15 @@ void save_parameters(const char *filename) - return; - } - -- map::iterator it; -+ if (global_power_valid()) -+ { -+ map::iterator it; - -- for (it = param_index.begin(); it != param_index.end(); it++) { -- int index; -- index = it->second; -- file << it->first << "\t" << setprecision(9) << all_parameters.parameters[index] << "\n"; -+ for (it = param_index.begin(); it != param_index.end(); it++) { -+ int index; -+ index = it->second; -+ file << it->first << "\t" << setprecision(9) << all_parameters.parameters[index] << "\n"; -+ } - } - file.close(); - } diff --git a/SOURCES/powertop-2.3-auto-tune.patch b/SOURCES/powertop-2.3-auto-tune.patch deleted file mode 100644 index 811f9f2..0000000 --- a/SOURCES/powertop-2.3-auto-tune.patch +++ /dev/null @@ -1,121 +0,0 @@ -diff --git a/doc/powertop.8 b/doc/powertop.8 -index 4a2f0b0..0f460ec 100644 ---- a/doc/powertop.8 -+++ b/doc/powertop.8 -@@ -14,7 +14,10 @@ experiment with various power management settings. When invoking powertop - without arguments powertop starts in interactive mode. - .SH OPTIONS - .TP --\fB\-\-calibrate -+.B \-\-auto\-tune -+Set all tunable options to their good setting without interaction. -+.TP -+.BR \-c ", " \-\-calibrate - runs powertop in calibration mode. When running on battery, powertop - can track power consumption as well as system activity. When there - are enough measurements, powertop can start to report power estimates. One -diff --git a/src/main.cpp b/src/main.cpp -index 16b1613..9da3167 100644 ---- a/src/main.cpp -+++ b/src/main.cpp -@@ -75,6 +75,7 @@ static const struct option long_options[] = - {"version", no_argument, NULL, 'V'}, - {"help",no_argument, NULL, 'u'}, /* u for usage */ - {"calibrate",no_argument, NULL, 'c'}, -+ {"auto-tune",no_argument, NULL, 'a'}, - {"html", optional_argument, NULL, 'h'}, - {"csv", optional_argument, NULL, 'C'}, - {"extech", optional_argument, NULL, 'e'}, -@@ -110,6 +111,7 @@ static void print_usage() - printf("--debug \t\t %s\n",_("run in \"debug\" mode")); - printf("--version \t\t %s\n",_("print version information")); - printf("--calibrate \t\t %s\n",_("runs powertop in calibration mode")); -+ printf("--auto-tune \t\t %s\n",_("Sets all tunable options to their GOOD setting")); - printf("--extech%s \t %s\n",_("[=devnode]"),_("uses an Extech Power Analyzer for measurements")); - printf("--html%s \t %s\n",_("[=FILENAME]"),_("generate a html report")); - printf("--csv%s \t %s\n",_("[=FILENAME]"),_("generate a csv report")); -@@ -362,7 +364,7 @@ int main(int argc, char **argv) - int c; - char filename[4096]; - char workload[4096] = {0,}; -- int iterations = 1; -+ int iterations = 1, auto_tune = 0; - - set_new_handler(out_of_memory); - -@@ -390,7 +392,10 @@ int main(int argc, char **argv) - print_usage(); - exit(0); - break; -- -+ case 'a': -+ auto_tune = 1; -+ leave_powertop = 1; -+ break; - case 'c': - powertop_init(); - calibrate(); -@@ -446,20 +451,27 @@ int main(int argc, char **argv) - end_pci_access(); - exit(0); - } -- -+ if (!auto_tune) -+ init_display(); -+ initialize_tuning(); - /* first one is short to not let the user wait too long */ -- init_display(); - one_measurement(1, NULL); -- initialize_tuning(); -- tuning_update_display(); -- show_tab(0); -+ -+ if (!auto_tune) { -+ tuning_update_display(); -+ show_tab(0); -+ } else { -+ auto_toggle_tuning(); -+ } - - while (!leave_powertop) { -- show_cur_tab(); -+ if (!auto_tune) -+ show_cur_tab(); - one_measurement(time_out, NULL); - learn_parameters(15, 0); - } -- endwin(); -+ if (!auto_tune) -+ endwin(); - printf("%s\n", _("Leaving PowerTOP")); - - end_process_data(); -diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp -index 08d8251..ff3d715 100644 ---- a/src/tuning/tuning.cpp -+++ b/src/tuning/tuning.cpp -@@ -273,3 +273,11 @@ void clear_tuning() - } - all_untunables.clear(); - } -+ -+void auto_toggle_tuning() -+{ -+ for (unsigned int i = 0; i < all_tunables.size(); i++) { -+ if (all_tunables[i]->good_bad() == TUNE_BAD) -+ all_tunables[i]->toggle(); -+ } -+} -diff --git a/src/tuning/tuning.h b/src/tuning/tuning.h -index 7c4921f..f70001b 100644 ---- a/src/tuning/tuning.h -+++ b/src/tuning/tuning.h -@@ -29,7 +29,5 @@ extern void initialize_tuning(void); - extern void tuning_update_display(void); - extern void report_show_tunables(void); - extern void clear_tuning(void); -- -- -- -+extern void auto_toggle_tuning(void); - #endif diff --git a/SOURCES/powertop-2.3-dump-option.patch b/SOURCES/powertop-2.3-dump-option.patch deleted file mode 100644 index eba2e5e..0000000 --- a/SOURCES/powertop-2.3-dump-option.patch +++ /dev/null @@ -1,617 +0,0 @@ -diff --git a/doc/powertop.8 b/doc/powertop.8 -index 0f460ec..9d225ca 100644 ---- a/doc/powertop.8 -+++ b/doc/powertop.8 -@@ -25,40 +25,44 @@ can get more accurate estimates by using this option to enable a - calibration cycle. This will cycle through various display levels and USB - device activities and workloads. - .TP --\fB\-\-csv[\fR=\fIFILENAME\fR] -+.BR \-C "[\fIFILENAME\fR], " \-\-csv [ =\fIFILENAME\fR] - generate a CSV report. If a filename is not specified then the --default name "powertop.csv" is used. The CSV report can be --used for reporting and data analysis. -+default name "powertop.csv" is used. If filename is "\fB\-\fR" then STDOUT is used. -+The CSV report can be used for reporting and data analysis. - .TP --\fB\-\-debug -+.BR \-d "[\fIFILENAME\fR], " \-\-dump [ =\fIFILENAME\fR] -+generate a plain text report. If a filename is not specified or it is "\fB\-\fR" then -+STDOUT is used. -+.TP -+\fB\-\-debug\fR - run in "debug" mode. - .TP --\fB\-\-extech\fR=\fIdevnode\fR -+.BI \-\-extech= devnode\fR - use the Extech Power Analyzer for measurements. This allows one to - specify the serial device node of the serial to USB adaptor connecting to - the Extech Power Analyzer, for example /dev/ttyUSB0. - .TP --\fB\-\-help -+\fB\-\-help\fR - show the help message. - .TP --\fB\-\-html[\fR=\fIFILENAME\fR] -+.BR \-r "[\fIFILENAME\fR], " \-\-html [ =\fIFILENAME\fR] - generate an HTML report. If a filename is not specified then the --default name "powertop.html" is used. The HTML report can be --sent to others to help diagnose power issues. -+default name "powertop.html" is used. If filename is "\fB\-\fR" then STDOUT is used. -+The HTML report can be sent to others to help diagnose power issues. - .TP --\fB\-\-iteration[\fR=\fIiterations\fR] -+.BR \-\-iteration [ =\fIiterations\fR] - number of times to run each test. - .TP --\fB\-\-workload[\fR=\fIworkload\fR] -+.BR \-\-workload [ =\fIworkload\fR] - file to execute for workload. - .TP --\fB\-\-quiet -+\fB\-\-quiet\fR - supress stderr output. - .TP --\fB\-\-time[\fR=\fIseconds\fR] -+.BR \-\-time [ =\fIseconds\fR] - generate a report for a specified number of seconds. - .TP --\fB\-\-version -+\fB\-\-version\fR - print version information and exit. - .SH BUGS - Send bug reports to -diff --git a/src/Makefile.am b/src/Makefile.am -index 398b8a7..5807a2d 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -31,6 +31,7 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par - report/report-formatter-base.cpp report/report-formatter-base.h \ - report/report-formatter-csv.cpp report/report-formatter-csv.h \ - report/report-formatter-html.cpp report/report-formatter-html.h \ -+ report/report-formatter-plain.cpp report/report-formatter-plain.h \ - main.cpp css.h powertop.css cpu/intel_gpu.cpp - - -diff --git a/src/Makefile.in b/src/Makefile.in -index fde9aed..591e675 100644 ---- a/src/Makefile.in -+++ b/src/Makefile.in -@@ -120,6 +120,7 @@ am_powertop_OBJECTS = parameters/powertop-persistent.$(OBJEXT) \ - report/powertop-report-formatter-base.$(OBJEXT) \ - report/powertop-report-formatter-csv.$(OBJEXT) \ - report/powertop-report-formatter-html.$(OBJEXT) \ -+ report/powertop-report-formatter-plain.$(OBJEXT) \ - powertop-main.$(OBJEXT) cpu/powertop-intel_gpu.$(OBJEXT) - nodist_powertop_OBJECTS = - powertop_OBJECTS = $(am_powertop_OBJECTS) $(nodist_powertop_OBJECTS) -@@ -357,6 +358,7 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par - report/report-formatter-base.cpp report/report-formatter-base.h \ - report/report-formatter-csv.cpp report/report-formatter-csv.h \ - report/report-formatter-html.cpp report/report-formatter-html.h \ -+ report/report-formatter-plain.cpp report/report-formatter-plain.h \ - main.cpp css.h powertop.css cpu/intel_gpu.cpp - - powertop_CXXFLAGS = -fno-omit-frame-pointer -fstack-protector -Wall -Wshadow -Wformat $(NCURSES_CFLAGS) $(PCIUTILS_CFLAGS) $(LIBNL_CFLAGS) $(GLIB2_CFLAGS) -@@ -604,6 +606,8 @@ report/powertop-report-formatter-csv.$(OBJEXT): \ - report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp) - report/powertop-report-formatter-html.$(OBJEXT): \ - report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp) -+report/powertop-report-formatter-plain.$(OBJEXT): \ -+ report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp) - cpu/powertop-intel_gpu.$(OBJEXT): cpu/$(am__dirstamp) \ - cpu/$(DEPDIR)/$(am__dirstamp) - powertop$(EXEEXT): $(powertop_OBJECTS) $(powertop_DEPENDENCIES) $(EXTRA_powertop_DEPENDENCIES) -@@ -652,6 +656,7 @@ mostlyclean-compile: - -rm -f report/powertop-report-formatter-base.$(OBJEXT) - -rm -f report/powertop-report-formatter-csv.$(OBJEXT) - -rm -f report/powertop-report-formatter-html.$(OBJEXT) -+ -rm -f report/powertop-report-formatter-plain.$(OBJEXT) - -rm -f report/powertop-report-maker.$(OBJEXT) - -rm -f report/powertop-report.$(OBJEXT) - -rm -f tuning/powertop-bluetooth.$(OBJEXT) -@@ -712,6 +717,7 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-base.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-csv.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-html.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-plain.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-maker.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@tuning/$(DEPDIR)/powertop-bluetooth.Po@am__quote@ -@@ -1529,6 +1535,20 @@ report/powertop-report-formatter-html.obj: report/report-formatter-html.cpp - @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-html.obj `if test -f 'report/report-formatter-html.cpp'; then $(CYGPATH_W) 'report/report-formatter-html.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-html.cpp'; fi` - -+report/powertop-report-formatter-plain.o: report/report-formatter-plain.cpp -+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-plain.o -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-plain.Tpo -c -o report/powertop-report-formatter-plain.o `test -f 'report/report-formatter-plain.cpp' || echo '$(srcdir)/'`report/report-formatter-plain.cpp -+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-plain.Tpo report/$(DEPDIR)/powertop-report-formatter-plain.Po -+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='report/report-formatter-plain.cpp' object='report/powertop-report-formatter-plain.o' libtool=no @AMDEPBACKSLASH@ -+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-plain.o `test -f 'report/report-formatter-plain.cpp' || echo '$(srcdir)/'`report/report-formatter-plain.cpp -+ -+report/powertop-report-formatter-plain.obj: report/report-formatter-plain.cpp -+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-plain.obj -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-plain.Tpo -c -o report/powertop-report-formatter-plain.obj `if test -f 'report/report-formatter-plain.cpp'; then $(CYGPATH_W) 'report/report-formatter-plain.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-plain.cpp'; fi` -+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-plain.Tpo report/$(DEPDIR)/powertop-report-formatter-plain.Po -+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='report/report-formatter-palin.cpp' object='report/powertop-report-formatter-plain.obj' libtool=no @AMDEPBACKSLASH@ -+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-plain.obj `if test -f 'report/report-formatter-plain.cpp'; then $(CYGPATH_W) 'report/report-formatter-plain.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-plain.cpp'; fi` -+ - powertop-main.o: main.cpp - @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT powertop-main.o -MD -MP -MF $(DEPDIR)/powertop-main.Tpo -c -o powertop-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp - @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/powertop-main.Tpo $(DEPDIR)/powertop-main.Po -diff --git a/src/main.cpp b/src/main.cpp -index 7ead705..339cfd1 100644 ---- a/src/main.cpp -+++ b/src/main.cpp -@@ -68,17 +68,24 @@ int debug_learning = 0; - unsigned time_out = 20; - int leave_powertop = 0; - -+enum { -+ OPT_AUTO_TUNE = CHAR_MAX + 1, -+ OPT_EXTECH, -+ OPT_DEBUG -+}; -+ - static const struct option long_options[] = - { - /* These options set a flag. */ -- {"debug", no_argument, &debug_learning, 'd'}, -+ {"debug", no_argument, &debug_learning, OPT_DEBUG}, - {"version", no_argument, NULL, 'V'}, - {"help",no_argument, NULL, 'u'}, /* u for usage */ - {"calibrate",no_argument, NULL, 'c'}, -- {"auto-tune",no_argument, NULL, 'a'}, -- {"html", optional_argument, NULL, 'h'}, -+ {"auto-tune",no_argument, NULL, OPT_AUTO_TUNE}, -+ {"html", optional_argument, NULL, 'r'}, - {"csv", optional_argument, NULL, 'C'}, -- {"extech", optional_argument, NULL, 'e'}, -+ {"dump", optional_argument, NULL, 'd'}, -+ {"extech", optional_argument, NULL, OPT_EXTECH}, - {"time", optional_argument, NULL, 't'}, - {"iteration", optional_argument, NULL, 'i'}, - {"workload", optional_argument, NULL, 'w'}, -@@ -109,15 +116,16 @@ static void print_usage() - { - printf("%s\n\n",_("Usage: powertop [OPTIONS]")); - printf("--debug \t\t %s\n",_("run in \"debug\" mode")); -- printf("--version \t\t %s\n",_("print version information")); -- printf("--calibrate \t\t %s\n",_("runs powertop in calibration mode")); -+ printf("-V, --version \t\t %s\n",_("print version information")); -+ printf("-c, --calibrate \t\t %s\n",_("runs powertop in calibration mode")); - printf("--auto-tune \t\t %s\n",_("Sets all tunable options to their GOOD setting")); - printf("--extech%s \t %s\n",_("[=devnode]"),_("uses an Extech Power Analyzer for measurements")); -- printf("--html%s \t %s\n",_("[=FILENAME]"),_("generate a html report")); -- printf("--csv%s \t %s\n",_("[=FILENAME]"),_("generate a csv report")); -- printf("--time%s \t %s\n",_("[=seconds]"), _("generate a report for 'x' seconds")); -- printf("--iteration%s\n", _("[=iterations] number of times to run each test")); -- printf("--workload%s \t %s\n", _("[=workload]"), _("file to execute for workload")); -+ printf("-r, --html%s \t %s\n",_("[=FILENAME]"),_("generate a html report")); -+ printf("-C, --csv%s \t %s\n",_("[=FILENAME]"), _("generate a csv report")); -+ printf("-d, --dump%s \t %s\n", _("[=FILENAME]"), _("generate plain text report")); -+ printf("-t, --time%s \t %s\n",_("[=seconds]"), _("generate a report for 'x' seconds")); -+ printf("-i, --iteration%s\n", _("[=iterations] number of times to run each test")); -+ printf("-w, --workload%s \t %s\n", _("[=workload]"), _("file to execute for workload")); - printf("--quiet \t\t %s\n", _("suppress stderr output")); - printf("--help \t\t\t %s\n",_("print this help menu")); - printf("\n"); -@@ -373,7 +381,7 @@ int main(int argc, char **argv) - textdomain (PACKAGE); - - while (1) { /* parse commandline options */ -- c = getopt_long (argc, argv, "ch:C:i:t:uVw:q", long_options, &option_index); -+ c = getopt_long (argc, argv, "ch::C::d::r::i:t:uVw:q", long_options, &option_index); - /* Detect the end of the options. */ - if (c == -1) - break; -@@ -384,7 +392,10 @@ int main(int argc, char **argv) - exit(0); - break; - -- case 'e': /* Extech power analyzer support */ -+ case OPT_DEBUG: -+ /* implemented using getopt_long(3) flag */ -+ break; -+ case OPT_EXTECH: /* Extech power analyzer support */ - checkroot(); - extech_power_meter(optarg ? optarg : "/dev/ttyUSB0"); - break; -@@ -392,7 +403,7 @@ int main(int argc, char **argv) - print_usage(); - exit(0); - break; -- case 'a': -+ case OPT_AUTO_TUNE: - auto_tune = 1; - leave_powertop = 1; - break; -@@ -401,7 +412,8 @@ int main(int argc, char **argv) - calibrate(); - break; - -- case 'h': /* html report */ -+ case 'h': /* for backward compatibility */ -+ case 'r': /* html report */ - reporttype = REPORT_HTML; - snprintf(filename, 4096, "%s", optarg ? optarg : "powertop.html" ); - if (!strlen(filename)) -@@ -436,6 +448,10 @@ int main(int argc, char **argv) - exit(1); - } - break; -+ case 'd': /* plain text report (dump) */ -+ reporttype = REPORT_PLAIN; -+ snprintf(filename, sizeof(filename), "%s", optarg ? optarg : "-"); -+ break; - case '?': /* Unknown option */ - /* getopt_long already printed an error message. */ - exit(0); -diff --git a/src/report/report-formatter-plain.cpp b/src/report/report-formatter-plain.cpp -new file mode 100644 ---- /dev/null -+++ b/src/report/report-formatter-plain.cpp -@@ -0,0 +1,174 @@ -+/* Copyright (c) 2016 Jaroslav Škarvada -+ * Based on CSV formatter code by Igor Zhbanov -+ * -+ * This file is part of PowerTOP -+ * -+ * This program file is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; version 2 of the License. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -+ * for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program in a file named COPYING; if not, write to the -+ * Free Software Foundation, Inc, -+ * 51 Franklin Street, Fifth Floor, -+ * Boston, MA 02110-1301 USA -+ * or just google for it. -+ */ -+ -+#define _BSD_SOURCE -+ -+/* Uncomment to disable asserts */ -+/*#define NDEBUG*/ -+ -+#include -+#include -+#include -+ -+#include "report-formatter-plain.h" -+ -+static const char report_plain_header[] = "PowerTOP Report"; -+ -+/* ************************************************************************ */ -+ -+report_formatter_plain::report_formatter_plain() -+{ -+ add_doc_header(); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::finish_report() -+{ -+ /* Do nothing special */ -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::add_doc_header() -+{ -+ add_header(report_plain_header, 1); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::add_header(const char *header, int level) -+{ -+ assert(header); -+ -+ addf("%.*s%s%.*s", 4 - level, "===", header, 4 - level, "==="); -+ add_exact("\n"); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::begin_section(section_type stype) -+{ -+ /* Do nothing special */ -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::end_section() -+{ -+ /* Do nothing special */ -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::begin_table(table_type ttype) -+{ -+ add_exact("\n"); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::end_table() -+{ -+ add_exact("\n"); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::begin_row(row_type rtype) -+{ -+ table_cell_number = 0; -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::end_row() -+{ -+ add_exact("\n"); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::begin_cell(cell_type ctype) -+{ -+ if (table_cell_number > 0) -+ add_exact(" "); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::end_cell() -+{ -+ table_cell_number++; -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::add_empty_cell() -+{ -+ /* Do nothing special */ -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::begin_paragraph() -+{ -+ /* Do nothing special */ -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::end_paragraph() -+{ -+ add_exact("\n"); -+} -+ -+/* ************************************************************************ */ -+ -+std::string -+report_formatter_plain::escape_string(const char *str) -+{ -+ assert(str); -+ return std::string(str); -+} -+ -+/* ************************************************************************ */ -+ -+void -+report_formatter_plain::set_cpu_number(int nr UNUSED) -+{ -+ /* Do nothing */ -+} -diff --git a/src/report/report-formatter-plain.h b/src/report/report-formatter-plain.h -new file mode 100644 ---- /dev/null -+++ b/src/report/report-formatter-plain.h -@@ -0,0 +1,64 @@ -+/* Copyright (c) 2016 Jaroslav Škarvada -+ * Based on CSV formatter code by Igor Zhbanov -+ * -+ * This file is part of PowerTOP -+ * -+ * This program file is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; version 2 of the License. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -+ * for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program in a file named COPYING; if not, write to the -+ * Free Software Foundation, Inc, -+ * 51 Franklin Street, Fifth Floor, -+ * Boston, MA 02110-1301 USA -+ * or just google for it. -+ */ -+ -+#ifndef _REPORT_FORMATTER_PLAIN_H_ -+#define _REPORT_FORMATTER_PLAIN_H_ -+ -+#include -+ -+#include "report-formatter-base.h" -+ -+class report_formatter_plain: public report_formatter_string_base -+{ -+public: -+ report_formatter_plain(); -+ -+ void finish_report(); -+ -+ void add_header(const char *header, int level); -+ -+ void begin_section(section_type stype); -+ void end_section(); -+ -+ void begin_table(table_type ttype); -+ void end_table(); -+ -+ void begin_row(row_type rtype); -+ void end_row(); -+ -+ void begin_cell(cell_type ctype); -+ void end_cell(); -+ void add_empty_cell(); -+ -+ void begin_paragraph(); -+ void end_paragraph(); -+ -+ void set_cpu_number(int nr); -+ -+private: -+ void add_doc_header(); -+ -+ std::string escape_string(const char *str); -+ size_t table_cell_number; -+}; -+ -+#endif /* _REPORT_FORMATTER_PLAIN_H_ */ -diff --git a/src/report/report-maker.cpp b/src/report/report-maker.cpp -index 59e83d9..7b7ac05 100644 ---- a/src/report/report-maker.cpp -+++ b/src/report/report-maker.cpp -@@ -32,6 +32,7 @@ - #include "report-maker.h" - #include "report-formatter-csv.h" - #include "report-formatter-html.h" -+#include "report-formatter-plain.h" - - /* ************************************************************************ */ - -@@ -113,6 +114,8 @@ report_maker::setup_report_formatter() - formatter = new report_formatter_html(); - else if (type == REPORT_CSV) - formatter = new report_formatter_csv(); -+ else if (type == REPORT_PLAIN) -+ formatter = new report_formatter_plain(); - else if (type == REPORT_OFF) - formatter = new report_formatter(); - else -diff --git a/src/report/report-maker.h b/src/report/report-maker.h -index 75e0d06..a589cd8 100644 ---- a/src/report/report-maker.h -+++ b/src/report/report-maker.h -@@ -76,7 +76,7 @@ - - /* Conditional gettext. We need original strings for CSV. */ - #define __(STRING) \ -- ((report.get_type() == REPORT_CSV) ? (STRING) : gettext(STRING)) -+ ((report.get_type() == REPORT_CSV || report.get_type() == REPORT_PLAIN) ? (STRING) : gettext(STRING)) - - #ifndef UNUSED - #define UNUSED __attribute__((unused)) -@@ -87,7 +87,8 @@ - enum report_type { - REPORT_OFF, - REPORT_HTML, -- REPORT_CSV -+ REPORT_CSV, -+ REPORT_PLAIN - }; - - /* ************************************************************************ */ -diff --git a/src/report/report.cpp b/src/report/report.cpp -index b01b925..b1444b3 100644 ---- a/src/report/report.cpp -+++ b/src/report/report.cpp -@@ -152,28 +152,35 @@ void init_report_output(char *filename_str, int iterations) - string filename; - time_t stamp; - char datestr[200]; -+ int len; - -- if (iterations == 1) -- sprintf(reportout.filename, "%s", filename_str); -+ len = strlen(filename_str); -+ if (!len || (len == 1 && filename_str[0] == '-')) -+ reportout.report_file = stdout; - else - { -- filename = string(filename_str); -- period = filename.find_last_of("."); -- if (period > filename.length()) -- period = filename.length(); -- memset(&datestr, 0, 200); -- memset(&stamp, 0, sizeof(time_t)); -- stamp = time(NULL); -- strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp)); -- snprintf(reportout.filename, 4096, "%s-%s%s", -- filename.substr(0, period).c_str(), datestr, -- filename.substr(period).c_str()); -- } -- -- reportout.report_file = fopen(reportout.filename, "wm"); -- if (!reportout.report_file) { -- fprintf(stderr, _("Cannot open output file %s (%s)\n"), -- reportout.filename, strerror(errno)); -+ if (iterations == 1) -+ sprintf(reportout.filename, "%s", filename_str); -+ else -+ { -+ filename = string(filename_str); -+ period = filename.find_last_of("."); -+ if (period > filename.length()) -+ period = filename.length(); -+ memset(&datestr, 0, 200); -+ memset(&stamp, 0, sizeof(time_t)); -+ stamp = time(NULL); -+ strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp)); -+ snprintf(reportout.filename, 4096, "%s-%s%s", -+ filename.substr(0, period).c_str(), datestr, -+ filename.substr(period).c_str()); -+ } -+ -+ reportout.report_file = fopen(reportout.filename, "wm"); -+ if (!reportout.report_file) { -+ fprintf(stderr, _("Cannot open output file %s (%s)\n"), -+ reportout.filename, strerror(errno)); -+ } - } - - report.set_type(reporttype); -@@ -188,10 +195,14 @@ void finish_report_output(void) - report.finish_report(); - if (reportout.report_file) - { -- fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename); -+ if (reportout.report_file == stdout) -+ fprintf(stderr, _("PowerTOP outputing using standard output\n")); -+ else -+ fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename); - fputs(report.get_result(), reportout.report_file); - fdatasync(fileno(reportout.report_file)); -- fclose(reportout.report_file); -+ if (reportout.report_file != stdout) -+ fclose(reportout.report_file); - } - report.clear_result(); - } diff --git a/SOURCES/powertop-2.3-fd-limit-err.patch b/SOURCES/powertop-2.3-fd-limit-err.patch deleted file mode 100644 index d517e94..0000000 --- a/SOURCES/powertop-2.3-fd-limit-err.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff -up powertop-2.4/src/perf/perf.cpp.orig powertop-2.4/src/perf/perf.cpp ---- powertop-2.4/src/perf/perf.cpp.orig 2013-01-31 16:39:27.000000000 -0500 -+++ powertop-2.4/src/perf/perf.cpp 2013-09-19 10:36:02.298839248 -0400 -@@ -26,6 +26,7 @@ - #include - #include - -+#include - #include - #include - #include -@@ -72,6 +73,7 @@ void perf_event::create_perf_event(char - { - struct perf_event_attr attr; - int ret; -+ int err; - - struct { - __u64 count; -@@ -107,10 +109,15 @@ void perf_event::create_perf_event(char - perf_fd = sys_perf_event_open(&attr, -1, _cpu, -1, 0); - - if (perf_fd < 0) { -+ err = errno; - reset_display(); -- fprintf(stderr, _("PowerTOP %s needs the kernel to support the 'perf' subsystem\n"), POWERTOP_VERSION); -- fprintf(stderr, _("as well as support for trace points in the kernel:\n")); -- fprintf(stderr, "CONFIG_PERF_EVENTS=y\nCONFIG_PERF_COUNTERS=y\nCONFIG_TRACEPOINTS=y\nCONFIG_TRACING=y\n"); -+ if (err == EMFILE) -+ fprintf(stderr, _("Too many open files, please increase the limit of open file descriptors.\n")); -+ else { -+ fprintf(stderr, _("PowerTOP %s needs the kernel to support the 'perf' subsystem\n"), POWERTOP_VERSION); -+ fprintf(stderr, _("as well as support for trace points in the kernel:\n")); -+ fprintf(stderr, "CONFIG_PERF_EVENTS=y\nCONFIG_PERF_COUNTERS=y\nCONFIG_TRACEPOINTS=y\nCONFIG_TRACING=y\n"); -+ } - exit(EXIT_FAILURE); - } - if (read(perf_fd, &read_data, sizeof(read_data)) == -1) { diff --git a/SOURCES/powertop-2.3-improve-reporting.patch b/SOURCES/powertop-2.3-improve-reporting.patch deleted file mode 100644 index a6e48ef..0000000 --- a/SOURCES/powertop-2.3-improve-reporting.patch +++ /dev/null @@ -1,82 +0,0 @@ -diff --git a/src/main.cpp b/src/main.cpp -index 9da3167..7ead705 100644 ---- a/src/main.cpp -+++ b/src/main.cpp -@@ -403,7 +403,12 @@ int main(int argc, char **argv) - - case 'h': /* html report */ - reporttype = REPORT_HTML; -- sprintf(filename, "%s", optarg ? optarg : "powertop.html" ); -+ snprintf(filename, 4096, "%s", optarg ? optarg : "powertop.html" ); -+ if (!strlen(filename)) -+ { -+ fprintf(stderr, _("Invalid HTML filename\n")); -+ exit(1); -+ } - break; - - case 't': -@@ -424,7 +429,12 @@ int main(int argc, char **argv) - - case 'C': /* csv report*/ - reporttype = REPORT_CSV; -- sprintf(filename, "%s", optarg ? optarg : "powertop.csv"); -+ snprintf(filename, 4096, "%s", optarg ? optarg : "powertop.csv"); -+ if (!strlen(filename)) -+ { -+ fprintf(stderr, _("Invalid CSV filename\n")); -+ exit(1); -+ } - break; - case '?': /* Unknown option */ - /* getopt_long already printed an error message. */ -diff --git a/src/report/report.cpp b/src/report/report.cpp -index c018bb1..b01b925 100644 ---- a/src/report/report.cpp -+++ b/src/report/report.cpp -@@ -149,28 +149,27 @@ static void system_info(void) - void init_report_output(char *filename_str, int iterations) - { - size_t period; -- char file_prefix[4096]; -- char file_postfix[8]; -+ string filename; - time_t stamp; - char datestr[200]; - -- string mystring = string(filename_str); -- sprintf(file_postfix, "%s", -- (reporttype == REPORT_HTML ? "html" : "csv")); -- period=mystring.find_last_of("."); -- sprintf(file_prefix, "%s",mystring.substr(0,period).c_str()); -- memset(&datestr, 0, 200); -- memset(&stamp, 0, sizeof(time_t)); -- stamp=time(NULL); -- strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp)); -- -- if (iterations != 1) -- sprintf(reportout.filename, "%s-%s.%s", -- file_prefix, datestr,file_postfix); -+ if (iterations == 1) -+ sprintf(reportout.filename, "%s", filename_str); - else -- sprintf(reportout.filename, "%s.%s", -- file_prefix, file_postfix); -- -+ { -+ filename = string(filename_str); -+ period = filename.find_last_of("."); -+ if (period > filename.length()) -+ period = filename.length(); -+ memset(&datestr, 0, 200); -+ memset(&stamp, 0, sizeof(time_t)); -+ stamp = time(NULL); -+ strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp)); -+ snprintf(reportout.filename, 4096, "%s-%s%s", -+ filename.substr(0, period).c_str(), datestr, -+ filename.substr(period).c_str()); -+ } -+ - reportout.report_file = fopen(reportout.filename, "wm"); - if (!reportout.report_file) { - fprintf(stderr, _("Cannot open output file %s (%s)\n"), diff --git a/SOURCES/powertop-2.3-man-fix.patch b/SOURCES/powertop-2.3-man-fix.patch deleted file mode 100644 index 18ed664..0000000 --- a/SOURCES/powertop-2.3-man-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -up powertop-2.3/doc/powertop.8.orig powertop-2.3/doc/powertop.8 ---- powertop-2.3/doc/powertop.8.orig 2013-01-31 22:39:27.000000000 +0100 -+++ powertop-2.3/doc/powertop.8 2013-06-25 15:51:49.000000000 +0200 -@@ -46,6 +46,9 @@ sent to others to help diagnose power is - \fB\-\-iteration[\fR=\fIiterations\fR] - number of times to run each test. - .TP -+\fB\-\-workload[\fR=\fIworkload\fR] -+file to execute for workload. -+.TP - \fB\-\-quiet - supress stderr output. - .TP diff --git a/SOURCES/powertop-2.3-msr-check.patch b/SOURCES/powertop-2.3-msr-check.patch deleted file mode 100644 index 70c1ca4..0000000 --- a/SOURCES/powertop-2.3-msr-check.patch +++ /dev/null @@ -1,170 +0,0 @@ -diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp -index 1eb340c..b021955 100644 ---- a/src/cpu/cpu.cpp -+++ b/src/cpu/cpu.cpp -@@ -57,6 +57,7 @@ class perf_power_bundle: public perf_bundle - - static class abstract_cpu * new_package(int package, int cpu, char * vendor, int family, int model) - { -+ uint64_t msr; - class abstract_cpu *ret = NULL; - class cpudevice *cpudev; - char packagename[128]; -@@ -71,15 +72,19 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int - case 0x25: /* Westmere */ - case 0x27: /* Medfield Atom*/ - case 0x2C: /* Westmere */ -- ret = new class nhm_package; -+ if (read_msr(cpu, MSR_APERF, &msr) >= 0) -+ ret = new class nhm_package; - break; - case 0x2A: /* SNB */ - case 0x2D: /* SNB Xeon */ - case 0x3A: /* IVB */ - case 0x3C: - case 0x3D: /* IVB Xeon */ -- has_c2c7_res = 1; -- ret = new class nhm_package; -+ if (read_msr(cpu, MSR_PKG_C7_RESIDENCY, &msr) >= 0) -+ { -+ has_c2c7_res = 1; -+ ret = new class nhm_package; -+ } - break; - } - } -@@ -99,6 +104,7 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int - - static class abstract_cpu * new_core(int core, int cpu, char * vendor, int family, int model) - { -+ uint64_t msr; - class abstract_cpu *ret = NULL; - - if (strcmp(vendor, "GenuineIntel") == 0) { -@@ -116,7 +122,8 @@ static class abstract_cpu * new_core(int core, int cpu, char * vendor, int famil - case 0x3A: /* IVB */ - case 0x3C: - case 0x3D: /* IVB Xeon */ -- ret = new class nhm_core; -+ if (read_msr(cpu, MSR_APERF, &msr) >= 0) -+ ret = new class nhm_core; - } - } - -@@ -142,6 +149,7 @@ static class abstract_cpu * new_i965_gpu(void) - - static class abstract_cpu * new_cpu(int number, char * vendor, int family, int model) - { -+ uint64_t msr; - class abstract_cpu * ret = NULL; - - if (strcmp(vendor, "GenuineIntel") == 0) { -@@ -159,7 +167,8 @@ static class abstract_cpu * new_cpu(int number, char * vendor, int family, int m - case 0x3A: /* IVB */ - case 0x3C: - case 0x3D: /* IVB Xeon */ -- ret = new class nhm_cpu; -+ if (read_msr(number, MSR_APERF, &msr) >= 0) -+ ret = new class nhm_cpu; - } - } - -diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp -index 2b78d31..8d5f51a 100644 ---- a/src/cpu/intel_cpus.cpp -+++ b/src/cpu/intel_cpus.cpp -@@ -49,30 +49,15 @@ static uint64_t get_msr(int cpu, uint64_t offset) - { - ssize_t retval; - uint64_t msr; -- int fd; -- char msr_path[256]; - -- fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu); -- -- if (access(msr_path, R_OK) != 0){ -- fd = sprintf(msr_path, "/dev/msr%d", cpu); -- -- if (access(msr_path, R_OK) != 0){ -- fprintf(stderr, _("msr reg not found")); -- exit(-2); -- } -- } -- -- fd = open(msr_path, O_RDONLY); -- -- retval = pread(fd, &msr, sizeof msr, offset); -- if (retval != sizeof msr) { -+ retval = read_msr(cpu, offset, &msr); -+ if (retval < 0) { - reset_display(); -- fprintf(stderr, _("pread cpu%d 0x%llx : "), cpu, (unsigned long long)offset); -+ fprintf(stderr, _("read_msr cpu%d 0x%llx : "), cpu, (unsigned long long)offset); - fprintf(stderr, "%s\n", strerror(errno)); - exit(-2); - } -- close(fd); -+ - return msr; - } - -diff --git a/src/lib.cpp b/src/lib.cpp -index 723517a..6993088 100644 ---- a/src/lib.cpp -+++ b/src/lib.cpp -@@ -56,6 +56,7 @@ extern "C" { - #include - #include - #include -+#include - - static int kallsyms_read = 0; - -@@ -450,3 +451,36 @@ int get_user_input(char *buf, unsigned sz) - /* to distinguish between getnstr error and empty line */ - return ret || strlen(buf); - } -+ -+int read_msr(int cpu, uint64_t offset, uint64_t *value) -+{ -+ ssize_t retval; -+ uint64_t msr; -+ int fd; -+ char msr_path[256]; -+ -+ sprintf(msr_path, "/dev/cpu/%d/msr", cpu); -+ -+ if (access(msr_path, R_OK) != 0){ -+ sprintf(msr_path, "/dev/msr%d", cpu); -+ -+ if (access(msr_path, R_OK) != 0){ -+ fprintf(stderr, -+ _("Model-specific registers (MSR)\ -+ not found (try enabling CONFIG_X86_MSR).\n")); -+ return -1; -+ } -+ } -+ -+ fd = open(msr_path, O_RDONLY); -+ if (fd < 0) -+ return -1; -+ retval = pread(fd, &msr, sizeof msr, offset); -+ close(fd); -+ if (retval != sizeof msr) { -+ return -1; -+ } -+ *value = msr; -+ -+ return retval; -+} -diff --git a/src/lib.h b/src/lib.h -index de2de5a..1c9ca42 100644 ---- a/src/lib.h -+++ b/src/lib.h -@@ -74,5 +74,6 @@ typedef void (*callback)(const char*); - extern void process_directory(const char *d_name, callback fn); - extern int utf_ok; - extern int get_user_input(char *buf, unsigned sz); -+extern int read_msr(int cpu, uint64_t offset, uint64_t *value); - - #endif diff --git a/SOURCES/powertop-2.3-ondemand-check.patch b/SOURCES/powertop-2.3-ondemand-check.patch deleted file mode 100644 index faba75f..0000000 --- a/SOURCES/powertop-2.3-ondemand-check.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff -up powertop-2.3/src/tuning/cpufreq.cpp.orig powertop-2.3/src/tuning/cpufreq.cpp ---- powertop-2.3/src/tuning/cpufreq.cpp.orig 2013-01-31 22:39:27.000000000 +0100 -+++ powertop-2.3/src/tuning/cpufreq.cpp 2013-06-28 14:05:04.254925669 +0200 -@@ -63,6 +63,7 @@ int cpufreq_tunable::good_bad(void) - - char gov[1024]; - int ret = TUNE_GOOD; -+ unsigned long int ld; - - - gov[0] = 0; -@@ -91,6 +92,30 @@ int cpufreq_tunable::good_bad(void) - if (strcmp(gov, line)) - ret = TUNE_BAD; - fclose(file); -+ -+ /* check if ondemand governor is available */ -+ sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_available_governors", dirent->d_name); -+ file = fopen(filename, "r"); -+ if (!file) -+ continue; -+ memset(line, 0, 1024); -+ if (fgets(line, 1023,file)==NULL || strstr(line, "ondemand")==NULL) { -+ fclose(file); -+ continue; -+ } -+ fclose(file); -+ -+ /* check if cpu transition latency is not higher than ondemand governor max_transition_latency */ -+ sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/cpuinfo_transition_latency", dirent->d_name); -+ file = fopen(filename, "r"); -+ if (!file) -+ continue; -+ if (fscanf(file, "%lu", &ld) != 1 || ld > 10000000) -+ { -+ fclose(file); -+ continue; -+ } -+ fclose(file); - } - - closedir(dir); diff --git a/SOURCES/powertop-2.3-reg-net-params.patch b/SOURCES/powertop-2.3-reg-net-params.patch deleted file mode 100644 index 12ea77e..0000000 --- a/SOURCES/powertop-2.3-reg-net-params.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff -up ./src/devices/network.cpp.orig ./src/devices/network.cpp ---- ./src/devices/network.cpp.orig 2013-10-29 08:26:59.000000000 +0100 -+++ ./src/devices/network.cpp 2013-10-29 08:30:52.100379762 +0100 -@@ -346,9 +346,29 @@ const char * network::device_name(void) - - void netdev_callback(const char *d_name) - { -+ char devname[128]; -+ - std::string f_name("/sys/class/net/"); - f_name.append(d_name); - -+ sprintf(devname, "%s-up", d_name); -+ register_parameter(devname); -+ -+ sprintf(devname, "%s-powerunsave", d_name); -+ register_parameter(devname); -+ -+ sprintf(devname, "%s-link-100", d_name); -+ register_parameter(devname); -+ -+ sprintf(devname, "%s-link-1000", d_name); -+ register_parameter(devname); -+ -+ sprintf(devname, "%s-link-high", d_name); -+ register_parameter(devname); -+ -+ sprintf(devname, "%s-packets", d_name); -+ register_parameter(devname); -+ - network *bl = new(std::nothrow) class network(d_name, f_name.c_str()); - if (bl) { - all_devices.push_back(bl); diff --git a/SOURCES/powertop-2.3-tunable-overflow-fix.patch b/SOURCES/powertop-2.3-tunable-overflow-fix.patch deleted file mode 100644 index 46f9fbd..0000000 --- a/SOURCES/powertop-2.3-tunable-overflow-fix.patch +++ /dev/null @@ -1,271 +0,0 @@ -diff --git a/src/tuning/bluetooth.cpp b/src/tuning/bluetooth.cpp -index e0bdf12..01c673d 100644 ---- a/src/tuning/bluetooth.cpp -+++ b/src/tuning/bluetooth.cpp -@@ -46,8 +46,8 @@ - bt_tunable::bt_tunable(void) : tunable("", 1.0, "Good", "Bad", "Unknown") - { - sprintf(desc, _("Bluetooth device interface status")); -- strcpy(toggle_bad, "/usr/sbin/hciconfig hci0 up &> /dev/null &"); -- strcpy(toggle_good, "/usr/sbin/hciconfig hci0 down &> /dev/null"); -+ toggle_bad = "/usr/sbin/hciconfig hci0 up &> /dev/null &"; -+ toggle_good = "/usr/sbin/hciconfig hci0 down &> /dev/null"; - } - - -@@ -188,9 +188,9 @@ const char *bt_tunable::toggle_script(void) - good = good_bad(); - - if (good == TUNE_GOOD) { -- return toggle_bad; -+ return toggle_bad.c_str(); - } -- return toggle_good; -+ return toggle_good.c_str(); - } - - -diff --git a/src/tuning/cpufreq.cpp b/src/tuning/cpufreq.cpp -index c169e6e..f696c89 100644 ---- a/src/tuning/cpufreq.cpp -+++ b/src/tuning/cpufreq.cpp -@@ -189,7 +189,7 @@ const char *cpufreq_tunable::toggle_script(void) { - int good; - good = good_bad(); - -- strcpy(toggle_good, "/sbin/modprobe cpufreq_ondemand > /dev/null 2>&1\n"); -+ toggle_good = "/sbin/modprobe cpufreq_ondemand > /dev/null 2>&1\n"; - - if (good == TUNE_GOOD) { - dir = opendir("/sys/devices/system/cpu"); -@@ -202,12 +202,12 @@ const char *cpufreq_tunable::toggle_script(void) { - sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name); - if (stat(filename, &statbuf) == -1) - continue; -- sprintf(tmp, "echo '%s' > '%s';\n", original, filename); -- strcat(toggle_good, tmp); -+ snprintf(tmp, 4096, "echo '%s' > '%s';\n", original, filename); -+ toggle_good += tmp; - } - - closedir(dir); -- return toggle_good; -+ return toggle_good.c_str(); - } - - dir = opendir("/sys/devices/system/cpu"); -@@ -220,12 +220,12 @@ const char *cpufreq_tunable::toggle_script(void) { - sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name); - if (stat(filename, &statbuf) == -1) - continue; -- sprintf(tmp, "echo 'ondemand' > '%s';\n", filename); -- strcat(toggle_good, tmp); -+ snprintf(tmp, 4096, "echo 'ondemand' > '%s';\n", filename); -+ toggle_good += tmp; - } - - closedir(dir); -- return toggle_good; -+ return toggle_good.c_str(); - } - - -diff --git a/src/tuning/ethernet.cpp b/src/tuning/ethernet.cpp -index 3164b31..d5ad8ed 100644 ---- a/src/tuning/ethernet.cpp -+++ b/src/tuning/ethernet.cpp -@@ -52,11 +52,13 @@ extern void create_all_nics(callback fn); - - ethernet_tunable::ethernet_tunable(const char *iface) : tunable("", 0.3, _("Good"), _("Bad"), _("Unknown")) - { -+ char tmp[4096]; -+ - memset(interf, 0, sizeof(interf)); - strncpy(interf, iface, sizeof(interf)); - sprintf(desc, _("Wake-on-lan status for device %s"), iface); -- sprintf(toggle_good, "ethtool -s %s wol d;", iface); -- -+ snprintf(tmp, 4096, "ethtool -s %s wol d;", iface); -+ toggle_good = tmp; - } - - -@@ -137,7 +139,7 @@ const char *ethernet_tunable::toggle_script(void) - good = good_bad(); - - if (good != TUNE_GOOD) { -- return toggle_good; -+ return toggle_good.c_str(); - } - - return NULL; -diff --git a/src/tuning/runtime.cpp b/src/tuning/runtime.cpp -index b57d53e..3369976 100644 ---- a/src/tuning/runtime.cpp -+++ b/src/tuning/runtime.cpp -@@ -42,6 +42,7 @@ runtime_tunable::runtime_tunable(const char *path, const char *bus, const char * - { - ifstream file; - sprintf(runtime_path, "%s/power/control", path); -+ char tmp[4096]; - - - sprintf(desc, _("Runtime PM for %s device %s"), bus, dev); -@@ -77,8 +78,10 @@ runtime_tunable::runtime_tunable(const char *path, const char *bus, const char * - - - } -- sprintf(toggle_good, "echo 'auto' > '%s';", runtime_path); -- sprintf(toggle_bad, "echo 'on' > '%s';", runtime_path); -+ snprintf(tmp, 4096, "echo 'auto' > '%s';", runtime_path); -+ toggle_good = tmp; -+ snprintf(tmp, 4096, "echo 'on' > '%s';", runtime_path); -+ toggle_bad = tmp; - } - - int runtime_tunable::good_bad(void) -@@ -112,10 +115,10 @@ const char *runtime_tunable::toggle_script(void) - good = good_bad(); - - if (good == TUNE_GOOD) { -- return toggle_bad; -+ return toggle_bad.c_str(); - } - -- return toggle_good; -+ return toggle_good.c_str(); - } - - -diff --git a/src/tuning/tunable.h b/src/tuning/tunable.h -index 3372378..8f90ee2 100644 ---- a/src/tuning/tunable.h -+++ b/src/tuning/tunable.h -@@ -26,6 +26,7 @@ - #define _INCLUDE_GUARD_TUNABLE_H - - #include -+#include - - #include "../lib.h" - -@@ -43,8 +44,8 @@ class tunable { - char bad_string[128]; - char neutral_string[128]; - protected: -- char toggle_good[4096]; -- char toggle_bad[4096]; -+ string toggle_good; -+ string toggle_bad; - public: - char desc[4096]; - double score; -diff --git a/src/tuning/tuningsysfs.cpp b/src/tuning/tuningsysfs.cpp -index ec1ca6b..aa4ebd5 100644 ---- a/src/tuning/tuningsysfs.cpp -+++ b/src/tuning/tuningsysfs.cpp -@@ -43,11 +43,15 @@ - - sysfs_tunable::sysfs_tunable(const char *str, const char *_sysfs_path, const char *_target_content) : tunable(str, 1.0, _("Good"), _("Bad"), _("Unknown")) - { -+ char tmp[4096]; -+ - strcpy(sysfs_path, _sysfs_path); - strcpy(target_value, _target_content); - bad_value[0] = 0; -- sprintf(toggle_good, "echo '%s' > '%s';", target_value, sysfs_path); -- sprintf(toggle_bad, "echo '%s' > '%s';", bad_value, sysfs_path); -+ snprintf(tmp, 4096, "echo '%s' > '%s';", target_value, sysfs_path); -+ toggle_good = tmp; -+ snprintf(tmp, 4096, "echo '%s' > '%s';", bad_value, sysfs_path); -+ toggle_bad = tmp; - } - - int sysfs_tunable::good_bad(void) -@@ -92,11 +96,11 @@ const char *sysfs_tunable::toggle_script(void) { - - if (good == TUNE_GOOD) { - if (strlen(bad_value) > 0) -- return toggle_bad; -+ return toggle_bad.c_str(); - return NULL; - } - -- return toggle_good; -+ return toggle_good.c_str(); - } - - -diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp -index 74bbacf..2cd7efe 100644 ---- a/src/tuning/tuningusb.cpp -+++ b/src/tuning/tuningusb.cpp -@@ -43,6 +43,7 @@ usb_tunable::usb_tunable(const char *path, const char *name) : tunable("", 0.9, - char filename[4096]; - char vendor[2048]; - char product[2048]; -+ char tmp[4096]; - string str1, str2; - sprintf(usb_path, "%s/power/control", path); - -@@ -75,8 +76,10 @@ usb_tunable::usb_tunable(const char *path, const char *name) : tunable("", 0.9, - else if (strlen(vendor)) - sprintf(desc, _("Autosuspend for USB device %s [%s]"), vendor, name); - -- sprintf(toggle_good, "echo 'auto' > '%s';", usb_path); -- sprintf(toggle_bad, "echo 'on' > '%s';", usb_path); -+ snprintf(tmp, 4096, "echo 'auto' > '%s';", usb_path); -+ toggle_good = tmp; -+ snprintf(tmp, 4096, "echo 'on' > '%s';", usb_path); -+ toggle_bad = tmp; - } - - int usb_tunable::good_bad(void) -@@ -110,10 +113,10 @@ const char *usb_tunable::toggle_script(void) - good = good_bad(); - - if (good == TUNE_GOOD) { -- return toggle_bad; -+ return toggle_bad.c_str(); - } - -- return toggle_good; -+ return toggle_good.c_str(); - } - - void add_usb_tunables(void) -diff --git a/src/tuning/wifi.cpp b/src/tuning/wifi.cpp -index 77cdfcc..2cc01b8 100644 ---- a/src/tuning/wifi.cpp -+++ b/src/tuning/wifi.cpp -@@ -44,11 +44,15 @@ extern "C" { - - wifi_tunable::wifi_tunable(const char *_iface) : tunable("", 1.5, _("Good"), _("Bad"), _("Unknown")) - { -+ char tmp[4096]; -+ - strcpy(iface, _iface); - sprintf(desc, _("Wireless Power Saving for interface %s"), iface); - -- sprintf(toggle_good, "iw dev %s set power_save on", iface); -- sprintf(toggle_bad, "iw dev %s set power_save off", iface); -+ snprintf(tmp, 4096, "iw dev %s set power_save on", iface); -+ toggle_good = tmp; -+ snprintf(tmp, 4096, "iw dev %s set power_save off", iface); -+ toggle_bad = tmp; - } - - int wifi_tunable::good_bad(void) -@@ -78,10 +82,10 @@ const char *wifi_tunable::toggle_script(void) - good = good_bad(); - - if (good == TUNE_GOOD) { -- return toggle_bad; -+ return toggle_bad.c_str(); - } - -- return toggle_good; -+ return toggle_good.c_str(); - } - - void add_wifi_tunables(void) diff --git a/SOURCES/powertop-2.3-unlimit-fds.patch b/SOURCES/powertop-2.3-unlimit-fds.patch deleted file mode 100644 index b98b10b..0000000 --- a/SOURCES/powertop-2.3-unlimit-fds.patch +++ /dev/null @@ -1,65 +0,0 @@ -diff --git a/src/main.cpp b/src/main.cpp -index 0883424..16b1613 100644 ---- a/src/main.cpp -+++ b/src/main.cpp -@@ -28,6 +28,7 @@ - * Arjan van de Ven - */ - #include -+#include - #include - #include - #include -@@ -36,6 +37,7 @@ - #include - #include - #include -+#include - - #include "cpu/cpu.h" - #include "process/process.h" -@@ -60,6 +62,8 @@ - - #define DEBUGFS_MAGIC 0x64626720 - -+#define NR_OPEN_DEF 1024 * 1024 -+ - int debug_learning = 0; - unsigned time_out = 20; - int leave_powertop = 0; -@@ -278,16 +282,35 @@ static void checkroot() { - - } - -+static int get_nr_open(void) { -+ int nr_open = NR_OPEN_DEF; -+ ifstream file; -+ -+ file.open("/proc/sys/fs/nr_open", ios::in); -+ if (file) { -+ file >> nr_open; -+ if (!file) -+ nr_open = NR_OPEN_DEF; -+ file.close(); -+ } -+ return nr_open; -+} -+ - static void powertop_init(void) - { - static char initialized = 0; - int ret; - struct statfs st_fs; -+ struct rlimit rlmt; - - if (initialized) - return; - - checkroot(); -+ -+ rlmt.rlim_cur = rlmt.rlim_max = get_nr_open(); -+ setrlimit (RLIMIT_NOFILE, &rlmt); -+ - ret = system("/sbin/modprobe cpufreq_stats > /dev/null 2>&1"); - ret = system("/sbin/modprobe msr > /dev/null 2>&1"); - statfs("/sys/kernel/debug", &st_fs); diff --git a/SOURCES/powertop-2.7-always-create-params.patch b/SOURCES/powertop-2.7-always-create-params.patch new file mode 100644 index 0000000..87ddf7d --- /dev/null +++ b/SOURCES/powertop-2.7-always-create-params.patch @@ -0,0 +1,35 @@ +diff --git a/src/parameters/persistent.cpp b/src/parameters/persistent.cpp +index 9a5688a..6a232cd 100644 +--- a/src/parameters/persistent.cpp ++++ b/src/parameters/persistent.cpp +@@ -145,9 +145,6 @@ void save_parameters(const char *filename) + + // printf("result size is %i, #parameters is %i \n", (int)past_results.size(), (int)all_parameters.parameters.size()); + +- if (!global_power_valid()) +- return; +- + pathname = get_param_directory(filename); + + file.open(pathname, ios::out); +@@ -156,12 +153,15 @@ void save_parameters(const char *filename) + return; + } + +- map::iterator it; ++ if (global_power_valid()) ++ { ++ map::iterator it; + +- for (it = param_index.begin(); it != param_index.end(); it++) { +- int index; +- index = it->second; +- file << it->first << "\t" << setprecision(9) << all_parameters.parameters[index] << "\n"; ++ for (it = param_index.begin(); it != param_index.end(); it++) { ++ int index; ++ index = it->second; ++ file << it->first << "\t" << setprecision(9) << all_parameters.parameters[index] << "\n"; ++ } + } + file.close(); + } diff --git a/SOURCES/powertop-2.9-cstates-rewrite-fix.patch b/SOURCES/powertop-2.9-cstates-rewrite-fix.patch new file mode 100644 index 0000000..3119bc8 --- /dev/null +++ b/SOURCES/powertop-2.9-cstates-rewrite-fix.patch @@ -0,0 +1,41 @@ +From f3f350f138912dc89abb37676f7e65fc6057ec53 Mon Sep 17 00:00:00 2001 +From: Gautam Paranjape +Date: Fri, 21 Jul 2017 07:02:13 -0700 +Subject: [PATCH] Some c-states exposed by the intel_idle driver are assigned + the same line_level, which means that the most recent one assigned can + overwrite another c-state. For example, the C1-SKL c-state is overwritten by + the C1E-SKL c-state because both have a "1" in the name and are assigned the + same line level. To fix this, check if a "sub c-state" (ex. C1E-SKL) is being + inserted. If so, check the vector of c-states if a c-state with similar name + (ex. C1-SKL) exists, and increment the line level. + +Signed-off-by: Gautam Paranjape +--- + src/cpu/abstract_cpu.cpp | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/src/cpu/abstract_cpu.cpp b/src/cpu/abstract_cpu.cpp +index bc32336..c59721c 100644 +--- a/src/cpu/abstract_cpu.cpp ++++ b/src/cpu/abstract_cpu.cpp +@@ -218,6 +218,17 @@ void abstract_cpu::insert_cstate(const char *linux_name, const char *human_name, + } + if (*c >= '0' && *c <='9') { + state->line_level = strtoull(c, NULL, 10); ++ if(*(c+1) != '-'){ ++ int greater_line_level = strtoull(c, NULL, 10); ++ for(unsigned int pos = 0; pos < cstates.size(); pos++){ ++ if(*c == cstates[pos]->human_name[1]){ ++ if(*(c+1) != cstates[pos]->human_name[2]){ ++ greater_line_level = max(greater_line_level, cstates[pos]->line_level); ++ state->line_level = greater_line_level + 1; ++ } ++ } ++ } ++ } + break; + } + c++; +-- +2.14.3 + diff --git a/SOURCES/powertop-2.9-intel-cnluy-support.patch b/SOURCES/powertop-2.9-intel-cnluy-support.patch new file mode 100644 index 0000000..7e3a3b4 --- /dev/null +++ b/SOURCES/powertop-2.9-intel-cnluy-support.patch @@ -0,0 +1,51 @@ +From 0d3a1cda2a95484fa41cc4c35294a4153b3a5e97 Mon Sep 17 00:00:00 2001 +From: Nivedita Swaminathan +Date: Wed, 31 Jan 2018 14:53:28 -0800 +Subject: [PATCH] Enable support for Intel CNL-U/Y + +This commit adds support for Intel CNL-U/Y platforms + +Signed-off-by: Nivedita Swaminathan +--- + src/cpu/intel_cpus.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp +index 4980516..4c7b315 100644 +--- a/src/cpu/intel_cpus.cpp ++++ b/src/cpu/intel_cpus.cpp +@@ -68,6 +68,7 @@ static int intel_cpu_models[] = { + 0x5E, /* SKY */ + 0x56, /* BDX-DE */ + 0x5c, /* BXT-P */ ++ 0x66, /* CNL-U/Y */ + 0x7A, /* GLK */ + 0x8E, /* KBL */ + 0x9E, /* KBL */ +@@ -166,6 +167,7 @@ nhm_core::nhm_core(int model) + case 0x5E: /* SKY */ + case 0x3D: /* BDW */ + case 0x5c: /* BXT-P */ ++ case 0x66: /* CNL-U/Y */ + case 0x7A: /* GLK */ + case 0x8E: /* KBL */ + case 0x9E: /* KBL */ +@@ -347,6 +349,7 @@ nhm_package::nhm_package(int model) + case 0x5E: /* SKY */ + case 0x3D: /* BDW */ + case 0x5c: /* BXT-P */ ++ case 0x66: /* CNL-U/Y */ + case 0x7A: /* GLK */ + case 0x8E: /* KBL */ + case 0x9E: /* KBL */ +@@ -380,6 +383,7 @@ nhm_package::nhm_package(int model) + case 0x4E: /* SKY */ + case 0x5E: /* SKY */ + case 0x5c: /* BXT-P */ ++ case 0x66: /* CNL-U/Y */ + case 0x7A: /* GLK */ + case 0x8E: /* KBL */ + case 0x9E: /* KBL */ +-- +2.14.3 + diff --git a/SOURCES/powertop-2.9-intel-cpu-check-aperf.patch b/SOURCES/powertop-2.9-intel-cpu-check-aperf.patch new file mode 100644 index 0000000..4793685 --- /dev/null +++ b/SOURCES/powertop-2.9-intel-cpu-check-aperf.patch @@ -0,0 +1,66 @@ +diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp +index f3711f5..019d922 100644 +--- a/src/cpu/cpu.cpp ++++ b/src/cpu/cpu.cpp +@@ -68,7 +68,7 @@ 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, cpu)) + ret = new class nhm_package(model); + + if (!ret) +@@ -105,7 +105,7 @@ 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, cpu)) + ret = new class nhm_core(model); + + if (!ret) +@@ -134,7 +134,7 @@ 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, number)) + ret = new class nhm_cpu; + + if (!ret) +diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp +index 4c7b315..0030dba 100644 +--- a/src/cpu/intel_cpus.cpp ++++ b/src/cpu/intel_cpus.cpp +@@ -77,13 +77,15 @@ static int intel_cpu_models[] = { + + static int intel_pstate_driver_loaded = -1; + +-int is_supported_intel_cpu(int model) ++int is_supported_intel_cpu(int model, int cpu) + { + int i; ++ uint64_t msr; + + for (i = 0; intel_cpu_models[i] != 0; i++) + if (model == intel_cpu_models[i]) +- return 1; ++ if (cpu < 0 || read_msr(cpu, MSR_APERF, &msr) >= 0) ++ return 1; + + return 0; + } +diff --git a/src/cpu/intel_cpus.h b/src/cpu/intel_cpus.h +index d20db9a..79afb98 100644 +--- a/src/cpu/intel_cpus.h ++++ b/src/cpu/intel_cpus.h +@@ -172,7 +172,7 @@ public: + + }; + +-int is_supported_intel_cpu(int model); ++int is_supported_intel_cpu(int model, int cpu); + int byt_has_ahci(); + + int is_intel_pstate_driver_loaded(); diff --git a/SOURCES/powertop-2.9-intel-glk-support.patch b/SOURCES/powertop-2.9-intel-glk-support.patch new file mode 100644 index 0000000..fa086ab --- /dev/null +++ b/SOURCES/powertop-2.9-intel-glk-support.patch @@ -0,0 +1,51 @@ +From 523b15bd892f036bb6b777ad6c88f334f0980347 Mon Sep 17 00:00:00 2001 +From: Nivedita Swaminathan +Date: Wed, 31 Jan 2018 14:41:18 -0800 +Subject: [PATCH] Enable support for Intel GLK + +This commit enables support for Intel GLK platforms + +Signed-off-by: Nivedita Swaminathan +--- + src/cpu/intel_cpus.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp +index 3901342..4980516 100644 +--- a/src/cpu/intel_cpus.cpp ++++ b/src/cpu/intel_cpus.cpp +@@ -68,6 +68,7 @@ static int intel_cpu_models[] = { + 0x5E, /* SKY */ + 0x56, /* BDX-DE */ + 0x5c, /* BXT-P */ ++ 0x7A, /* GLK */ + 0x8E, /* KBL */ + 0x9E, /* KBL */ + 0 /* last entry must be zero */ +@@ -165,6 +166,7 @@ nhm_core::nhm_core(int model) + case 0x5E: /* SKY */ + case 0x3D: /* BDW */ + case 0x5c: /* BXT-P */ ++ case 0x7A: /* GLK */ + case 0x8E: /* KBL */ + case 0x9E: /* KBL */ + has_c7_res = 1; +@@ -345,6 +347,7 @@ nhm_package::nhm_package(int model) + case 0x5E: /* SKY */ + case 0x3D: /* BDW */ + case 0x5c: /* BXT-P */ ++ case 0x7A: /* GLK */ + case 0x8E: /* KBL */ + case 0x9E: /* KBL */ + has_c2c6_res=1; +@@ -377,6 +380,7 @@ nhm_package::nhm_package(int model) + case 0x4E: /* SKY */ + case 0x5E: /* SKY */ + case 0x5c: /* BXT-P */ ++ case 0x7A: /* GLK */ + case 0x8E: /* KBL */ + case 0x9E: /* KBL */ + has_c8c9c10_res = 1; +-- +2.14.3 + diff --git a/SOURCES/powertop-2.9-powertop-2.3-compat.patch b/SOURCES/powertop-2.9-powertop-2.3-compat.patch new file mode 100644 index 0000000..3742e4c --- /dev/null +++ b/SOURCES/powertop-2.9-powertop-2.3-compat.patch @@ -0,0 +1,552 @@ +From fa86b4030ae67b7a8445c831493bba551c6613e8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= +Date: Fri, 4 May 2018 14:56:13 +0200 +Subject: [PATCH] RHEL-7 PowerTOP 2.3 compatibility patch +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Jaroslav Škarvada +--- + doc/powertop.8 | 22 ++++-- + src/Makefile.am | 2 + + src/Makefile.in | 20 +++++ + src/main.cpp | 17 +++-- + src/report/report-formatter-plain.cpp | 133 ++++++++++++++++++++++++++++++++++ + src/report/report-formatter-plain.h | 54 ++++++++++++++ + src/report/report-maker.cpp | 3 + + src/report/report-maker.h | 5 +- + src/report/report.cpp | 53 ++++++++------ + 9 files changed, 275 insertions(+), 34 deletions(-) + create mode 100644 src/report/report-formatter-plain.cpp + create mode 100644 src/report/report-formatter-plain.h + +diff --git a/doc/powertop.8 b/doc/powertop.8 +index 60e3c73..c18344d 100644 +--- a/doc/powertop.8 ++++ b/doc/powertop.8 +@@ -23,12 +23,20 @@ can get more accurate estimates by using this option to enable a + calibration cycle. This will cycle through various display levels and + USB device activities and workloads. + .TP +-\fB\-C\fR, \fB\-\-csv\fR[=\fIfilename\fR] ++\fB\-C\fR[\fIfilename\fR], \fB\-\-csv\fR[=\fIfilename\fR] + Generate a CSV report. If a + .I filename + is not specified then the default name + .B powertop.csv +-is used. The CSV report can be used for reporting and data analysis. ++is used. If a ++.I filename ++is "\fB\-\fR" then STDOUT is used. The CSV report can ++be used for reporting and data analysis. ++.TP ++\fB\-d\fR[\fIfilename\fR], \fB\-\-dump\fR[=\fIfilename\fR] ++Generate a plain text report. If a ++.I filename ++is not specified or it is "\fB\-\fR" then STDOUT is used. + .TP + .B \-\-debug + Run in debug mode. +@@ -39,13 +47,15 @@ specify the serial device node of the serial to USB adaptor connecting to + the Extech Power Analyzer, for example + .IR /dev/ttyUSB0 . + .TP +-\fB\-r\fR, \fB\-\-html\fR[=\fIfilename\fR] ++\fB\-r\fR[\fIfilename\fR], \fB\-h\fR[\fIfilename\fR], \fB\-\-html\fR[=\fIfilename\fR] + Generate an HTML report. If a + .I filename + is not specified then the default name + .B powertop.html +-is used. The HTML report can be sent to others to help diagnose power +-issues. ++is used. If a ++.I filename ++is "\fB\-\fR" then STDOUT is used. The HTML report can be sent to others to help ++diagnose power issues. + .TP + \fB\-i\fR, \fB\-\-iteration\fR[=\fIiterations\fR] + Number of times to run each test. +@@ -65,7 +75,7 @@ file as a part of calibration before making a report. + .BR \-V ", " \-\-version + Print version information and exit. + .TP +-.BR \-h ", " \-\-help ++.BR \-u ", " \-\-help + Show the help message and exit. + .SH COMMANDS + In interactive mode, the following key bindings are available: +diff --git a/src/Makefile.am b/src/Makefile.am +index 8357bae..5882468 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -99,6 +99,8 @@ powertop_SOURCES = \ + report/report-formatter-csv.h \ + report/report-formatter-html.cpp \ + report/report-formatter-html.h \ ++ report/report-formatter-plain.cpp \ ++ eport/report-formatter-plain.h \ + report/report-formatter.h \ + report/report-maker.cpp \ + report/report-maker.h \ +diff --git a/src/Makefile.in b/src/Makefile.in +index 643b7ce..90ebdff 100644 +--- a/src/Makefile.in ++++ b/src/Makefile.in +@@ -159,6 +159,7 @@ am_powertop_OBJECTS = powertop-devlist.$(OBJEXT) \ + report/powertop-report-formatter-base.$(OBJEXT) \ + report/powertop-report-formatter-csv.$(OBJEXT) \ + report/powertop-report-formatter-html.$(OBJEXT) \ ++ report/powertop-report-formatter-plain.$(OBJEXT) \ + report/powertop-report-maker.$(OBJEXT) \ + report/powertop-report.$(OBJEXT) \ + tuning/powertop-bluetooth.$(OBJEXT) \ +@@ -512,6 +513,8 @@ powertop_SOURCES = \ + report/report-formatter-csv.h \ + report/report-formatter-html.cpp \ + report/report-formatter-html.h \ ++ report/report-formatter-plain.cpp \ ++ report/report-formatter-plain.h \ + report/report-formatter.h \ + report/report-maker.cpp \ + report/report-maker.h \ +@@ -806,6 +809,8 @@ report/powertop-report-formatter-csv.$(OBJEXT): \ + report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp) + report/powertop-report-formatter-html.$(OBJEXT): \ + report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp) ++report/powertop-report-formatter-plain.$(OBJEXT): \ ++ report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp) + report/powertop-report-maker.$(OBJEXT): report/$(am__dirstamp) \ + report/$(DEPDIR)/$(am__dirstamp) + report/powertop-report.$(OBJEXT): report/$(am__dirstamp) \ +@@ -907,6 +912,7 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-base.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-csv.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-html.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-plain.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-maker.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@tuning/$(DEPDIR)/powertop-bluetooth.Po@am__quote@ +@@ -1675,6 +1681,20 @@ report/powertop-report-formatter-html.o: report/report-formatter-html.cpp + @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-html.o `test -f 'report/report-formatter-html.cpp' || echo '$(srcdir)/'`report/report-formatter-html.cpp + ++report/powertop-report-formatter-plain.o: report/report-formatter-plain.cpp ++@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-plain.o -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-plain.Tpo -c -o report/powertop-report-formatter-plain.o `test -f 'report/report-formatter-plain.cpp' || echo '$(srcdir)/'`report/report-formatter-plain.cpp ++@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-plain.Tpo report/$(DEPDIR)/powertop-report-formatter-plain.Po ++@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='report/report-formatter-plain.cpp' object='report/powertop-report-formatter-plain.o' libtool=no @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-plain.o `test -f 'report/report-formatter-plain.cpp' || echo '$(srcdir)/'`report/report-formatter-plain.cpp ++ ++report/powertop-report-formatter-plain.obj: report/report-formatter-plain.cpp ++@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-plain.obj -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-plain.Tpo -c -o report/powertop-report-formatter-plain.obj `if test -f 'report/report-formatter-plain.cpp'; then $(CYGPATH_W) 'report/report-formatter-plain.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-plain.cpp'; fi` ++@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-plain.Tpo report/$(DEPDIR)/powertop-report-formatter-plain.Po ++@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='report/report-formatter-palin.cpp' object='report/powertop-report-formatter-plain.obj' libtool=no @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-plain.obj `if test -f 'report/report-formatter-plain.cpp'; then $(CYGPATH_W) 'report/report-formatter-plain.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-plain.cpp'; fi` ++ + report/powertop-report-formatter-html.obj: report/report-formatter-html.cpp + @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-html.obj -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-html.Tpo -c -o report/powertop-report-formatter-html.obj `if test -f 'report/report-formatter-html.cpp'; then $(CYGPATH_W) 'report/report-formatter-html.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-html.cpp'; fi` + @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-html.Tpo report/$(DEPDIR)/powertop-report-formatter-html.Po +diff --git a/src/main.cpp b/src/main.cpp +index 7467f0f..769d593 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -84,6 +84,7 @@ static const struct option long_options[] = + {"auto-tune", no_argument, NULL, OPT_AUTO_TUNE}, + {"calibrate", no_argument, NULL, 'c'}, + {"csv", optional_argument, NULL, 'C'}, ++ {"dump", optional_argument, NULL, 'd'}, + {"debug", no_argument, &debug_learning, OPT_DEBUG}, + {"extech", optional_argument, NULL, OPT_EXTECH}, + {"html", optional_argument, NULL, 'r'}, +@@ -93,7 +94,7 @@ static const struct option long_options[] = + {"time", optional_argument, NULL, 't'}, + {"workload", optional_argument, NULL, 'w'}, + {"version", no_argument, NULL, 'V'}, +- {"help", no_argument, NULL, 'h'}, ++ {"help", no_argument, NULL, 'u'}, + {NULL, 0, NULL, 0} + }; + +@@ -122,16 +123,17 @@ static void print_usage() + printf(" --auto-tune\t %s\n", _("sets all tunable options to their GOOD setting")); + printf(" -c, --calibrate\t %s\n", _("runs powertop in calibration mode")); + printf(" -C, --csv%s\t %s\n", _("[=filename]"), _("generate a csv report")); ++ printf(" -d, --dump%s\t %s\n", _("[=filename]"), _("generate plain text report")); + printf(" --debug\t\t %s\n", _("run in \"debug\" mode")); + printf(" --extech%s\t %s\n", _("[=devnode]"), _("uses an Extech Power Analyzer for measurements")); +- printf(" -r, --html%s\t %s\n", _("[=filename]"), _("generate a html report")); ++ printf(" -r, -h, --html%s\t %s\n", _("[=filename]"), _("generate a html report")); + printf(" -i, --iteration%s\n", _("[=iterations] number of times to run each test")); + printf(" -q, --quiet\t\t %s\n", _("suppress stderr output")); + printf(" -s, --sample%s\t %s\n", _("[=seconds]"), _("interval for power consumption measurement")); + printf(" -t, --time%s\t %s\n", _("[=seconds]"), _("generate a report for 'x' seconds")); + printf(" -w, --workload%s %s\n", _("[=workload]"), _("file to execute for workload")); + printf(" -V, --version\t\t %s\n", _("print version information")); +- printf(" -h, --help\t\t %s\n", _("print this help menu")); ++ printf(" -u, --help\t\t %s\n", _("print this help menu")); + printf("\n"); + printf("%s\n\n", _("For more help please refer to the 'man 8 powertop'")); + } +@@ -441,7 +443,7 @@ int main(int argc, char **argv) + #endif + ui_notify_user = ui_notify_user_ncurses; + while (1) { /* parse commandline options */ +- c = getopt_long(argc, argv, "cC:r:i:qt:w:Vh", long_options, &option_index); ++ c = getopt_long(argc, argv, "cC::d::r::i:qt:w:uVh::", long_options, &option_index); + /* Detect the end of the options. */ + if (c == -1) + break; +@@ -471,6 +473,7 @@ int main(int argc, char **argv) + checkroot(); + extech_power_meter(optarg ? optarg : "/dev/ttyUSB0"); + break; ++ case 'h': + case 'r': /* html report */ + reporttype = REPORT_HTML; + snprintf(filename, sizeof(filename), "%s", optarg ? optarg : "powertop.html"); +@@ -480,6 +483,10 @@ int main(int argc, char **argv) + exit(1); + } + break; ++ case 'd': /* plain text report (dump) */ ++ reporttype = REPORT_PLAIN; ++ snprintf(filename, sizeof(filename), "%s", optarg ? optarg : "-"); ++ break; + case 'i': + iterations = (optarg ? atoi(optarg) : 1); + break; +@@ -500,7 +507,7 @@ int main(int argc, char **argv) + print_version(); + exit(0); + break; +- case 'h': ++ case 'u': + print_usage(); + exit(0); + break; +diff --git a/src/report/report-formatter-plain.cpp b/src/report/report-formatter-plain.cpp +new file mode 100644 +index 0000000..9a0d636 +--- /dev/null ++++ b/src/report/report-formatter-plain.cpp +@@ -0,0 +1,133 @@ ++/* Copyright (c) 2016-2018 Jaroslav Škarvada ++ * Based on CSV formatter code by Igor Zhbanov ++ * ++ * This file is part of PowerTOP ++ * ++ * This program file is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; version 2 of the License. ++ * ++ * This program is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program in a file named COPYING; if not, write to the ++ * Free Software Foundation, Inc, ++ * 51 Franklin Street, Fifth Floor, ++ * Boston, MA 02110-1301 USA ++ * or just google for it. ++ */ ++ ++#define _BSD_SOURCE ++ ++/* Uncomment to disable asserts */ ++/*#define NDEBUG*/ ++ ++#include ++#include ++#include ++ ++#include "report-formatter-plain.h" ++#include "report-data-html.h" ++ ++/* ************************************************************************ */ ++report_formatter_plain::report_formatter_plain() ++{ ++ /* Do nothing special */ ++} ++ ++/* ************************************************************************ */ ++void report_formatter_plain::finish_report() ++{ ++ /* Do nothing special */ ++} ++ ++string report_formatter_plain::escape_string(const char *str) ++{ ++ assert(str); ++ return string(str); ++} ++ ++/* Report Style */ ++void report_formatter_plain::add_header() ++{ ++} ++ ++void ++report_formatter_plain::end_header() ++{ ++ /* Do nothing */ ++} ++ ++void ++report_formatter_plain::add_logo() ++{ ++ add_exact("===PowerTOP Report===\n"); ++} ++ ++ ++void ++report_formatter_plain::add_div(struct tag_attr * div_attr) ++{ ++ add_exact("\n"); ++} ++ ++void ++report_formatter_plain::end_div() ++{ ++ /*Do nothing*/ ++} ++ ++void ++report_formatter_plain::add_title(struct tag_attr *title_att, const char *title) ++{ ++ addf_exact("==%s==\n", title); ++} ++ ++void ++report_formatter_plain::add_navigation() ++{ ++ /* No nav in plain - thinking on table of contents */ ++} ++ ++void ++report_formatter_plain::add_summary_list(string *list, int size) ++{ ++ int i; ++ add_exact("\n"); ++ for (i=0; i < size; i+=2){ ++ addf_exact("%s %s", list[i].c_str(), list[i+1].c_str()); ++ if(i < (size - 1)) ++ add_exact(" "); ++ } ++ add_exact("\n"); ++} ++ ++void ++report_formatter_plain::add_table(string *system_data, struct table_attributes* tb_attr) ++{ ++ int i, j; ++ int offset=0; ++ string tmp_str=""; ++ int empty_row=0; ++ add_exact("\n"); ++ for (i=0; i < tb_attr->rows; i++){ ++ for (j=0; j < tb_attr->cols; j++){ ++ offset = i * (tb_attr->cols) + j; ++ tmp_str=system_data[offset]; ++ ++ if(tmp_str == " ") ++ empty_row+=1; ++ else{ ++ addf_exact("%s", system_data[offset].c_str()); ++ if(j < (tb_attr->cols - 1)) ++ add_exact(" "); ++ } ++ } ++ if(empty_row < tb_attr->cols) ++ add_exact("\n"); ++ empty_row=0; ++ } ++} +diff --git a/src/report/report-formatter-plain.h b/src/report/report-formatter-plain.h +new file mode 100644 +index 0000000..276b5ac +--- /dev/null ++++ b/src/report/report-formatter-plain.h +@@ -0,0 +1,54 @@ ++/* Copyright (c) 2016-2018 Jaroslav Škarvada ++ * Based on CSV formatter code by Igor Zhbanov ++ * ++ * This file is part of PowerTOP ++ * ++ * This program file is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; version 2 of the License. ++ * ++ * This program is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program in a file named COPYING; if not, write to the ++ * Free Software Foundation, Inc, ++ * 51 Franklin Street, Fifth Floor, ++ * Boston, MA 02110-1301 USA ++ * or just google for it. ++ */ ++ ++#ifndef _REPORT_FORMATTER_PLAIN_H_ ++#define _REPORT_FORMATTER_PLAIN_H_ ++ ++#include ++ ++#include "report-formatter-base.h" ++ ++class report_formatter_plain: public report_formatter_string_base ++{ ++public: ++ report_formatter_plain(); ++ void finish_report(); ++ ++ /* Report Style */ ++ void add_logo(); ++ void add_header(); ++ void end_header(); ++ void add_div(struct tag_attr *div_attr); ++ void end_div(); ++ void add_title(struct tag_attr *title_att, const char *title); ++ void add_navigation(); ++ void add_summary_list(string *list, int size); ++ void add_table(string *system_data, struct table_attributes *tb_attr); ++ ++private: ++ void add_quotes(); ++ string escape_string(const char *str); ++ bool csv_need_quotes; ++ size_t text_start; ++}; ++ ++#endif /* _REPORT_FORMATTER_PLAIN_H_ */ +diff --git a/src/report/report-maker.cpp b/src/report/report-maker.cpp +index 4049a54..4d0932a 100644 +--- a/src/report/report-maker.cpp ++++ b/src/report/report-maker.cpp +@@ -32,6 +32,7 @@ + #include "report-maker.h" + #include "report-formatter-csv.h" + #include "report-formatter-html.h" ++#include "report-formatter-plain.h" + + /* ************************************************************************ */ + +@@ -103,6 +104,8 @@ report_maker::setup_report_formatter() + formatter = new report_formatter_html(); + else if (type == REPORT_CSV) + formatter = new report_formatter_csv(); ++ else if (type == REPORT_PLAIN) ++ formatter = new report_formatter_plain(); + else if (type == REPORT_OFF) + formatter = new report_formatter(); + else +diff --git a/src/report/report-maker.h b/src/report/report-maker.h +index bda4cef..08d2a6d 100644 +--- a/src/report/report-maker.h ++++ b/src/report/report-maker.h +@@ -65,7 +65,7 @@ using namespace std; + /* Conditional gettext. We need original strings for CSV. */ + #ifdef ENABLE_NLS + #define __(STRING) \ +- ((report.get_type() == REPORT_CSV) ? (STRING) : gettext(STRING)) ++ ((report.get_type() == REPORT_CSV || report.get_type() == REPORT_PLAIN) ? (STRING) : gettext(STRING)) + #else + #define __(STRING) (STRING) + #endif +@@ -79,7 +79,8 @@ using namespace std; + enum report_type { + REPORT_OFF, + REPORT_HTML, +- REPORT_CSV ++ REPORT_CSV, ++ REPORT_PLAIN + }; + + /* ************************************************************************ */ +diff --git a/src/report/report.cpp b/src/report/report.cpp +index f0f31ee..5fa9051 100644 +--- a/src/report/report.cpp ++++ b/src/report/report.cpp +@@ -172,30 +172,37 @@ void init_report_output(char *filename_str, int iterations) + string filename; + time_t stamp; + char datestr[200]; ++ int len; + +- if (iterations == 1) +- snprintf(reportout.filename, sizeof(reportout.filename), "%s", filename_str); ++ len = strlen(filename_str); ++ if (!len || (len == 1 && filename_str[0] == '-')) ++ reportout.report_file = stdout; + else + { +- filename = string(filename_str); +- period = filename.find_last_of("."); +- if (period > filename.length()) +- period = filename.length(); +- memset(&datestr, 0, 200); +- memset(&stamp, 0, sizeof(time_t)); +- stamp = time(NULL); +- strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp)); +- snprintf(reportout.filename, sizeof(reportout.filename), "%s-%s%s", +- filename.substr(0, period).c_str(), datestr, +- filename.substr(period).c_str()); +- } ++ if (iterations == 1) ++ snprintf(reportout.filename, sizeof(reportout.filename), "%s", filename_str); ++ else ++ { ++ filename = string(filename_str); ++ period = filename.find_last_of("."); ++ if (period > filename.length()) ++ period = filename.length(); ++ memset(&datestr, 0, 200); ++ memset(&stamp, 0, sizeof(time_t)); ++ stamp = time(NULL); ++ strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp)); ++ snprintf(reportout.filename, sizeof(reportout.filename), "%s-%s%s", ++ filename.substr(0, period).c_str(), datestr, ++ filename.substr(period).c_str()); ++ } + +- reportout.report_file = fopen(reportout.filename, "wm"); +- if (!reportout.report_file) { +- fprintf(stderr, _("Cannot open output file %s (%s)\n"), +- reportout.filename, strerror(errno)); ++ reportout.report_file = fopen(reportout.filename, "wm"); ++ if (!reportout.report_file) { ++ fprintf(stderr, _("Cannot open output file %s (%s)\n"), ++ reportout.filename, strerror(errno)); ++ } + } +- ++ + report.set_type(reporttype); + system_info(); + } +@@ -208,10 +215,14 @@ void finish_report_output(void) + report.finish_report(); + if (reportout.report_file) + { +- fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename); ++ if (reportout.report_file == stdout) ++ fprintf(stderr, _("PowerTOP outputing using standard output\n")); ++ else ++ fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename); + fputs(report.get_result(), reportout.report_file); + fdatasync(fileno(reportout.report_file)); +- fclose(reportout.report_file); ++ if (reportout.report_file != stdout) ++ fclose(reportout.report_file); + } + report.clear_result(); + } +-- +2.14.3 + diff --git a/SPECS/powertop.spec b/SPECS/powertop.spec index d42ebc5..ba46a5b 100644 --- a/SPECS/powertop.spec +++ b/SPECS/powertop.spec @@ -1,66 +1,46 @@ Name: powertop -Version: 2.3 -Release: 12%{?dist} +Version: 2.9 +Release: 1%{?dist} Summary: Power consumption monitor Group: Applications/System License: GPLv2 URL: http://01.org/powertop/ -Source0: http://01.org/powertop/sites/default/files/downloads/%{name}-%{version}.tar.gz +Source0: http://01.org/sites/default/files/downloads/powertop/%{name}-v%{version}.tar.gz Source1: powertop.service # Sent upstream -Patch0: powertop-2.3-always-create-params.patch -# Sent upstream (http://github.com/fenrus75/powertop/pull/11) -Patch1: powertop-2.3-man-fix.patch -# Sent upstream (http://github.com/fenrus75/powertop/pull/12) -Patch2: powertop-2.3-ondemand-check.patch -# Accepted upstream -Patch3: powertop-2.3-unlimit-fds.patch -# Accepted upstream -Patch4: powertop-2.3-fd-limit-err.patch -# Sent upstream -Patch5: powertop-2.3-reg-net-params.patch -Patch6: powertop-2.3-tunable-overflow-fix.patch -# Reported upstream, but upstream powertop needs different patch -Patch7: powertop-2.3-msr-check.patch -# Backported from upstream -Patch8: powertop-2.3-auto-tune.patch -# Sent upstream -Patch9: powertop-2.3-improve-reporting.patch -# Sent upstream (https://github.com/fenrus75/powertop/pull/22) -# RHEL patch has slightly different default behavior not to break -# backward compatibility, i.e. it writes by default to powertop.html/csv file. -# It can write to STDOUT if "-" is used as filename., but the -d, --dump writes -# by default to STDOUT if no filename is given -Patch10: powertop-2.3-dump-option.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: gettext, ncurses-devel, pciutils-devel, zlib-devel, libnl3-devel -BuildRequires: systemd -Requires(post): systemd, coreutils -Requires(preun): systemd +Patch0: powertop-2.7-always-create-params.patch +Patch1: powertop-2.9-cstates-rewrite-fix.patch +Patch2: powertop-2.9-intel-glk-support.patch +Patch3: powertop-2.9-intel-cnluy-support.patch +Patch4: powertop-2.9-intel-cpu-check-aperf.patch +Patch5: powertop-2.9-powertop-2.3-compat.patch +BuildRequires: gettext-devel, ncurses-devel, pciutils-devel, zlib-devel, libnl3-devel +BuildRequires: systemd +BuildRequires: gcc, gcc-c++ +Requires(post): systemd, coreutils +Requires(preun): systemd Requires(postun): systemd +Provides: bundled(kernel-event-lib) %description PowerTOP is a tool that finds the software component(s) that make your computer use more power than necessary while it is idle. %prep -%setup -q +%setup -q -n %{name}-v%{version} %patch0 -p1 -b .always-create-params -%patch1 -p1 -b .man-fix -%patch2 -p1 -b .ondemand-check -%patch3 -p1 -b .unlimit-fds -%patch4 -p1 -b .fd-limit-err -%patch5 -p1 -b .reg-net-params -%patch6 -p1 -b .tunable-overflow-fix.patch -%patch7 -p1 -b .msr-check -%patch8 -p1 -b .auto-tune -%patch9 -p1 -b .improve-reporting -%patch10 -p1 -b .dump-option - -# remove left over object files -find . -name "*.o" -exec rm {} \; +# https://github.com/fenrus75/powertop/commit/f3f350f138912dc89abb37676f7e65fc6057ec53 +%patch1 -p1 -b .cstates-rewrite-fix +# https://github.com/fenrus75/powertop/commit/523b15bd892f036bb6b777ad6c88f334f0980347 +%patch2 -p1 -b .intel-glk-support +# https://github.com/fenrus75/powertop/commit/0d3a1cda2a95484fa41cc4c35294a4153b3a5e97 +%patch3 -p1 -b .intel-cnluy-support +# sent upstream +%patch4 -p1 -b .intel-cpu-check-aperf +# compatibility patch keeping consistent behavior with powertop-2.3 +%patch5 -p1 -b .powertop-2.3-compat %build %configure @@ -85,10 +65,7 @@ install -Dpm 644 %{SOURCE1} %{buildroot}%{_unitdir}/powertop.service %post %systemd_post powertop.service # Hack for powertop not to show warnings on first start -touch %{_localstatedir}/cache/powertop/{saved_parameters.powertop,saved_results.powertop} - -%clean -rm -rf %{buildroot} +touch %{_localstatedir}/cache/powertop/{saved_parameters.powertop,saved_results.powertop} &> /dev/null || : %files -f %{name}.lang %defattr(-,root,root,-) @@ -101,6 +78,12 @@ rm -rf %{buildroot} %{_unitdir}/powertop.service %changelog +* Fri May 4 2018 Jaroslav Škarvada - 2.9-1 +- New version + Resolves: rhbz#1515645 +- Added support for Intel CNL-U/Y + Resolves: rhbz#1464918 + * Tue Mar 21 2017 Jaroslav Škarvada - 2.3-12 - Fixed auto-tuning Resolves: rhbz#1392438