提交 d4ecdff2 编写于 作者: C Cyril Bur 提交者: Michael Ellerman

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: NCyril Bur <cyrilbur@gmail.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
上级 f1fb60bf
...@@ -190,7 +190,7 @@ int parse_proc_maps(void) ...@@ -190,7 +190,7 @@ int parse_proc_maps(void)
bool require_paranoia_below(int level) bool require_paranoia_below(int level)
{ {
unsigned long current; long current;
char *end, buf[16]; char *end, buf[16];
FILE *f; FILE *f;
int rc; int rc;
...@@ -208,7 +208,7 @@ bool require_paranoia_below(int level) ...@@ -208,7 +208,7 @@ bool require_paranoia_below(int level)
goto out_close; goto out_close;
} }
current = strtoul(buf, &end, 10); current = strtol(buf, &end, 10);
if (end == buf) { if (end == buf) {
printf("Couldn't parse " PARANOID_PATH "?\n"); printf("Couldn't parse " PARANOID_PATH "?\n");
...@@ -216,7 +216,7 @@ bool require_paranoia_below(int level) ...@@ -216,7 +216,7 @@ bool require_paranoia_below(int level)
} }
if (current >= level) if (current >= level)
goto out; goto out_close;
rc = 0; rc = 0;
out_close: out_close:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册