Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 335628
b: refs/heads/master
c: d91bb17
h: refs/heads/master
v: v3
  • Loading branch information
Len Brown committed Nov 1, 2012
1 parent 4d508dc commit 2bed822
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 39300ffb9b6666714c60735cf854e1280e4e75f4
refs/heads/master: d91bb17c2a874493603c4d99db305d8caf2d180c
26 changes: 18 additions & 8 deletions trunk/tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
retval = pread(fd, msr, sizeof *msr, offset);
close(fd);

if (retval != sizeof *msr)
if (retval != sizeof *msr) {
fprintf(stderr, "%s offset 0x%zx read failed\n", pathname, offset);
return -1;
}

return 0;
}
Expand Down Expand Up @@ -1101,7 +1103,9 @@ void turbostat_loop()

restart:
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
if (retval) {
if (retval < -1) {
exit(retval);
} else if (retval == -1) {
re_initialize();
goto restart;
}
Expand All @@ -1114,7 +1118,9 @@ void turbostat_loop()
}
sleep(interval_sec);
retval = for_all_cpus(get_counters, ODD_COUNTERS);
if (retval) {
if (retval < -1) {
exit(retval);
} else if (retval == -1) {
re_initialize();
goto restart;
}
Expand All @@ -1126,7 +1132,9 @@ void turbostat_loop()
flush_stdout();
sleep(interval_sec);
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
if (retval) {
if (retval < -1) {
exit(retval);
} else if (retval == -1) {
re_initialize();
goto restart;
}
Expand Down Expand Up @@ -1545,8 +1553,11 @@ void turbostat_init()
int fork_it(char **argv)
{
pid_t child_pid;
int status;

for_all_cpus(get_counters, EVEN_COUNTERS);
status = for_all_cpus(get_counters, EVEN_COUNTERS);
if (status)
exit(status);
/* clear affinity side-effect of get_counters() */
sched_setaffinity(0, cpu_present_setsize, cpu_present_set);
gettimeofday(&tv_even, (struct timezone *)NULL);
Expand All @@ -1556,7 +1567,6 @@ int fork_it(char **argv)
/* child */
execvp(argv[0], argv);
} else {
int status;

/* parent */
if (child_pid == -1) {
Expand All @@ -1568,7 +1578,7 @@ int fork_it(char **argv)
signal(SIGQUIT, SIG_IGN);
if (waitpid(child_pid, &status, 0) == -1) {
perror("wait");
exit(1);
exit(status);
}
}
/*
Expand All @@ -1585,7 +1595,7 @@ int fork_it(char **argv)

fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0);

return 0;
return status;
}

void cmdline(int argc, char **argv)
Expand Down

0 comments on commit 2bed822

Please sign in to comment.