Skip to content

Commit f7d7986

Browse files
antonblanchardpaulusmack
authored andcommitted
perf_event: Add alignment-faults and emulation-faults software events
Add two more software events that are common to many cpus. Alignment faults: When a load or store is not aligned properly. Emulation faults: When an instruction is emulated in software. Both cause a very significant slowdown (100x or worse), so identifying and fixing them is very important. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 81cd5ae commit f7d7986

5 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎include/linux/perf_counter.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ enum perf_sw_ids {
106106
PERF_COUNT_SW_CPU_MIGRATIONS = 4,
107107
PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
108108
PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
109+
PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
110+
PERF_COUNT_SW_EMULATION_FAULTS = 8,
109111

110112
PERF_COUNT_SW_MAX, /* non-ABI */
111113
};

‎include/linux/perf_event.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ enum perf_sw_ids {
102102
PERF_COUNT_SW_CPU_MIGRATIONS = 4,
103103
PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
104104
PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
105+
PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
106+
PERF_COUNT_SW_EMULATION_FAULTS = 8,
105107

106108
PERF_COUNT_SW_MAX, /* non-ABI */
107109
};

‎kernel/perf_event.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,6 +4186,8 @@ static const struct pmu *sw_perf_event_init(struct perf_event *event)
41864186
case PERF_COUNT_SW_PAGE_FAULTS_MAJ:
41874187
case PERF_COUNT_SW_CONTEXT_SWITCHES:
41884188
case PERF_COUNT_SW_CPU_MIGRATIONS:
4189+
case PERF_COUNT_SW_ALIGNMENT_FAULTS:
4190+
case PERF_COUNT_SW_EMULATION_FAULTS:
41894191
if (!event->parent) {
41904192
atomic_inc(&perf_swevent_enabled[event_id]);
41914193
event->destroy = sw_perf_event_destroy;

‎tools/perf/design.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ enum sw_event_ids {
137137
PERF_COUNT_SW_CPU_MIGRATIONS = 4,
138138
PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
139139
PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
140+
PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
141+
PERF_COUNT_SW_EMULATION_FAULTS = 8,
140142
};
141143

142144
Counters of the type PERF_TYPE_TRACEPOINT are available when the ftrace event

‎tools/perf/util/parse-events.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ static struct event_symbol event_symbols[] = {
4646
{ CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
4747
{ CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
4848
{ CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
49+
{ CSW(ALIGNMENT_FAULTS), "alignment-faults", "" },
50+
{ CSW(EMULATION_FAULTS), "emulation-faults", "" },
4951
};
5052

5153
#define __PERF_EVENT_FIELD(config, name) \
@@ -74,6 +76,8 @@ static const char *sw_event_names[] = {
7476
"CPU-migrations",
7577
"minor-faults",
7678
"major-faults",
79+
"alignment-faults",
80+
"emulation-faults",
7781
};
7882

7983
#define MAX_ALIASES 8

0 commit comments

Comments
 (0)