diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-14 16:46:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-14 16:46:40 -0500 |
commit | 79e979eae0df58831e85281e3285f63663f3cf76 (patch) | |
tree | 03263ca6cd0709763be0461202a46dd7f73fa3c4 /tools | |
parent | f0c391131a6483004791458f181d2a6f6ffb1c11 (diff) | |
parent | d91bb17c2a874493603c4d99db305d8caf2d180c (diff) |
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull power tools fixes from Len Brown:
"A pair of power tools patches -- a 3.7 regression fix plus a bug fix."
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
tools/power turbostat: graceful fail on garbage input
tools/power turbostat: Repair Segmentation fault when using -i option
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 2655ae9a3ad8..ea095abbe97e 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -206,8 +206,10 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr) | |||
206 | retval = pread(fd, msr, sizeof *msr, offset); | 206 | retval = pread(fd, msr, sizeof *msr, offset); |
207 | close(fd); | 207 | close(fd); |
208 | 208 | ||
209 | if (retval != sizeof *msr) | 209 | if (retval != sizeof *msr) { |
210 | fprintf(stderr, "%s offset 0x%zx read failed\n", pathname, offset); | ||
210 | return -1; | 211 | return -1; |
212 | } | ||
211 | 213 | ||
212 | return 0; | 214 | return 0; |
213 | } | 215 | } |
@@ -1101,7 +1103,9 @@ void turbostat_loop() | |||
1101 | 1103 | ||
1102 | restart: | 1104 | restart: |
1103 | retval = for_all_cpus(get_counters, EVEN_COUNTERS); | 1105 | retval = for_all_cpus(get_counters, EVEN_COUNTERS); |
1104 | if (retval) { | 1106 | if (retval < -1) { |
1107 | exit(retval); | ||
1108 | } else if (retval == -1) { | ||
1105 | re_initialize(); | 1109 | re_initialize(); |
1106 | goto restart; | 1110 | goto restart; |
1107 | } | 1111 | } |
@@ -1114,7 +1118,9 @@ restart: | |||
1114 | } | 1118 | } |
1115 | sleep(interval_sec); | 1119 | sleep(interval_sec); |
1116 | retval = for_all_cpus(get_counters, ODD_COUNTERS); | 1120 | retval = for_all_cpus(get_counters, ODD_COUNTERS); |
1117 | if (retval) { | 1121 | if (retval < -1) { |
1122 | exit(retval); | ||
1123 | } else if (retval == -1) { | ||
1118 | re_initialize(); | 1124 | re_initialize(); |
1119 | goto restart; | 1125 | goto restart; |
1120 | } | 1126 | } |
@@ -1126,7 +1132,9 @@ restart: | |||
1126 | flush_stdout(); | 1132 | flush_stdout(); |
1127 | sleep(interval_sec); | 1133 | sleep(interval_sec); |
1128 | retval = for_all_cpus(get_counters, EVEN_COUNTERS); | 1134 | retval = for_all_cpus(get_counters, EVEN_COUNTERS); |
1129 | if (retval) { | 1135 | if (retval < -1) { |
1136 | exit(retval); | ||
1137 | } else if (retval == -1) { | ||
1130 | re_initialize(); | 1138 | re_initialize(); |
1131 | goto restart; | 1139 | goto restart; |
1132 | } | 1140 | } |
@@ -1545,8 +1553,11 @@ void turbostat_init() | |||
1545 | int fork_it(char **argv) | 1553 | int fork_it(char **argv) |
1546 | { | 1554 | { |
1547 | pid_t child_pid; | 1555 | pid_t child_pid; |
1556 | int status; | ||
1548 | 1557 | ||
1549 | for_all_cpus(get_counters, EVEN_COUNTERS); | 1558 | status = for_all_cpus(get_counters, EVEN_COUNTERS); |
1559 | if (status) | ||
1560 | exit(status); | ||
1550 | /* clear affinity side-effect of get_counters() */ | 1561 | /* clear affinity side-effect of get_counters() */ |
1551 | sched_setaffinity(0, cpu_present_setsize, cpu_present_set); | 1562 | sched_setaffinity(0, cpu_present_setsize, cpu_present_set); |
1552 | gettimeofday(&tv_even, (struct timezone *)NULL); | 1563 | gettimeofday(&tv_even, (struct timezone *)NULL); |
@@ -1556,7 +1567,6 @@ int fork_it(char **argv) | |||
1556 | /* child */ | 1567 | /* child */ |
1557 | execvp(argv[0], argv); | 1568 | execvp(argv[0], argv); |
1558 | } else { | 1569 | } else { |
1559 | int status; | ||
1560 | 1570 | ||
1561 | /* parent */ | 1571 | /* parent */ |
1562 | if (child_pid == -1) { | 1572 | if (child_pid == -1) { |
@@ -1568,7 +1578,7 @@ int fork_it(char **argv) | |||
1568 | signal(SIGQUIT, SIG_IGN); | 1578 | signal(SIGQUIT, SIG_IGN); |
1569 | if (waitpid(child_pid, &status, 0) == -1) { | 1579 | if (waitpid(child_pid, &status, 0) == -1) { |
1570 | perror("wait"); | 1580 | perror("wait"); |
1571 | exit(1); | 1581 | exit(status); |
1572 | } | 1582 | } |
1573 | } | 1583 | } |
1574 | /* | 1584 | /* |
@@ -1585,7 +1595,7 @@ int fork_it(char **argv) | |||
1585 | 1595 | ||
1586 | fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0); | 1596 | fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0); |
1587 | 1597 | ||
1588 | return 0; | 1598 | return status; |
1589 | } | 1599 | } |
1590 | 1600 | ||
1591 | void cmdline(int argc, char **argv) | 1601 | void cmdline(int argc, char **argv) |
@@ -1594,7 +1604,7 @@ void cmdline(int argc, char **argv) | |||
1594 | 1604 | ||
1595 | progname = argv[0]; | 1605 | progname = argv[0]; |
1596 | 1606 | ||
1597 | while ((opt = getopt(argc, argv, "+pPSvisc:sC:m:M:")) != -1) { | 1607 | while ((opt = getopt(argc, argv, "+pPSvi:sc:sC:m:M:")) != -1) { |
1598 | switch (opt) { | 1608 | switch (opt) { |
1599 | case 'p': | 1609 | case 'p': |
1600 | show_core_only++; | 1610 | show_core_only++; |