This patch adds a simple check whether powertop can access
/sys/kernel/debug/tracing/events, if not it is very likely that
CONFIG_TRACEPOINTS is not set in the kernel, so we print this
information out to the user.
Unfortunately the logic in perf/perf.cpp does not catch this properly.

To simplify translation, the same error message as in perf.cpp was used.

Signed-off-by: Peter Huewe <[email protected]>
---
 main.cpp |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/main.cpp b/main.cpp
index 7861c37..ad2e803 100644
--- a/main.cpp
+++ b/main.cpp
@@ -264,6 +264,13 @@ int main(int argc, char **argv)
        system("/sbin/modprobe msr > /dev/null 2>&1");
        system("/bin/mount -t debugfs debugfs /sys/kernel/debug > /dev/null 
2>&1");
 
+       if (access("/sys/kernel/debug/tracing/events", R_OK) < 0) {
+               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_TRACEPOINTS=y\nCONFIG_TRACING=y\n");
+               exit(EXIT_FAILURE);
+       }
+
        srand(time(NULL));
 
        mkdir("/var/cache/powertop", 0600);
-- 
1.7.3.4

_______________________________________________
Power mailing list
[email protected]
https://bughost.org/mailman/listinfo/power

Reply via email to