add page fault perf events

This commit is contained in:
Alexander Kuzmenkov 2020-06-25 23:21:58 +03:00
parent e521d616fe
commit a8db0b40d0
3 changed files with 11 additions and 2 deletions

View File

@ -196,6 +196,8 @@
M(PerfCpuMigrations, "Number of times the process has migrated to a new CPU") \ M(PerfCpuMigrations, "Number of times the process has migrated to a new CPU") \
M(PerfAlignmentFaults, "Number of alignment faults. These happen when unaligned memory accesses happen; the kernel can handle these but it reduces performance. This happens only on some architectures (never on x86).") \ M(PerfAlignmentFaults, "Number of alignment faults. These happen when unaligned memory accesses happen; the kernel can handle these but it reduces performance. This happens only on some architectures (never on x86).") \
M(PerfEmulationFaults, "Number of emulation faults. The kernel sometimes traps on unimplemented instructions and emulates them for user space. This can negatively impact performance.") \ M(PerfEmulationFaults, "Number of emulation faults. The kernel sometimes traps on unimplemented instructions and emulates them for user space. This can negatively impact performance.") \
M(PerfPageFaultsMinor, "This counts the number of minor page faults. These did not require disk I/O to handle.") \
M(PerfPageFaultsMajor, "This counts the number of major page faults. These required disk I/O to handle.") \
\ \
M(CreatedHTTPConnections, "Total amount of created HTTP connections (closed or opened).") \ M(CreatedHTTPConnections, "Total amount of created HTTP connections (closed or opened).") \
\ \

View File

@ -159,15 +159,20 @@ static const PerfEventInfo raw_events_info[] = {
HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, PerfStalledCyclesFrontend), HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, PerfStalledCyclesFrontend),
HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_BACKEND, PerfStalledCyclesBackend), HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_BACKEND, PerfStalledCyclesBackend),
HARDWARE_EVENT(PERF_COUNT_HW_REF_CPU_CYCLES, PerfRefCpuCycles), HARDWARE_EVENT(PERF_COUNT_HW_REF_CPU_CYCLES, PerfRefCpuCycles),
// `cpu-clock` is a bit broken according to this: https://stackoverflow.com/a/56967896 // `cpu-clock` is a bit broken according to this: https://stackoverflow.com/a/56967896
SOFTWARE_EVENT(PERF_COUNT_SW_CPU_CLOCK, PerfCpuClock), SOFTWARE_EVENT(PERF_COUNT_SW_CPU_CLOCK, PerfCpuClock),
SOFTWARE_EVENT(PERF_COUNT_SW_TASK_CLOCK, PerfTaskClock), SOFTWARE_EVENT(PERF_COUNT_SW_TASK_CLOCK, PerfTaskClock),
SOFTWARE_EVENT(PERF_COUNT_SW_CONTEXT_SWITCHES, PerfContextSwitches), SOFTWARE_EVENT(PERF_COUNT_SW_CONTEXT_SWITCHES, PerfContextSwitches),
SOFTWARE_EVENT(PERF_COUNT_SW_CPU_MIGRATIONS, PerfCpuMigrations), SOFTWARE_EVENT(PERF_COUNT_SW_CPU_MIGRATIONS, PerfCpuMigrations),
SOFTWARE_EVENT(PERF_COUNT_SW_ALIGNMENT_FAULTS, PerfAlignmentFaults), SOFTWARE_EVENT(PERF_COUNT_SW_ALIGNMENT_FAULTS, PerfAlignmentFaults),
SOFTWARE_EVENT(PERF_COUNT_SW_EMULATION_FAULTS, PerfEmulationFaults) SOFTWARE_EVENT(PERF_COUNT_SW_EMULATION_FAULTS, PerfEmulationFaults),
SOFTWARE_EVENT(PERF_COUNT_SW_PAGE_FAULTS_MIN, PerfPageFaultsMinor),
SOFTWARE_EVENT(PERF_COUNT_SW_PAGE_FAULTS_MAJ, PerfPageFaultsMajor)
}; };
static_assert(sizeof(raw_events_info) / sizeof(raw_events_info[0]) == NUMBER_OF_RAW_EVENTS);
#undef HARDWARE_EVENT #undef HARDWARE_EVENT
#undef SOFTWARE_EVENT #undef SOFTWARE_EVENT

View File

@ -53,6 +53,8 @@ namespace ProfileEvents
extern const Event PerfCpuMigrations; extern const Event PerfCpuMigrations;
extern const Event PerfAlignmentFaults; extern const Event PerfAlignmentFaults;
extern const Event PerfEmulationFaults; extern const Event PerfEmulationFaults;
extern const Event PerfPageFaultsMinor;
extern const Event PerfPageFaultsMajor;
#endif #endif
} }
@ -156,7 +158,7 @@ struct PerfEventValue
UInt64 time_running = 0; UInt64 time_running = 0;
}; };
static constexpr size_t NUMBER_OF_RAW_EVENTS = 16; static constexpr size_t NUMBER_OF_RAW_EVENTS = 18;
struct PerfDescriptorsHolder : boost::noncopyable struct PerfDescriptorsHolder : boost::noncopyable
{ {