aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2015-03-24 16:37:35 -0400
committerLen Brown <len.brown@intel.com>2015-04-18 14:20:51 -0400
commita21d38c846fce05ef55ab240f18fb19755bed16a (patch)
tree994b93a6ba3b49cdd435c2058938f0d3ba6ad0c2 /tools
parentfcd17211bd807533f6d4be20b1a4644e9191bfe2 (diff)
tools/power turbostat: modprobe msr, if needed
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/x86/turbostat/turbostat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index f05a3f7b5d4c..50341a322cb8 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1528,7 +1528,8 @@ void check_dev_msr()
1528 struct stat sb; 1528 struct stat sb;
1529 1529
1530 if (stat("/dev/cpu/0/msr", &sb)) 1530 if (stat("/dev/cpu/0/msr", &sb))
1531 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); 1531 if (system("/sbin/modprobe msr > /dev/null 2>&1"))
1532 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" ");
1532} 1533}
1533 1534
1534void check_permissions() 1535void check_permissions()
@@ -2713,7 +2714,7 @@ int get_and_dump_counters(void)
2713} 2714}
2714 2715
2715void print_version() { 2716void print_version() {
2716 fprintf(stderr, "turbostat version 4.2 23 Mar, 2015" 2717 fprintf(stderr, "turbostat version 4.3 24 Mar, 2015"
2717 " - Len Brown <lenb@kernel.org>\n"); 2718 " - Len Brown <lenb@kernel.org>\n");
2718} 2719}
2719 2720