Skip to content

Instantly share code, notes, and snippets.

@nrdmn
Last active September 5, 2019 08:01
Show Gist options
  • Save nrdmn/c2fd8b1a09e3c3c3598d2991f5470a70 to your computer and use it in GitHub Desktop.
Save nrdmn/c2fd8b1a09e3c3c3598d2991f5470a70 to your computer and use it in GitHub Desktop.
atop bug
#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;
}
@nrdmn
Copy link
Author

nrdmn commented Sep 5, 2019

Fixed in 5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment