MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / resolvePmuEventName

Function resolvePmuEventName

src/perfEvents_linux.cpp:116–132  ·  view source on GitHub ↗

Convert pmu/event-name/ to pmu/param1=N,param2=M/

Source from the content-addressed store, hash-verified

114
115// Convert pmu/event-name/ to pmu/param1=N,param2=M/
116static void resolvePmuEventName(const char* device, char* event, size_t size) {
117 char buf[256];
118 if ((size_t)snprintf(buf, sizeof(buf), "/sys/bus/event_source/devices/%s/events/%s", device, event) >= sizeof(buf)) {
119 return;
120 }
121
122 int fd = open(buf, O_RDONLY);
123 if (fd == -1) {
124 return;
125 }
126
127 ssize_t r = read(fd, event, size);
128 if (r > 0 && (r == size || event[r - 1] == '\n')) {
129 event[r - 1] = 0;
130 }
131 close(fd);
132}
133
134// Set a PMU parameter (such as umask) to the corresponding config field
135static bool setPmuConfig(const char* device, const char* param, __u64* config, __u64 val) {

Callers 1

getPmuEventMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected