Skip to content

Commit

Permalink
cpupower: If root, try to load msr driver on x86 if /dev/cpu/0/msr is…
Browse files Browse the repository at this point in the history
… not available

Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Thomas Renninger authored and Rafael J. Wysocki committed May 16, 2014
1 parent 84baab9 commit 8a19cb5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/power/cpupower/utils/cpupower.c
Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utsname.h>

#include "builtin.h"
#include "helpers/helpers.h"
@@ -169,6 +172,8 @@ int main(int argc, const char *argv[])
{
const char *cmd;
unsigned int i, ret;
struct stat statbuf;
struct utsname uts;

cpus_chosen = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));

@@ -195,6 +200,15 @@ int main(int argc, const char *argv[])

get_cpu_info(0, &cpupower_cpu_info);
run_as_root = !getuid();
if (run_as_root) {
ret = uname(&uts);
if (!ret && !strcmp(uts.machine, "x86_64") &&
stat("/dev/cpu/0/msr", &statbuf) != 0) {
if (system("modprobe msr") == -1)
fprintf(stderr, _("MSR access not available.\n"));
}
}


for (i = 0; i < ARRAY_SIZE(commands); i++) {
struct cmd_struct *p = commands + i;

0 comments on commit 8a19cb5

Please sign in to comment.