* [PATCH] selftests/powerpc: PMU libs: use signed long to read perf_event_paranoid
@ 2016-03-01 4:26 Cyril Bur
2016-07-05 14:10 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Cyril Bur @ 2016-03-01 4:26 UTC (permalink / raw)
To: linuxppc-dev
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 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>
---
tools/testing/selftests/powerpc/pmu/lib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/powerpc/pmu/lib.c b/tools/testing/selftests/powerpc/pmu/lib.c
index a361ad3..8b992fa 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)
bool require_paranoia_below(int level)
{
- unsigned long current;
+ long current;
char *end, buf[16];
FILE *f;
int rc;
@@ -208,7 +208,7 @@ bool require_paranoia_below(int level)
goto out_close;
}
- current = strtoul(buf, &end, 10);
+ current = strtol(buf, &end, 10);
if (end == buf) {
printf("Couldn't parse " PARANOID_PATH "?\n");
@@ -216,7 +216,7 @@ bool require_paranoia_below(int level)
}
if (current >= level)
- goto out;
+ goto out_close;
rc = 0;
out_close:
--
2.7.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: selftests/powerpc: PMU libs: use signed long to read perf_event_paranoid
2016-03-01 4:26 [PATCH] selftests/powerpc: PMU libs: use signed long to read perf_event_paranoid Cyril Bur
@ 2016-07-05 14:10 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2016-07-05 14:10 UTC (permalink / raw)
To: Cyril Bur, linuxppc-dev
On Tue, 2016-01-03 at 04:26:36 UTC, Cyril Bur wrote:
> 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 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>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/d4ecdff2ecdb5c01c46f2a6b1b
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-05 14:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-01 4:26 [PATCH] selftests/powerpc: PMU libs: use signed long to read perf_event_paranoid Cyril Bur
2016-07-05 14:10 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).