]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tools/power turbostat: modprobe msr, if needed
authorLen Brown <len.brown@intel.com>
Tue, 24 Mar 2015 20:37:35 +0000 (16:37 -0400)
committerLen Brown <len.brown@intel.com>
Sat, 18 Apr 2015 18:20:51 +0000 (14:20 -0400)
Some distros (Ubuntu) ship the msr driver as a module.
If turbosat is run as root on those systems, and discovers
that there is no /dev/cpu/cpu0/msr, it will now "modprobe msr"
for the user.

If not root, the modprobe attempt will fail, and turbostat will exit as before:

turbostat: no /dev/cpu/0/msr, Try "# modprobe msr" : No such file or directory

Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/turbostat.c

index f05a3f7b5d4c0586d3052842f728fdb370fee96b..50341a322cb8ef984f370e6bc55c0d1620cdda5b 100644 (file)
@@ -1528,7 +1528,8 @@ void check_dev_msr()
        struct stat sb;
 
        if (stat("/dev/cpu/0/msr", &sb))
-               err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" ");
+               if (system("/sbin/modprobe msr > /dev/null 2>&1"))
+                       err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" ");
 }
 
 void check_permissions()
@@ -2713,7 +2714,7 @@ int get_and_dump_counters(void)
 }
 
 void print_version() {
-       fprintf(stderr, "turbostat version 4.2 23 Mar, 2015"
+       fprintf(stderr, "turbostat version 4.3 24 Mar, 2015"
                " - Len Brown <lenb@kernel.org>\n");
 }