|
|
e284e3 |
From dd433306f249db81f1ef5cfffefeb2d0ad4e3115 Mon Sep 17 00:00:00 2001
|
|
|
e284e3 |
From: William Cohen <wcohen@redhat.com>
|
|
|
e284e3 |
Date: Tue, 10 Mar 2015 10:52:39 -0400
|
|
|
e284e3 |
Subject: [PATCH] Ensure that umask is set if the extra bits (edge, inv, cmask)
|
|
|
e284e3 |
are used
|
|
|
e284e3 |
|
|
|
e284e3 |
When testing ocount on some of the Intel processor it was discovered
|
|
|
e284e3 |
that that the umask not not being set for events that specified the
|
|
|
e284e3 |
the extra bits. Below is an example of the problem on an Intel Ivy
|
|
|
e284e3 |
Bridge processor with the event code missing the 0x03 unit masks for
|
|
|
e284e3 |
the events:
|
|
|
e284e3 |
|
|
|
e284e3 |
$ ocount --verbose -e int_misc:recovery_cycles -e int_misc:recovery_stalls_count ls
|
|
|
e284e3 |
Final event code is 140000d
|
|
|
e284e3 |
Final event code is 144000d
|
|
|
e284e3 |
Number of events passed is 2
|
|
|
e284e3 |
Exec args are: ls
|
|
|
e284e3 |
telling child to start app
|
|
|
e284e3 |
parent says start app /usr/bin/ls
|
|
|
e284e3 |
calling perf_event_open for pid 240d
|
|
|
e284e3 |
perf_event_open returning fd 9
|
|
|
e284e3 |
perf_event_open returning fd a
|
|
|
e284e3 |
perf counter setup complete
|
|
|
e284e3 |
app 240d is running
|
|
|
e284e3 |
going into waitpid on monitored app 240d
|
|
|
e284e3 |
app process ended normally.
|
|
|
e284e3 |
Reading counter data for event int_misc
|
|
|
e284e3 |
Reading counter data for event int_misc
|
|
|
e284e3 |
|
|
|
e284e3 |
Events were actively counted for 1070382 nanoseconds.
|
|
|
e284e3 |
Event counts (actual) for /usr/bin/ls:
|
|
|
e284e3 |
Event Count % time counted
|
|
|
e284e3 |
int_misc:recovery_cycles 0 100.00
|
|
|
e284e3 |
int_misc:recovery_stalls_count 0 100.00
|
|
|
e284e3 |
|
|
|
e284e3 |
With this patch the umasks are included and the example executes correctly:
|
|
|
e284e3 |
|
|
|
e284e3 |
$ ocount --verbose -e int_misc:recovery_cycles -e int_misc:recovery_stalls_count ls
|
|
|
e284e3 |
Final event code is 140030d
|
|
|
e284e3 |
Final event code is 144030d
|
|
|
e284e3 |
Number of events passed is 2
|
|
|
e284e3 |
Exec args are: ls
|
|
|
e284e3 |
telling child to start app
|
|
|
e284e3 |
calling perf_event_open for pid 72e1
|
|
|
e284e3 |
parent says start app /usr/bin/ls
|
|
|
e284e3 |
perf_event_open returning fd 9
|
|
|
e284e3 |
perf_event_open returning fd a
|
|
|
e284e3 |
perf counter setup complete
|
|
|
e284e3 |
app 72e1 is running
|
|
|
e284e3 |
going into waitpid on monitored app 72e1
|
|
|
e284e3 |
app process ended normally.
|
|
|
e284e3 |
Reading counter data for event int_misc
|
|
|
e284e3 |
Reading counter data for event int_misc
|
|
|
e284e3 |
|
|
|
e284e3 |
Events were actively counted for 1216948 nanoseconds.
|
|
|
e284e3 |
Event counts (actual) for /usr/bin/ls:
|
|
|
e284e3 |
Event Count % time counted
|
|
|
e284e3 |
int_misc:recovery_cycles 69,730 100.00
|
|
|
e284e3 |
int_misc:recovery_stalls_count 14,800 100.00
|
|
|
e284e3 |
|
|
|
e284e3 |
Signed-off-by: William Cohen <wcohen@redhat.com>
|
|
|
e284e3 |
---
|
|
|
e284e3 |
libop/op_events.c | 3 +++
|
|
|
e284e3 |
libop/op_events.h | 3 +++
|
|
|
e284e3 |
2 files changed, 6 insertions(+)
|
|
|
e284e3 |
|
|
|
e284e3 |
diff --git a/libop/op_events.c b/libop/op_events.c
|
|
|
e284e3 |
index 99266c6..2badc8e 100644
|
|
|
e284e3 |
--- a/libop/op_events.c
|
|
|
e284e3 |
+++ b/libop/op_events.c
|
|
|
e284e3 |
@@ -238,6 +238,9 @@ static void parse_um_entry(struct op_described_um * entry, char const * line)
|
|
|
e284e3 |
if (strisprefix(c, "extra:")) {
|
|
|
e284e3 |
c += 6;
|
|
|
e284e3 |
entry->extra = parse_extra(c);
|
|
|
e284e3 |
+ /* include the regular umask if there are real extra bits */
|
|
|
e284e3 |
+ if (entry->extra != EXTRA_NONE)
|
|
|
e284e3 |
+ entry->extra |= (entry->value & UMASK_MASK) << UMASK_SHIFT;
|
|
|
e284e3 |
/* named mask */
|
|
|
e284e3 |
c = skip_nonws(c);
|
|
|
e284e3 |
c = skip_ws(c);
|
|
|
e284e3 |
diff --git a/libop/op_events.h b/libop/op_events.h
|
|
|
e284e3 |
index ec345e5..f09c830 100644
|
|
|
e284e3 |
--- a/libop/op_events.h
|
|
|
e284e3 |
+++ b/libop/op_events.h
|
|
|
e284e3 |
@@ -20,6 +20,9 @@ extern "C" {
|
|
|
e284e3 |
#include "op_types.h"
|
|
|
e284e3 |
#include "op_list.h"
|
|
|
e284e3 |
|
|
|
e284e3 |
+#define UMASK_SHIFT 8
|
|
|
e284e3 |
+#define UMASK_MASK 0xff
|
|
|
e284e3 |
+
|
|
|
e284e3 |
#define EXTRA_EDGE (1U << 18)
|
|
|
e284e3 |
#define EXTRA_MIN_VAL EXTRA_EDGE
|
|
|
e284e3 |
|
|
|
e284e3 |
--
|
|
|
e284e3 |
2.1.0
|
|
|
e284e3 |
|