diff --git a/observation/src/numamove/numamove.bpf.c b/observation/src/numamove/numamove.bpf.c index 1a52bc6ae856fdd9bec7c0027937ac5fb63a0b67..de2b16330ff433f30f69eca8e88131c2ea5dc5da 100644 --- a/observation/src/numamove/numamove.bpf.c +++ b/observation/src/numamove/numamove.bpf.c @@ -30,3 +30,40 @@ struct __type(key, u32); __type(value, u64); } num_map SEC(".maps"); + +static int __migrate_misplaced_page(void) +{ + pid_t pid = (pid_t)bpf_get_current_pid_tgid(); + u64 ts = bpf_ktime_get_ns(); + + bpf_map_update_elem(&start, &pid, &ts, BPF_ANY); + return 0; +} + +SEC("fentry/migrate_misplaced_page") +int BPF_PROG(fentry_migrate_misplaced_page) +{ + return __migrate_misplaced_page(); +} + +SEC("kprobe/migrate_misplaced_page") +int BPF_KPROBE(kprobe_migrate_misplaced_page) +{ + return __migrate_misplaced_page(); +} + +static u64 zero; + +SEC("fexit/migrate_misplaced_page") +int BPF_PROG(fexit_migrate_misplaced_page) +{ + return __migrate_misplaced_page_exit(); +} + +SEC("kretprobe/migrate_misplaced_page") +int BPF_KRETPROBE(kretprobe_migrate_misplaced_page) +{ + return __migrate_misplaced_page_exit(); +} + +char LICENSE[] SEC("license") = "GPL"; \ No newline at end of file diff --git a/observation/src/numamove/numamove.c b/observation/src/numamove/numamove.c index af29f403fbca15b7880c474d1c17e95ca815b1d6..6e0740a7fcaf9986c698f4b34db6304e02fb24c2 100644 --- a/observation/src/numamove/numamove.c +++ b/observation/src/numamove/numamove.c @@ -26,4 +26,35 @@ const char argp_program_doc[] = static const struct argp_option opts[] = { {"verbose", 'v', NULL, 0, "Verbose debug output"}, {NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help"}, - {}}; \ No newline at end of file + {}}; + +static error_t parse_arg(int key, char *arg, struct argp_state *state) +{ + switch (key) + { + case 'v': + env.verbose = true; + break; + case 'h': + argp_state_help(state, stderr, ARGP_HELP_STD_HELP); + break; + default: + return ARGP_ERR_UNKNOWN; + } + + return 0; +} + +static int libbpf_print_fn(enum libbpf_print_level level, const char *format, + va_list args) +{ + if (level == LIBBPF_DEBUG && !env.verbose) + return 0; + + return vfprintf(stderr, format, args); +} + +static void sig_handler(int sig) +{ + exiting = 1; +} \ No newline at end of file