From 4d24b878b22133dcf02ae63dc02ffffa20f9122b Mon Sep 17 00:00:00 2001 From: CentOS Buildsys Date: Oct 29 2013 09:50:24 +0000 Subject: import powertop-2.3-5.el7.src.rpm --- diff --git a/.powertop.metadata b/.powertop.metadata new file mode 100644 index 0000000..ed72933 --- /dev/null +++ b/.powertop.metadata @@ -0,0 +1 @@ +0bb26b38a87f45cdb61acc8dc233e4391220c8b4 SOURCES/powertop-2.3.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/powertop-2.3-always-create-params.patch b/SOURCES/powertop-2.3-always-create-params.patch new file mode 100644 index 0000000..044bb71 --- /dev/null +++ b/SOURCES/powertop-2.3-always-create-params.patch @@ -0,0 +1,35 @@ +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-fd-limit-err.patch b/SOURCES/powertop-2.3-fd-limit-err.patch new file mode 100644 index 0000000..d517e94 --- /dev/null +++ b/SOURCES/powertop-2.3-fd-limit-err.patch @@ -0,0 +1,38 @@ +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-man-fix.patch b/SOURCES/powertop-2.3-man-fix.patch new file mode 100644 index 0000000..18ed664 --- /dev/null +++ b/SOURCES/powertop-2.3-man-fix.patch @@ -0,0 +1,13 @@ +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-ondemand-check.patch b/SOURCES/powertop-2.3-ondemand-check.patch new file mode 100644 index 0000000..faba75f --- /dev/null +++ b/SOURCES/powertop-2.3-ondemand-check.patch @@ -0,0 +1,42 @@ +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 new file mode 100644 index 0000000..12ea77e --- /dev/null +++ b/SOURCES/powertop-2.3-reg-net-params.patch @@ -0,0 +1,33 @@ +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-unlimit-fds.patch b/SOURCES/powertop-2.3-unlimit-fds.patch new file mode 100644 index 0000000..b98b10b --- /dev/null +++ b/SOURCES/powertop-2.3-unlimit-fds.patch @@ -0,0 +1,65 @@ +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/SPECS/powertop.spec b/SPECS/powertop.spec new file mode 100644 index 0000000..86e96f2 --- /dev/null +++ b/SPECS/powertop.spec @@ -0,0 +1,274 @@ +Name: powertop +Version: 2.3 +Release: 5%{?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 + +# 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 +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: gettext, ncurses-devel, pciutils-devel, zlib-devel, libnl3-devel +Requires(post): coreutils + +%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 +%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 + +# remove left over object files +find . -name "*.o" -exec rm {} \; + +%build +%configure +make %{?_smp_mflags} CFLAGS="%{optflags}" + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} +install -Dd %{buildroot}%{_localstatedir}/cache/powertop +touch %{buildroot}%{_localstatedir}/cache/powertop/{saved_parameters.powertop,saved_results.powertop} +%find_lang %{name} + +%post +# Hack for powertop not to show warnings on first start +touch %{_localstatedir}/cache/powertop/{saved_parameters.powertop,saved_results.powertop} + +%clean +rm -rf %{buildroot} + +%files -f %{name}.lang +%defattr(-,root,root,-) +%doc COPYING README TODO +%dir %{_localstatedir}/cache/powertop +%ghost %{_localstatedir}/cache/powertop/saved_parameters.powertop +%ghost %{_localstatedir}/cache/powertop/saved_results.powertop +%{_sbindir}/powertop +%{_mandir}/man8/powertop.8* + +%changelog +* Tue Oct 29 2013 Jaroslav Škarvada - 2.3-5 +- Fixed some possible unregistered parameters errors + (by reg-net-param patch) + Resolves: rhbz#1014662 +- Unlimit FDs (by unlimit-fds patch) + Printed friendly error message if the system is running out + of FDs (by fd-limit-err patch) + Resolves: rhbz#1017668 + +* Fri Jun 28 2013 Jaroslav Škarvada - 2.3-4 +- Added check if ondemand governor is applicable (by ondemand-check patch) + Resolves: rhbz#697273 + +* Tue Jun 25 2013 Jaroslav Škarvada - 2.3-3 +- Added workload option to the man page + +* Wed Apr 10 2013 Jaroslav Škarvada - 2.3-2 +- Added post requirements for coreutils + +* Wed Mar 20 2013 Jaroslav Škarvada - 2.3-1 +- New version + Resolves: rhbz#923729 +- Dropped fix-crash-on-readonly-fs, reduce-syscalls, + gpu-wiggle-fix patches (upstreamed) +- Dropped version-fix patch (not needed) + +* Thu Feb 14 2013 Fedora Release Engineering - 2.2-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Sun Jan 20 2013 Dan Horák - 2.2-6 +- rebuilt again for fixed soname in libnl3 + +* Sun Jan 20 2013 Kalev Lember - 2.2-5 +- Rebuilt for libnl3 + +* Mon Jan 14 2013 Jaroslav Škarvada - 2.2-4 +- Reduced number of useless syscalls (reduce-syscalls patch) and + fixed gpu wiggle (gpu-wiggle-fix patch) + Resolves: rhbz#886185 + +* Sun Dec 2 2012 Jaroslav Škarvada - 2.2-3 +- Updated version to show 2.2 (by version-fix patch) + +* Wed Nov 28 2012 Jaroslav Škarvada - 2.2-2 +- Fixed crash when writing report on readonly filesystem + (fix-crash-on-readonly-fs patch) + +* Fri Nov 23 2012 Jaroslav Škarvada - 2.2-1 +- New version + Resolves: rhbz#877373 +- Dropped html-escape patch (not needed) + +* Thu Aug 16 2012 Jaroslav Škarvada - 2.1-2 +- Removed left over object files + +* Thu Aug 16 2012 Jaroslav Škarvada - 2.1-1 +- New version +- Removed patches (all upstreamed): show-watts-only-if-discharging, + valid-html-output, factor-out-powertop-init, catch-fstream-errors + +* Sat Jul 21 2012 Fedora Release Engineering - 2.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Wed Jul 4 2012 Jaroslav Škarvada - 2.0-3 +- Catch fstream exceptions + Resolves: rhbz#832497 + +* Mon May 21 2012 Jaroslav Škarvada - 2.0-2 +- Fixed segfault during calibration + Resolves: rhbz#823502 +- Used macro optflags instead of variable RPM_OPT_FLAGS + +* Wed May 16 2012 Jaroslav Škarvada - 2.0-1 +- New version + Resolves: rhbz#821144 +- Dropped patches: unknown-readings-fix (upstreamed), compile-fix (upstreamed), + power-supply-add-power-now-support (upstreamed), + html-print-commands (upstreamed), add-power-supply-class-support (obsoleted), + power-supply-units-fix (obsoleted) +- Updated patches: show-watts-only-if-discharging patch (sent upstream), + html-escape patch +- Added patch: valid-html-output (sent upstream) + +* Tue Apr 17 2012 Jaroslav Škarvada - 1.98-9 +- Show power consumption only if discharging + Resolves: rhbz#811949 + +* Tue Apr 03 2012 Jan Kaluza - 1.98-8 +- Escape scripts in HTML output + +* Mon Mar 26 2012 Jaroslav Škarvada - 1.98-7 +- Print commands which reproduce the tunings into html log (html-print-commands patch) + +* Wed Mar 7 2012 Jaroslav Škarvada - 1.98-6 +- Fixed power_supply units + Resolves: rhbz#800814 + +* Tue Feb 28 2012 Fedora Release Engineering - 1.98-5 +- Rebuilt for c++ ABI breakage + +* Fri Feb 24 2012 Jaroslav Škarvada - 1.98-4 +- Backported support for power_supply class + (add-power-supply-class-support patch) +- Added support for POWER_NOW readings + (power-supply-add-power-now-support patch) + Resolves: rhbz#796068 + +* Tue Jan 10 2012 Jaroslav Škarvada - 1.98-3 +- Fixed 'unknown' readings from ACPI meters + Resolves: rhbz#770289 +- Fixed compilation on f17 + +* Fri Dec 2 2011 Jaroslav Škarvada - 1.98-2 +- Always create params file + Resolves: rhbz#698020 +- Added cache files + +* Wed May 25 2011 Jaroslav Škarvada - 1.98-1 +- New version + +* Wed Mar 23 2011 Dan Horák - 1.97-2 +- csstoh should return 0 + +* Tue Feb 15 2011 Jaroslav Škarvada - 1.97-1 +- New version + +* Wed Feb 09 2011 Fedora Release Engineering - 1.13-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Wed Nov 24 2010 Jaroslav Škarvada - 1.13-2 +- Fixed sigwinch handling (#644800) +- Readded strncpy patch as strncpy is safer than strcpy +- Print all P-states in dump mode +- Added explicit requires for pcituils (#653560) +- Output error in interactive mode if there is no tty (#657212) +- Do not suggest ondemand when p4-clockmod scaling driver is used (#497167) +- Fixed rpmlint warning about mixed tabs and spaces + +* Wed Aug 25 2010 Adam Jackson 1.13-1 +- powertop 1.13 + +* Sun Jul 26 2009 Fedora Release Engineering - 1.11-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu Feb 26 2009 Fedora Release Engineering - 1.11-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Tue Jan 06 2009 Adam Jackson 1.11-1 +- powertop 1.11 + +* Thu Nov 20 2008 Adam Jackson +- Spec only change, fix URL. + +* Thu Nov 6 2008 Josh Boyer - 1.10-1 +- Update to latest release +- Drop upstreamed patch + +* Wed May 21 2008 Tom "spot" Callaway - 1.9-4 +- fix license tag + +* Mon Feb 18 2008 Fedora Release Engineering - 1.9-3 +- Autorebuild for GCC 4.3 + +* Tue Jan 22 2008 Adam Jackson 1.9-2 +- Use full path when invoking hciconfig. (Ville Skyttä, #426721) + +* Mon Dec 10 2007 Josh Boyer 1.9-1 +- Update to latest release + +* Mon Aug 20 2007 Josh Boyer 1.8-1 +- Update to latest release + +* Mon Jul 23 2007 Bill Nottingham 1.7-4 +- add patch to allow dumping output to stdout + +* Mon Jul 09 2007 Adam Jackson 1.7-3 +- powertop-1.7-strncpy.patch: Use strncpy() to avoid stack smash. Patch from + Till Maas. (#246796) + +* Thu Jul 05 2007 Adam Jackson 1.7-2 +- Don't suggest disabling g-p-m. Any additional power consumption is more + than offset by the ability to suspend. + +* Mon Jun 18 2007 Adam Jackson 1.7-1 +- powertop 1.7. + +* Mon Jun 11 2007 Adam Jackson 1.6-1 +- powertop 1.6. + +* Tue May 29 2007 Adam Jackson 1.5-1 +- powertop 1.5. + +* Mon May 21 2007 Adam Jackson 1.3-1 +- powertop 1.3. + +* Tue May 15 2007 Adam Jackson 1.2-1 +- powertop 1.2. Fixes power reports on machines that report power in Amperes + instead of Watts. + +* Sun May 13 2007 Adam Jackson 1.1-1 +- powertop 1.1. + +* Fri May 11 2007 Adam Jackson 1.0-1 +- Initial revision.