[powertop] Printed friendly error message if the system is running out

Jaroslav Škarvada jskarvad at fedoraproject.org
Thu Sep 19 15:53:06 UTC 2013


commit c68c6110a4ded93d8660cefe087808e8f030298e
Author: Jaroslav Škarvada <jskarvad at redhat.com>
Date:   Thu Sep 19 17:52:55 2013 +0200

    Printed friendly error message if the system is running out
    
      of FDs (by fd-limit-err patch)

 powertop-2.4-fd-limit-err.patch |   38 ++++++++++++++++++++++++++++++++++++++
 powertop.spec                   |    9 ++++++++-
 2 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/powertop-2.4-fd-limit-err.patch b/powertop-2.4-fd-limit-err.patch
new file mode 100644
index 0000000..d517e94
--- /dev/null
+++ b/powertop-2.4-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 <iostream>
+ #include <fstream>
+ 
++#include <errno.h>
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -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/powertop.spec b/powertop.spec
index 1629155..c569d27 100644
--- a/powertop.spec
+++ b/powertop.spec
@@ -1,6 +1,6 @@
 Name:           powertop
 Version:        2.4
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Power consumption monitor
 
 Group:          Applications/System
@@ -14,6 +14,8 @@ Patch0:         powertop-2.3-always-create-params.patch
 Patch1:         powertop-2.3-man-fix.patch
 # Sent upstream (http://github.com/fenrus75/powertop/pull/12)
 Patch2:         powertop-2.3-ondemand-check.patch
+# Sent upstream (http://github.com/fenrus75/powertop/pull/14)
+Patch3:         powertop-2.4-fd-limit-err.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:  gettext, ncurses-devel, pciutils-devel, zlib-devel, libnl3-devel
 Requires(post): coreutils
@@ -27,6 +29,7 @@ computer use more power than necessary while it is idle.
 %patch0 -p1 -b .always-create-params
 %patch1 -p1 -b .man-fix
 %patch2 -p1 -b .ondemand-check
+%patch3 -p1 -b .fd-limit-err
 
 # remove left over object files
 find . -name "*.o" -exec rm {} \;
@@ -59,6 +62,10 @@ rm -rf %{buildroot}
 %{_mandir}/man8/powertop.8*
 
 %changelog
+* Thu Sep 19 2013 Jaroslav Škarvada <jskarvad at redhat.com> - 2.4-3
+- Printed friendly error message if the system is running out
+  of FDs (by fd-limit-err patch)
+
 * Sun Aug 04 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.4-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 


More information about the scm-commits mailing list