diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2023-06-19 13:08:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-19 13:08:42 +0000 |
commit | 49bcf61f6d9d997d30359772497fb26fd1305019 (patch) | |
tree | aabe7baa368e41b1d2b53f181f9076b978d402d6 /collectors/ebpf.plugin/ebpf_dcstat.c | |
parent | c76538e2f0ef4450e7c5f12b44f620d74fdcde47 (diff) |
Speed up eBPF exit before to bring functions (#15187)
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_dcstat.c')
-rw-r--r-- | collectors/ebpf.plugin/ebpf_dcstat.c | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/collectors/ebpf.plugin/ebpf_dcstat.c b/collectors/ebpf.plugin/ebpf_dcstat.c index 5a07e4619b..4157f0c875 100644 --- a/collectors/ebpf.plugin/ebpf_dcstat.c +++ b/collectors/ebpf.plugin/ebpf_dcstat.c @@ -286,55 +286,29 @@ void dcstat_update_publish(netdata_publish_dcstat_t *out, uint64_t cache_access, *****************************************************************/ /** - * Clean names - * - * Clean the optional names allocated during startup. - */ -void ebpf_dcstat_clean_names() -{ - size_t i = 0; - while (dc_optional_name[i].program_name) { - freez(dc_optional_name[i].optional); - i++; - } -} - -/** - * DCstat Free + * DCstat exit * - * Cleanup variables after child threads to stop + * Cancel child and exit. * * @param ptr thread data. */ -static void ebpf_dcstat_free(ebpf_module_t *em ) +static void ebpf_dcstat_exit(void *ptr) { - pthread_mutex_lock(&ebpf_exit_cleanup); - em->enabled = NETDATA_THREAD_EBPF_STOPPING; - pthread_mutex_unlock(&ebpf_exit_cleanup); + ebpf_module_t *em = (ebpf_module_t *)ptr; - freez(dcstat_vector); - freez(dcstat_values); +#ifdef LIBBPF_MAJOR_VERSION + if (dc_bpf_obj) + dc_bpf__destroy(dc_bpf_obj); +#endif - ebpf_dcstat_clean_names(); + if (em->objects) + ebpf_unload_legacy_code(em->objects, em->probe_links); pthread_mutex_lock(&ebpf_exit_cleanup); em->enabled = NETDATA_THREAD_EBPF_STOPPED; pthread_mutex_unlock(&ebpf_exit_cleanup); } -/** - * DCstat exit - * - * Cancel child and exit. - * - * @param ptr thread data. - */ -static void ebpf_dcstat_exit(void *ptr) -{ - ebpf_module_t *em = (ebpf_module_t *)ptr; - ebpf_dcstat_free(em); -} - /***************************************************************** * * APPS |