Blame SOURCES/oprofile-extramask.patch

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