Browse Source

Ebpf issues (#13259)

thiagoftsm 2 years ago
parent
commit
3f9d90a155

+ 0 - 43
collectors/ebpf.plugin/ebpf.c

@@ -219,51 +219,8 @@ static void ebpf_exit(int sig)
         return;
     }
 
-    if (ebpf_modules[EBPF_MODULE_SOCKET_IDX].enabled) {
-        ebpf_modules[EBPF_MODULE_SOCKET_IDX].enabled = 0;
-        clean_socket_apps_structures();
-        freez(socket_bandwidth_curr);
-    }
-
-    if (ebpf_modules[EBPF_MODULE_CACHESTAT_IDX].enabled) {
-        ebpf_modules[EBPF_MODULE_CACHESTAT_IDX].enabled = 0;
-        clean_cachestat_pid_structures();
-        freez(cachestat_pid);
-    }
-
-    if (ebpf_modules[EBPF_MODULE_DCSTAT_IDX].enabled) {
-        ebpf_modules[EBPF_MODULE_DCSTAT_IDX].enabled = 0;
-        clean_dcstat_pid_structures();
-        freez(dcstat_pid);
-    }
-
-    if (ebpf_modules[EBPF_MODULE_SWAP_IDX].enabled) {
-        ebpf_modules[EBPF_MODULE_SWAP_IDX].enabled = 0;
-        clean_swap_pid_structures();
-        freez(swap_pid);
-    }
-
-    if (ebpf_modules[EBPF_MODULE_VFS_IDX].enabled) {
-        ebpf_modules[EBPF_MODULE_VFS_IDX].enabled = 0;
-        clean_vfs_pid_structures();
-        freez(vfs_pid);
-    }
-
-    if (ebpf_modules[EBPF_MODULE_FD_IDX].enabled) {
-        ebpf_modules[EBPF_MODULE_FD_IDX].enabled = 0;
-        clean_fd_pid_structures();
-        freez(fd_pid);
-    }
-
-    if (ebpf_modules[EBPF_MODULE_SHM_IDX].enabled) {
-        ebpf_modules[EBPF_MODULE_SHM_IDX].enabled = 0;
-        clean_shm_pid_structures();
-        freez(shm_pid);
-    }
-
     ebpf_close_cgroup_shm();
 
-    ebpf_clean_cgroup_pids();
     /*
     int ret = fork();
     if (ret < 0) // error

+ 0 - 2
collectors/ebpf.plugin/ebpf_apps.h

@@ -433,8 +433,6 @@ extern size_t read_bandwidth_statistic_using_pid_on_target(ebpf_bandwidth_t **ep
 
 extern void collect_data_for_all_processes(int tbl_pid_stats_fd);
 
-extern void clean_global_memory();
-
 extern ebpf_process_stat_t **global_process_stats;
 extern ebpf_process_publish_apps_t **current_apps_data;
 extern netdata_publish_cachestat_t **cachestat_pid;

+ 2 - 15
collectors/ebpf.plugin/ebpf_cachestat.c

@@ -293,20 +293,6 @@ static inline int ebpf_cachestat_load_and_attach(struct cachestat_bpf *obj, ebpf
  *
  *****************************************************************/
 
-/**
- * Clean PID structures
- *
- * Clean the allocated structures.
- */
-void clean_cachestat_pid_structures() {
-    struct pid_stat *pids = root_of_pids;
-    while (pids) {
-        freez(cachestat_pid[pids->pid]);
-
-        pids = pids->next;
-    }
-}
-
 /**
  * Clean up the main thread.
  *
@@ -338,7 +324,8 @@ static void ebpf_cachestat_cleanup(void *ptr)
             bpf_link__destroy(probe_links[i]);
             i++;
         }
-        bpf_object__close(objects);
+        if (objects)
+            bpf_object__close(objects);
     }
 #ifdef LIBBPF_MAJOR_VERSION
     else if (bpf_obj)

+ 0 - 1
collectors/ebpf.plugin/ebpf_cachestat.h

@@ -82,7 +82,6 @@ typedef struct netdata_publish_cachestat {
 } netdata_publish_cachestat_t;
 
 extern void *ebpf_cachestat_thread(void *ptr);
-extern void clean_cachestat_pid_structures();
 
 extern struct config cachestat_config;
 extern netdata_ebpf_targets_t cachestat_targets[];

+ 0 - 20
collectors/ebpf.plugin/ebpf_cgroup.c

@@ -133,26 +133,6 @@ static inline void ebpf_clean_specific_cgroup_pids(struct pid_on_target2 *pt)
     }
 }
 
-/**
- * Cleanup link list
- */
-void ebpf_clean_cgroup_pids()
-{
-    if (!ebpf_cgroup_pids)
-        return;
-
-    ebpf_cgroup_target_t *ect = ebpf_cgroup_pids;
-    while (ect) {
-        ebpf_cgroup_target_t *next_cgroup = ect->next;
-
-        ebpf_clean_specific_cgroup_pids(ect->pids);
-        freez(ect);
-
-        ect = next_cgroup;
-    }
-    ebpf_cgroup_pids = NULL;
-}
-
 /**
  * Remove Cgroup Update Target Update List
  *

+ 0 - 1
collectors/ebpf.plugin/ebpf_cgroup.h

@@ -63,7 +63,6 @@ typedef struct ebpf_cgroup_target {
 extern void ebpf_map_cgroup_shared_memory();
 extern void ebpf_parse_cgroup_shm_data();
 extern void ebpf_close_cgroup_shm();
-extern void ebpf_clean_cgroup_pids();
 extern void ebpf_create_charts_on_systemd(char *id, char *title, char *units, char *family, char *charttype, int order,
                                           char *algorithm, char *context, char *module, int update_every);
 

+ 2 - 15
collectors/ebpf.plugin/ebpf_dcstat.c

@@ -251,20 +251,6 @@ void dcstat_update_publish(netdata_publish_dcstat_t *out, uint64_t cache_access,
  *
  *****************************************************************/
 
-/**
- * Clean PID structures
- *
- * Clean the allocated structures.
- */
-void clean_dcstat_pid_structures() {
-    struct pid_stat *pids = root_of_pids;
-    while (pids) {
-        freez(dcstat_pid[pids->pid]);
-
-        pids = pids->next;
-    }
-}
-
 /**
  *  Clean names
  *
@@ -312,7 +298,8 @@ static void ebpf_dcstat_cleanup(void *ptr)
             bpf_link__destroy(probe_links[i]);
             i++;
         }
-        bpf_object__close(objects);
+        if (objects)
+            bpf_object__close(objects);
     }
 #ifdef LIBBPF_MAJOR_VERSION
     else if (bpf_obj)

+ 0 - 1
collectors/ebpf.plugin/ebpf_dcstat.h

@@ -77,7 +77,6 @@ typedef struct netdata_publish_dcstat {
 
 extern void *ebpf_dcstat_thread(void *ptr);
 extern void ebpf_dcstat_create_apps_charts(struct ebpf_module *em, void *ptr);
-extern void clean_dcstat_pid_structures();
 extern struct config dcstat_config;
 extern netdata_ebpf_targets_t dc_targets[];
 

+ 2 - 1
collectors/ebpf.plugin/ebpf_disk.c

@@ -465,7 +465,8 @@ static void ebpf_disk_cleanup(void *ptr)
             bpf_link__destroy(probe_links[i]);
             i++;
         }
-        bpf_object__close(objects);
+        if (objects)
+            bpf_object__close(objects);
     }
 }
 

+ 2 - 15
collectors/ebpf.plugin/ebpf_fd.c

@@ -47,20 +47,6 @@ netdata_fd_stat_t **fd_pid = NULL;
  *
  *****************************************************************/
 
-/**
- * Clean PID structures
- *
- * Clean the allocated structures.
- */
-void clean_fd_pid_structures() {
-    struct pid_stat *pids = root_of_pids;
-    while (pids) {
-        freez(fd_pid[pids->pid]);
-
-        pids = pids->next;
-    }
-}
-
 /**
  * Clean up the main thread.
  *
@@ -92,7 +78,8 @@ static void ebpf_fd_cleanup(void *ptr)
             bpf_link__destroy(probe_links[i]);
             i++;
         }
-        bpf_object__close(objects);
+        if (objects)
+            bpf_object__close(objects);
     }
 }
 

Some files were not shown because too many files changed in this diff