diff --git a/example/libbpf-tools/syscount/syscount.bpf.c b/example/libbpf-tools/syscount/syscount.bpf.c index 38f8f978..0e179cf2 100644 --- a/example/libbpf-tools/syscount/syscount.bpf.c +++ b/example/libbpf-tools/syscount/syscount.bpf.c @@ -16,13 +16,6 @@ const volatile bool filter_failed = false; const volatile int filter_errno = false; const volatile pid_t filter_pid = 0; -struct { - __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY); - __type(key, u32); - __type(value, u32); - __uint(max_entries, 1); -} cgroup_map SEC(".maps"); - struct { __uint(type, BPF_MAP_TYPE_HASH); __uint(max_entries, MAX_ENTRIES); @@ -37,18 +30,6 @@ struct { __type(value, struct data_t); } data SEC(".maps"); -static __always_inline -void save_proc_name(struct data_t *val) -{ - struct task_struct *current = (void *)bpf_get_current_task(); - - /* We should save the process name every time because it can be - * changed (e.g., by exec). This can be optimized later by managing - * this field with the help of tp/sched/sched_process_exec and - * raw_tp/task_rename. */ - BPF_CORE_READ_STR_INTO(&val->comm, current, group_leader, comm); -} - SEC("tracepoint/raw_syscalls/sys_enter") int sys_enter(struct trace_event_raw_sys_enter *args) { @@ -57,9 +38,6 @@ int sys_enter(struct trace_event_raw_sys_enter *args) u32 tid = id; u64 ts; - if (filter_cg && !bpf_current_task_under_cgroup(&cgroup_map, 0)) - return 0; - if (filter_pid && pid != filter_pid) return 0; @@ -71,9 +49,6 @@ int sys_enter(struct trace_event_raw_sys_enter *args) SEC("tracepoint/raw_syscalls/sys_exit") int sys_exit(struct trace_event_raw_sys_exit *args) { - if (filter_cg && !bpf_current_task_under_cgroup(&cgroup_map, 0)) - return 0; - u64 id = bpf_get_current_pid_tgid(); static const struct data_t zero; pid_t pid = id >> 32; @@ -103,11 +78,10 @@ int sys_exit(struct trace_event_raw_sys_exit *args) key = (count_by_process) ? pid : args->id; val = bpf_map_lookup_or_try_init(&data, &key, &zero); if (val) { - __sync_fetch_and_add(&val->count, 1); - if (count_by_process) - save_proc_name(val); - if (measure_latency) - __sync_fetch_and_add(&val->total_ns, lat); + val->count = val->count + 1; + if (measure_latency) { + val->total_ns = val->total_ns + lat; + } } return 0; } diff --git a/example/libbpf-tools/syscount/syscount.c b/example/libbpf-tools/syscount/syscount.c index 258be5e9..29efcc47 100644 --- a/example/libbpf-tools/syscount/syscount.c +++ b/example/libbpf-tools/syscount/syscount.c @@ -388,8 +388,6 @@ int main(int argc, char **argv) int seconds = 0; __u32 count; int err; - int idx, cg_map_fd; - int cgfd = -1; init_syscall_names(); @@ -430,21 +428,6 @@ int main(int argc, char **argv) goto cleanup_obj; } - /* update cgroup path fd to map */ - if (env.cg) { - idx = 0; - cg_map_fd = bpf_map__fd(obj->maps.cgroup_map); - cgfd = open(env.cgroupspath, O_RDONLY); - if (cgfd < 0) { - fprintf(stderr, "Failed opening Cgroup path: %s", env.cgroupspath); - goto cleanup_obj; - } - if (bpf_map_update_elem(cg_map_fd, &idx, &cgfd, BPF_ANY)) { - fprintf(stderr, "Failed adding target cgroup to map"); - goto cleanup_obj; - } - } - obj->links.sys_exit = bpf_program__attach(obj->progs.sys_exit); if (!obj->links.sys_exit) { err = -errno;