Last active
September 5, 2019 08:01
-
-
Save nrdmn/c2fd8b1a09e3c3c3598d2991f5470a70 to your computer and use it in GitHub Desktop.
atop bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/perf_event.h> | |
#include <linux/hw_breakpoint.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <asm/unistd.h> | |
#include <stdio.h> | |
int main() | |
{ | |
if (geteuid() != 0) { | |
fputs("program must be run as root!\n", stderr); | |
return 1; | |
} | |
struct perf_event_attr foo; | |
memset(&foo, 0, sizeof(struct perf_event_attr)); | |
foo.type = PERF_TYPE_HARDWARE; | |
foo.size = sizeof(struct perf_event_attr); | |
foo.inherit = 1; | |
foo.pinned = 1; | |
foo.config = PERF_COUNT_HW_INSTRUCTIONS; | |
syscall(__NR_perf_event_open, &foo, -1, 0, -1, PERF_FLAG_FD_CLOEXEC); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment