diff options
| author | Cyril Bur <cyrilbur@gmail.com> | 2016-02-29 23:26:36 -0500 |
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-07-05 09:49:49 -0400 |
| commit | d4ecdff2ecdb5c01c46f2a6b1bf3f161279b330e (patch) | |
| tree | b905b4e18e9e7241e0a7114bb162bccf58c571c1 /tools/testing | |
| parent | f1fb60bfde65fe4c4372d480d1b5d57bdba20367 (diff) | |
selftests/powerpc/pmu: Use signed long to read perf_event_paranoid
Excerpt from man 2 perf_event_open:
/proc/sys/kernel/perf_event_paranoid
The perf_event_paranoid file can be set to restrict access to the
performance counters.
2 allow only user-space measurements.
1 allow both kernel and user measurements (default).
0 allow access to CPU-specific data but not raw tracepoint samples.
-1 no restrictions.
require_paranoia_below() should return 0 if perf_event_paranoid is below
a specified level, the value from perf_event_paranoid is read into an
unsigned long so the incorrect value is returned when
perf_event_paranoid is set to -1.
Without this patch applied there is the same number of selftests/powerpc
which skip when /proc/sys/kernel/perf_event_paranoid is set to 1 or -1
but no skips when set to zero.
With this patch applied there are no skipped selftests/powerpc test when
/proc/sys/kernel/perf_event_paranoid is set to 0 or -1.
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/powerpc/pmu/lib.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/testing/selftests/powerpc/pmu/lib.c b/tools/testing/selftests/powerpc/pmu/lib.c index a361ad3334ce..8b992fa5b478 100644 --- a/tools/testing/selftests/powerpc/pmu/lib.c +++ b/tools/testing/selftests/powerpc/pmu/lib.c | |||
| @@ -190,7 +190,7 @@ int parse_proc_maps(void) | |||
| 190 | 190 | ||
| 191 | bool require_paranoia_below(int level) | 191 | bool require_paranoia_below(int level) |
| 192 | { | 192 | { |
| 193 | unsigned long current; | 193 | long current; |
| 194 | char *end, buf[16]; | 194 | char *end, buf[16]; |
| 195 | FILE *f; | 195 | FILE *f; |
| 196 | int rc; | 196 | int rc; |
| @@ -208,7 +208,7 @@ bool require_paranoia_below(int level) | |||
| 208 | goto out_close; | 208 | goto out_close; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | current = strtoul(buf, &end, 10); | 211 | current = strtol(buf, &end, 10); |
| 212 | 212 | ||
| 213 | if (end == buf) { | 213 | if (end == buf) { |
| 214 | printf("Couldn't parse " PARANOID_PATH "?\n"); | 214 | printf("Couldn't parse " PARANOID_PATH "?\n"); |
| @@ -216,7 +216,7 @@ bool require_paranoia_below(int level) | |||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | if (current >= level) | 218 | if (current >= level) |
| 219 | goto out; | 219 | goto out_close; |
| 220 | 220 | ||
| 221 | rc = 0; | 221 | rc = 0; |
| 222 | out_close: | 222 | out_close: |
