When invald MSR's are specified on the command line,
turbostat should simply print an error and exit.
Signed-off-by: Len Brown <len.brown@intel.com>
retval = pread(fd, msr, sizeof *msr, offset);
close(fd);
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);
restart:
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
restart:
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
+ if (retval < -1) {
+ exit(retval);
+ } else if (retval == -1) {
re_initialize();
goto restart;
}
re_initialize();
goto restart;
}
}
sleep(interval_sec);
retval = for_all_cpus(get_counters, ODD_COUNTERS);
}
sleep(interval_sec);
retval = for_all_cpus(get_counters, ODD_COUNTERS);
+ if (retval < -1) {
+ exit(retval);
+ } else if (retval == -1) {
re_initialize();
goto restart;
}
re_initialize();
goto restart;
}
flush_stdout();
sleep(interval_sec);
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
flush_stdout();
sleep(interval_sec);
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
+ if (retval < -1) {
+ exit(retval);
+ } else if (retval == -1) {
re_initialize();
goto restart;
}
re_initialize();
goto restart;
}
int fork_it(char **argv)
{
pid_t child_pid;
int fork_it(char **argv)
{
pid_t child_pid;
- 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);
/* clear affinity side-effect of get_counters() */
sched_setaffinity(0, cpu_present_setsize, cpu_present_set);
gettimeofday(&tv_even, (struct timezone *)NULL);
/* child */
execvp(argv[0], argv);
} else {
/* child */
execvp(argv[0], argv);
} else {
/* parent */
if (child_pid == -1) {
/* parent */
if (child_pid == -1) {
signal(SIGQUIT, SIG_IGN);
if (waitpid(child_pid, &status, 0) == -1) {
perror("wait");
signal(SIGQUIT, SIG_IGN);
if (waitpid(child_pid, &status, 0) == -1) {
perror("wait");
fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0);
fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0);
}
void cmdline(int argc, char **argv)
}
void cmdline(int argc, char **argv)