Renamed events

This commit is contained in:
Andrey Skobtsov 2020-05-18 14:44:24 +03:00
parent 182e4f2c0b
commit e7bea6e03a
3 changed files with 113 additions and 117 deletions

View File

@ -178,48 +178,48 @@
M(OSReadChars, "Number of bytes read from filesystem, including page cache.") \
M(OSWriteChars, "Number of bytes written to filesystem, including page cache.") \
\
M(PERF_COUNT_HW_CPU_CYCLES, "Total cycles. Be wary of what happens during CPU frequency scaling.") \
M(PERF_COUNT_HW_CPU_CYCLES_RUNNING, "Total cycles (<time running>).") \
M(PERF_COUNT_HW_CPU_CYCLES_ENABLED, "Total cycles (<time enabled>).") \
M(PERF_COUNT_HW_INSTRUCTIONS, "Retired instructions. Be careful, these can be affected by various issues, most notably hardware interrupt counts.") \
M(PERF_COUNT_HW_INSTRUCTIONS_RUNNING, "Retired instructions (<time running>).") \
M(PERF_COUNT_HW_INSTRUCTIONS_ENABLED, "Retired instructions (<time enabled> * 100%).") \
M(PERF_COUNT_HW_CACHE_REFERENCES, "Cache accesses. Usually this indicates Last Level Cache accesses but this may vary depending on your CPU. This may include prefetches and coherency messages; again this depends on the design of your CPU.") \
M(PERF_COUNT_HW_CACHE_REFERENCES_RUNNING, "Cache accesses (<time running>).") \
M(PERF_COUNT_HW_CACHE_REFERENCES_ENABLED, "Cache accesses (<time enabled>).") \
M(PERF_COUNT_HW_CACHE_MISSES, "Cache misses. Usually this indicates Last Level Cache misses; this is intended to be used in conjunction with the PERF_COUNT_HW_CACHE_REFERENCES event to calculate cache miss rates.") \
M(PERF_COUNT_HW_CACHE_MISSES_RUNNING, "Cache misses (<time running> / <time enabled> * 100%).") \
M(PERF_COUNT_HW_CACHE_MISSES_ENABLED, "Cache misses (<time enabled>).") \
M(PERF_COUNT_HW_BRANCH_INSTRUCTIONS, "Retired branch instructions. Prior to Linux 2.6.35, this used the wrong event on AMD processors.") \
M(PERF_COUNT_HW_BRANCH_INSTRUCTIONS_RUNNING, "Retired branch instructions (<time running>).") \
M(PERF_COUNT_HW_BRANCH_INSTRUCTIONS_ENABLED, "Retired branch instructions (<time enabled>).") \
M(PERF_COUNT_HW_BRANCH_MISSES, "Mispredicted branch instructions.") \
M(PERF_COUNT_HW_BRANCH_MISSES_RUNNING, "Mispredicted branch instructions (<time running>).") \
M(PERF_COUNT_HW_BRANCH_MISSES_ENABLED, "Mispredicted branch instructions (<time enabled>).") \
M(PERF_COUNT_HW_BUS_CYCLES, "Bus cycles, which can be different from total cycles.") \
M(PERF_COUNT_HW_BUS_CYCLES_RUNNING, "Bus cycles, which can be different from total cycles (<time running>).") \
M(PERF_COUNT_HW_BUS_CYCLES_ENABLED, "Bus cycles, which can be different from total cycles (<time enabled>).") \
M(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, "Stalled cycles during issue.") \
M(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND_RUNNING, "Stalled cycles during issue (<time running>).") \
M(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND_ENABLED, "Stalled cycles during issue (<time enabled>).") \
M(PERF_COUNT_HW_STALLED_CYCLES_BACKEND, "Stalled cycles during retirement.") \
M(PERF_COUNT_HW_STALLED_CYCLES_BACKEND_RUNNING, "Stalled cycles during retirement (<time running>).") \
M(PERF_COUNT_HW_STALLED_CYCLES_BACKEND_ENABLED, "Stalled cycles during retirement (<time enabled>).") \
M(PERF_COUNT_HW_REF_CPU_CYCLES, "Total cycles; not affected by CPU frequency scaling.") \
M(PERF_COUNT_HW_REF_CPU_CYCLES_RUNNING, "Total cycles; not affected by CPU frequency scaling (<time running>).") \
M(PERF_COUNT_HW_REF_CPU_CYCLES_ENABLED, "Total cycles; not affected by CPU frequency scaling (<time enabled>).") \
M(PerfCpuCycles, "Total cycles. Be wary of what happens during CPU frequency scaling.") \
M(PerfCpuCyclesRunning, "Total cycles (<time running>).") \
M(PerfCpuCyclesEnabled, "Total cycles (<time enabled>).") \
M(PerfInstructions, "Retired instructions. Be careful, these can be affected by various issues, most notably hardware interrupt counts.") \
M(PerfInstructionsRunning, "Retired instructions (<time running>).") \
M(PerfInstructionsEnabled, "Retired instructions (<time enabled>).") \
M(PerfCacheReferences, "Cache accesses. Usually this indicates Last Level Cache accesses but this may vary depending on your CPU. This may include prefetches and coherency messages; again this depends on the design of your CPU.") \
M(PerfCacheReferencesRunning, "Cache accesses (<time running>).") \
M(PerfCacheReferencesEnabled, "Cache accesses (<time enabled>).") \
M(PerfCacheMisses, "Cache misses. Usually this indicates Last Level Cache misses; this is intended to be used in conjunction with the PERFCOUNTHWCACHEREFERENCES event to calculate cache miss rates.") \
M(PerfCacheMissesRunning, "Cache misses (<time running>).") \
M(PerfCacheMissesEnabled, "Cache misses (<time enabled>).") \
M(PerfBranchInstructions, "Retired branch instructions. Prior to Linux 2.6.35, this used the wrong event on AMD processors.") \
M(PerfBranchInstructionsRunning, "Retired branch instructions (<time running>).") \
M(PerfBranchInstructionsEnabled, "Retired branch instructions (<time enabled>).") \
M(PerfBranchMisses, "Mispredicted branch instructions.") \
M(PerfBranchMissesRunning, "Mispredicted branch instructions (<time running>).") \
M(PerfBranchMissesEnabled, "Mispredicted branch instructions (<time enabled>).") \
M(PerfBusCycles, "Bus cycles, which can be different from total cycles.") \
M(PerfBusCyclesRunning, "Bus cycles, which can be different from total cycles (<time running>).") \
M(PerfBusCyclesEnabled, "Bus cycles, which can be different from total cycles (<time enabled>).") \
M(PerfStalledCyclesFrontend, "Stalled cycles during issue.") \
M(PerfStalledCyclesFrontendRunning, "Stalled cycles during issue (<time running>).") \
M(PerfStalledCyclesFrontendEnabled, "Stalled cycles during issue (<time enabled>).") \
M(PerfStalledCyclesBackend, "Stalled cycles during retirement.") \
M(PerfStalledCyclesBackendRunning, "Stalled cycles during retirement (<time running>).") \
M(PerfStalledCyclesBackendEnabled, "Stalled cycles during retirement (<time enabled>).") \
M(PerfRefCpuCycles, "Total cycles; not affected by CPU frequency scaling.") \
M(PerfRefCpuCyclesRunning, "Total cycles; not affected by CPU frequency scaling (<time running>).") \
M(PerfRefCpuCyclesEnabled, "Total cycles; not affected by CPU frequency scaling (<time enabled>).") \
\
M(PERF_COUNT_SW_TASK_CLOCK, "A clock count specific to the task that is running") \
M(PERF_COUNT_SW_PAGE_FAULTS, "Number of page faults") \
M(PERF_COUNT_SW_CONTEXT_SWITCHES, "Number of context switches") \
M(PERF_COUNT_SW_CPU_MIGRATIONS, "Number of times the process has migrated to a new CPU") \
M(PERF_COUNT_SW_PAGE_FAULTS_MIN, "Number of minor page faults. These did not require disk I/O to handle") \
M(PERF_COUNT_SW_PAGE_FAULTS_MAJ, "Number of major page faults. These required disk I/O to handle") \
M(PERF_COUNT_SW_ALIGNMENT_FAULTS, "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(PERF_COUNT_SW_EMULATION_FAULTS, "Number of emulation faults. The kernel sometimes traps on unimplemented instructions and emulates them for user space. This can negatively impact performance.") \
M(PerfTaskClock, "A clock count specific to the task that is running") \
M(PerfPageFaults, "Number of page faults") \
M(PerfContextSwitches, "Number of context switches") \
M(PerfCpuMigrations, "Number of times the process has migrated to a new CPU") \
M(PerfPageFaultsMin, "Number of minor page faults. These did not require disk I/O to handle") \
M(PerfPageFaultsMaj, "Number of major page faults. These required disk I/O to handle") \
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(PERF_CUSTOM_INSTRUCTIONS_PER_CPU_CYCLE_SCALED, "") \
M(PERF_CUSTOM_INSTRUCTIONS_PER_CPU_CYCLE, "") \
M(PerfCustomInstructionsPerCpuCycleScaled, "") \
M(PerfCustomInstructionsPerCpuCycle, "") \
\
M(CreatedHTTPConnections, "Total amount of created HTTP connections (closed or opened).") \
\

View File

@ -123,50 +123,46 @@ static PerfEventInfo softwareEvent(int event_config, ProfileEvents::Event profil
};
}
static PerfEventInfo hardwareEvent(int event_config, ProfileEvents::Event profile_event, std::optional<ProfileEvents::Event> pe_running, std::optional<ProfileEvents::Event> pe_enabled)
{
return PerfEventInfo
{
.event_type = perf_type_id::PERF_TYPE_HARDWARE,
.event_config = event_config,
.profile_event = profile_event,
.profile_event_running = pe_running,
.profile_event_enabled = pe_enabled
};
}
#define HARDWARE_WITH_TIME(EVENT_NAME) \
hardwareEvent(EVENT_NAME, ProfileEvents::EVENT_NAME, {ProfileEvents::EVENT_NAME##_RUNNING}, {ProfileEvents::EVENT_NAME##_ENABLED})
#define HARDWARE_EVENT(PERF_NAME, LOCAL_NAME) \
PerfEventInfo \
{ \
.event_type = perf_type_id::PERF_TYPE_HARDWARE, \
.event_config = PERF_NAME, \
.profile_event = ProfileEvents::LOCAL_NAME, \
.profile_event_running = {ProfileEvents::LOCAL_NAME##Running}, \
.profile_event_enabled = {ProfileEvents::LOCAL_NAME##Enabled} \
}
// descriptions' source: http://man7.org/linux/man-pages/man2/perf_event_open.2.html
const PerfEventInfo PerfEventsCounters::raw_events_info[] = {
HARDWARE_WITH_TIME(PERF_COUNT_HW_CPU_CYCLES),
HARDWARE_WITH_TIME(PERF_COUNT_HW_INSTRUCTIONS),
HARDWARE_WITH_TIME(PERF_COUNT_HW_CACHE_REFERENCES),
HARDWARE_WITH_TIME(PERF_COUNT_HW_CACHE_MISSES),
HARDWARE_WITH_TIME(PERF_COUNT_HW_BRANCH_INSTRUCTIONS),
HARDWARE_WITH_TIME(PERF_COUNT_HW_BRANCH_MISSES),
HARDWARE_WITH_TIME(PERF_COUNT_HW_BUS_CYCLES),
HARDWARE_WITH_TIME(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND),
HARDWARE_WITH_TIME(PERF_COUNT_HW_STALLED_CYCLES_BACKEND),
HARDWARE_WITH_TIME(PERF_COUNT_HW_REF_CPU_CYCLES),
HARDWARE_EVENT(PERF_COUNT_HW_CPU_CYCLES, PerfCpuCycles),
HARDWARE_EVENT(PERF_COUNT_HW_INSTRUCTIONS, PerfInstructions),
HARDWARE_EVENT(PERF_COUNT_HW_CACHE_REFERENCES, PerfCacheReferences),
HARDWARE_EVENT(PERF_COUNT_HW_CACHE_MISSES, PerfCacheMisses),
HARDWARE_EVENT(PERF_COUNT_HW_BRANCH_INSTRUCTIONS, PerfBranchInstructions),
HARDWARE_EVENT(PERF_COUNT_HW_BRANCH_MISSES, PerfBranchMisses),
HARDWARE_EVENT(PERF_COUNT_HW_BUS_CYCLES, PerfBusCycles),
HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, PerfStalledCyclesFrontend),
HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_BACKEND, PerfStalledCyclesBackend),
HARDWARE_EVENT(PERF_COUNT_HW_REF_CPU_CYCLES, PerfRefCpuCycles),
// This reports the CPU clock, a high-resolution per-CPU timer.
// a bit broken according to this: https://stackoverflow.com/a/56967896
// softwareEvent(PERF_COUNT_SW_CPU_CLOCK, ProfileEvents::PERF_COUNT_SW_CPU_CLOCK),
softwareEvent(PERF_COUNT_SW_TASK_CLOCK, ProfileEvents::PERF_COUNT_SW_TASK_CLOCK),
softwareEvent(PERF_COUNT_SW_PAGE_FAULTS, ProfileEvents::PERF_COUNT_SW_PAGE_FAULTS),
softwareEvent(PERF_COUNT_SW_CONTEXT_SWITCHES, ProfileEvents::PERF_COUNT_SW_CONTEXT_SWITCHES),
softwareEvent(PERF_COUNT_SW_CPU_MIGRATIONS, ProfileEvents::PERF_COUNT_SW_CPU_MIGRATIONS),
softwareEvent(PERF_COUNT_SW_PAGE_FAULTS_MIN, ProfileEvents::PERF_COUNT_SW_PAGE_FAULTS_MIN),
softwareEvent(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ProfileEvents::PERF_COUNT_SW_PAGE_FAULTS_MAJ),
softwareEvent(PERF_COUNT_SW_ALIGNMENT_FAULTS, ProfileEvents::PERF_COUNT_SW_ALIGNMENT_FAULTS),
softwareEvent(PERF_COUNT_SW_EMULATION_FAULTS, ProfileEvents::PERF_COUNT_SW_EMULATION_FAULTS)
// softwareEvent(PERF_COUNT_SW_CPU_CLOCK, ProfileEvents::PerfCpuClock),
softwareEvent(PERF_COUNT_SW_TASK_CLOCK, ProfileEvents::PerfTaskClock),
softwareEvent(PERF_COUNT_SW_PAGE_FAULTS, ProfileEvents::PerfPageFaults),
softwareEvent(PERF_COUNT_SW_CONTEXT_SWITCHES, ProfileEvents::PerfContextSwitches),
softwareEvent(PERF_COUNT_SW_CPU_MIGRATIONS, ProfileEvents::PerfCpuMigrations),
softwareEvent(PERF_COUNT_SW_PAGE_FAULTS_MIN, ProfileEvents::PerfPageFaultsMin),
softwareEvent(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ProfileEvents::PerfPageFaultsMaj),
softwareEvent(PERF_COUNT_SW_ALIGNMENT_FAULTS, ProfileEvents::PerfAlignmentFaults),
softwareEvent(PERF_COUNT_SW_EMULATION_FAULTS, ProfileEvents::PerfEmulationFaults)
// This is a placeholder event that counts nothing. Informational sample record types such as mmap or
// comm must be associated with an active event. This dummy event allows gathering such records
// without requiring a counting event.
// softwareEventInfo(PERF_COUNT_SW_DUMMY, ProfileEvents::PERF_COUNT_SW_DUMMY)
};
#undef HARDWARE_WITH_TIME
#undef HARDWARE_EVENT
thread_local PerfDescriptorsHolder PerfEventsCounters::thread_events_descriptors_holder{};
thread_local bool PerfEventsCounters::thread_events_descriptors_opened = false;
@ -363,8 +359,8 @@ void PerfEventsCounters::finalizeProfileEvents(PerfEventsCounters & counters, Pr
? counters.getRawValue(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS).value / hw_ref_cpu_cycles
: 0;
profile_events.increment(ProfileEvents::PERF_CUSTOM_INSTRUCTIONS_PER_CPU_CYCLE_SCALED, instructions_per_cpu_scaled);
profile_events.increment(ProfileEvents::PERF_CUSTOM_INSTRUCTIONS_PER_CPU_CYCLE, instructions_per_cpu);
profile_events.increment(ProfileEvents::PerfCustomInstructionsPerCpuCycleScaled, instructions_per_cpu_scaled);
profile_events.increment(ProfileEvents::PerfCustomInstructionsPerCpuCycle, instructions_per_cpu);
current_thread_counters = nullptr;
}

View File

@ -36,49 +36,49 @@ namespace ProfileEvents
extern const Event OSReadBytes;
extern const Event OSWriteBytes;
extern const Event PERF_COUNT_HW_CPU_CYCLES;
extern const Event PERF_COUNT_HW_CPU_CYCLES_RUNNING;
extern const Event PERF_COUNT_HW_CPU_CYCLES_ENABLED;
extern const Event PERF_COUNT_HW_INSTRUCTIONS;
extern const Event PERF_COUNT_HW_INSTRUCTIONS_RUNNING;
extern const Event PERF_COUNT_HW_INSTRUCTIONS_ENABLED;
extern const Event PERF_COUNT_HW_CACHE_REFERENCES;
extern const Event PERF_COUNT_HW_CACHE_REFERENCES_RUNNING;
extern const Event PERF_COUNT_HW_CACHE_REFERENCES_ENABLED;
extern const Event PERF_COUNT_HW_CACHE_MISSES;
extern const Event PERF_COUNT_HW_CACHE_MISSES_RUNNING;
extern const Event PERF_COUNT_HW_CACHE_MISSES_ENABLED;
extern const Event PERF_COUNT_HW_BRANCH_INSTRUCTIONS;
extern const Event PERF_COUNT_HW_BRANCH_INSTRUCTIONS_RUNNING;
extern const Event PERF_COUNT_HW_BRANCH_INSTRUCTIONS_ENABLED;
extern const Event PERF_COUNT_HW_BRANCH_MISSES;
extern const Event PERF_COUNT_HW_BRANCH_MISSES_RUNNING;
extern const Event PERF_COUNT_HW_BRANCH_MISSES_ENABLED;
extern const Event PERF_COUNT_HW_BUS_CYCLES;
extern const Event PERF_COUNT_HW_BUS_CYCLES_RUNNING;
extern const Event PERF_COUNT_HW_BUS_CYCLES_ENABLED;
extern const Event PERF_COUNT_HW_STALLED_CYCLES_FRONTEND;
extern const Event PERF_COUNT_HW_STALLED_CYCLES_FRONTEND_RUNNING;
extern const Event PERF_COUNT_HW_STALLED_CYCLES_FRONTEND_ENABLED;
extern const Event PERF_COUNT_HW_STALLED_CYCLES_BACKEND;
extern const Event PERF_COUNT_HW_STALLED_CYCLES_BACKEND_RUNNING;
extern const Event PERF_COUNT_HW_STALLED_CYCLES_BACKEND_ENABLED;
extern const Event PERF_COUNT_HW_REF_CPU_CYCLES;
extern const Event PERF_COUNT_HW_REF_CPU_CYCLES_RUNNING;
extern const Event PERF_COUNT_HW_REF_CPU_CYCLES_ENABLED;
extern const Event PerfCpuCycles;
extern const Event PerfCpuCyclesRunning;
extern const Event PerfCpuCyclesEnabled;
extern const Event PerfInstructions;
extern const Event PerfInstructionsRunning;
extern const Event PerfInstructionsEnabled;
extern const Event PerfCacheReferences;
extern const Event PerfCacheReferencesRunning;
extern const Event PerfCacheReferencesEnabled;
extern const Event PerfCacheMisses;
extern const Event PerfCacheMissesRunning;
extern const Event PerfCacheMissesEnabled;
extern const Event PerfBranchInstructions;
extern const Event PerfBranchInstructionsRunning;
extern const Event PerfBranchInstructionsEnabled;
extern const Event PerfBranchMisses;
extern const Event PerfBranchMissesRunning;
extern const Event PerfBranchMissesEnabled;
extern const Event PerfBusCycles;
extern const Event PerfBusCyclesRunning;
extern const Event PerfBusCyclesEnabled;
extern const Event PerfStalledCyclesFrontend;
extern const Event PerfStalledCyclesFrontendRunning;
extern const Event PerfStalledCyclesFrontendEnabled;
extern const Event PerfStalledCyclesBackend;
extern const Event PerfStalledCyclesBackendRunning;
extern const Event PerfStalledCyclesBackendEnabled;
extern const Event PerfRefCpuCycles;
extern const Event PerfRefCpuCyclesRunning;
extern const Event PerfRefCpuCyclesEnabled;
// extern const Event PERF_COUNT_SW_CPU_CLOCK;
extern const Event PERF_COUNT_SW_TASK_CLOCK;
extern const Event PERF_COUNT_SW_PAGE_FAULTS;
extern const Event PERF_COUNT_SW_CONTEXT_SWITCHES;
extern const Event PERF_COUNT_SW_CPU_MIGRATIONS;
extern const Event PERF_COUNT_SW_PAGE_FAULTS_MIN;
extern const Event PERF_COUNT_SW_PAGE_FAULTS_MAJ;
extern const Event PERF_COUNT_SW_ALIGNMENT_FAULTS;
extern const Event PERF_COUNT_SW_EMULATION_FAULTS;
// extern const Event PerfCpuClock;
extern const Event PerfTaskClock;
extern const Event PerfPageFaults;
extern const Event PerfContextSwitches;
extern const Event PerfCpuMigrations;
extern const Event PerfPageFaultsMin;
extern const Event PerfPageFaultsMaj;
extern const Event PerfAlignmentFaults;
extern const Event PerfEmulationFaults;
extern const Event PERF_CUSTOM_INSTRUCTIONS_PER_CPU_CYCLE_SCALED;
extern const Event PERF_CUSTOM_INSTRUCTIONS_PER_CPU_CYCLE;
extern const Event PerfCustomInstructionsPerCpuCycleScaled;
extern const Event PerfCustomInstructionsPerCpuCycle;
#endif
}