summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2024-04-30 11:13:34 +0000
committerGitHub <noreply@github.com>2024-04-30 11:13:34 +0000
commit4c76a141ad330f422d31a837ebeb23b9b7b443f8 (patch)
tree5968a91b89c2782862102bea248bcbcc710a546d /src
parent824d52b2f21be17f04e573d6d6c74d5f4a0e220e (diff)
Adjust eBPF code. (#17550)
Diffstat (limited to 'src')
-rw-r--r--src/collectors/ebpf.plugin/ebpf_cachestat.c4
-rw-r--r--src/collectors/ebpf.plugin/ebpf_dcstat.c4
-rw-r--r--src/collectors/ebpf.plugin/ebpf_fd.c6
-rw-r--r--src/collectors/ebpf.plugin/ebpf_oomkill.c2
-rw-r--r--src/collectors/ebpf.plugin/ebpf_shm.c4
-rw-r--r--src/collectors/ebpf.plugin/ebpf_socket.c4
-rw-r--r--src/collectors/ebpf.plugin/ebpf_swap.c4
-rw-r--r--src/collectors/ebpf.plugin/ebpf_vfs.c4
-rw-r--r--src/libnetdata/ebpf/ebpf.c6
9 files changed, 21 insertions, 17 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf_cachestat.c b/src/collectors/ebpf.plugin/ebpf_cachestat.c
index 91d9a28dbe..9bc51e484e 100644
--- a/src/collectors/ebpf.plugin/ebpf_cachestat.c
+++ b/src/collectors/ebpf.plugin/ebpf_cachestat.c
@@ -1412,7 +1412,7 @@ static void cachestat_collector(ebpf_module_t *em)
netdata_apps_integration_flags_t apps = em->apps_charts;
ebpf_cachestat_read_global_tables(stats, maps_per_core);
- if (cgroups)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_update_cachestat_cgroup();
pthread_mutex_lock(&lock);
@@ -1422,7 +1422,7 @@ static void cachestat_collector(ebpf_module_t *em)
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
ebpf_cache_send_apps_data(apps_groups_root_target);
- if (cgroups)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_cachestat_send_cgroup_data(update_every);
pthread_mutex_unlock(&lock);
diff --git a/src/collectors/ebpf.plugin/ebpf_dcstat.c b/src/collectors/ebpf.plugin/ebpf_dcstat.c
index 8e458eb528..dbba1e38c0 100644
--- a/src/collectors/ebpf.plugin/ebpf_dcstat.c
+++ b/src/collectors/ebpf.plugin/ebpf_dcstat.c
@@ -1271,7 +1271,7 @@ static void dcstat_collector(ebpf_module_t *em)
netdata_apps_integration_flags_t apps = em->apps_charts;
ebpf_dc_read_global_tables(stats, maps_per_core);
- if (cgroups)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_update_dc_cgroup();
pthread_mutex_lock(&lock);
@@ -1281,7 +1281,7 @@ static void dcstat_collector(ebpf_module_t *em)
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
ebpf_dcache_send_apps_data(apps_groups_root_target);
- if (cgroups)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_dc_send_cgroup_data(update_every);
pthread_mutex_unlock(&lock);
diff --git a/src/collectors/ebpf.plugin/ebpf_fd.c b/src/collectors/ebpf.plugin/ebpf_fd.c
index 7d87c48509..0e4165ed1b 100644
--- a/src/collectors/ebpf.plugin/ebpf_fd.c
+++ b/src/collectors/ebpf.plugin/ebpf_fd.c
@@ -6,8 +6,10 @@
static char *fd_dimension_names[NETDATA_FD_SYSCALL_END] = { "open", "close" };
static char *fd_id_names[NETDATA_FD_SYSCALL_END] = { "do_sys_open", "__close_fd" };
+#ifdef LIBBPF_MAJOR_VERSION
static char *close_targets[NETDATA_EBPF_MAX_FD_TARGETS] = {"close_fd", "__close_fd"};
static char *open_targets[NETDATA_EBPF_MAX_FD_TARGETS] = {"do_sys_openat2", "do_sys_open"};
+#endif
static netdata_syscall_stat_t fd_aggregated_data[NETDATA_FD_SYSCALL_END];
static netdata_publish_syscall_t fd_publish_aggregated[NETDATA_FD_SYSCALL_END];
@@ -1213,7 +1215,7 @@ static void fd_collector(ebpf_module_t *em)
netdata_apps_integration_flags_t apps = em->apps_charts;
ebpf_fd_read_global_tables(stats, maps_per_core);
- if (cgroups)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_update_fd_cgroup();
pthread_mutex_lock(&lock);
@@ -1223,7 +1225,7 @@ static void fd_collector(ebpf_module_t *em)
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
ebpf_fd_send_apps_data(em, apps_groups_root_target);
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_fd_send_cgroup_data(em);
pthread_mutex_unlock(&lock);
diff --git a/src/collectors/ebpf.plugin/ebpf_oomkill.c b/src/collectors/ebpf.plugin/ebpf_oomkill.c
index fba5a2dda5..df0ddd5c53 100644
--- a/src/collectors/ebpf.plugin/ebpf_oomkill.c
+++ b/src/collectors/ebpf.plugin/ebpf_oomkill.c
@@ -470,7 +470,7 @@ static void oomkill_collector(ebpf_module_t *em)
stats[NETDATA_CONTROLLER_PID_TABLE_DEL] += (uint64_t) count;
pthread_mutex_lock(&lock);
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids) {
+ if (cgroups && shm_ebpf_cgroup.header) {
ebpf_update_oomkill_cgroup(keys, count);
// write everything from the ebpf map.
ebpf_oomkill_send_cgroup_data(update_every);
diff --git a/src/collectors/ebpf.plugin/ebpf_shm.c b/src/collectors/ebpf.plugin/ebpf_shm.c
index ed9436c04b..bffc7b850b 100644
--- a/src/collectors/ebpf.plugin/ebpf_shm.c
+++ b/src/collectors/ebpf.plugin/ebpf_shm.c
@@ -1119,7 +1119,7 @@ static void shm_collector(ebpf_module_t *em)
ebpf_shm_read_global_table(stats, maps_per_core);
pthread_mutex_lock(&lock);
- if (cgroups) {
+ if (cgroups && shm_ebpf_cgroup.header) {
ebpf_update_shm_cgroup();
}
@@ -1129,7 +1129,7 @@ static void shm_collector(ebpf_module_t *em)
ebpf_shm_send_apps_data(apps_groups_root_target);
}
- if (cgroups) {
+ if (cgroups && shm_ebpf_cgroup.header) {
ebpf_shm_send_cgroup_data(update_every);
}
diff --git a/src/collectors/ebpf.plugin/ebpf_socket.c b/src/collectors/ebpf.plugin/ebpf_socket.c
index 32e8e9e50e..47ec20df22 100644
--- a/src/collectors/ebpf.plugin/ebpf_socket.c
+++ b/src/collectors/ebpf.plugin/ebpf_socket.c
@@ -2665,7 +2665,7 @@ static void socket_collector(ebpf_module_t *em)
ebpf_socket_read_hash_global_tables(stats, maps_per_core);
}
- if (cgroups)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_update_socket_cgroup();
pthread_mutex_lock(&lock);
@@ -2675,7 +2675,7 @@ static void socket_collector(ebpf_module_t *em)
if (socket_apps_enabled & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
ebpf_socket_send_apps_data();
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_socket_send_cgroup_data(update_every);
fflush(stdout);
diff --git a/src/collectors/ebpf.plugin/ebpf_swap.c b/src/collectors/ebpf.plugin/ebpf_swap.c
index ba7699dfde..b2b5dad347 100644
--- a/src/collectors/ebpf.plugin/ebpf_swap.c
+++ b/src/collectors/ebpf.plugin/ebpf_swap.c
@@ -929,7 +929,7 @@ static void swap_collector(ebpf_module_t *em)
netdata_apps_integration_flags_t apps = em->apps_charts;
ebpf_swap_read_global_table(stats, maps_per_core);
- if (cgroup)
+ if (cgroup && shm_ebpf_cgroup.header)
ebpf_update_swap_cgroup();
pthread_mutex_lock(&lock);
@@ -939,7 +939,7 @@ static void swap_collector(ebpf_module_t *em)
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
ebpf_swap_send_apps_data(apps_groups_root_target);
- if (cgroup && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
+ if (cgroup && shm_ebpf_cgroup.header)
ebpf_swap_send_cgroup_data(update_every);
pthread_mutex_unlock(&lock);
diff --git a/src/collectors/ebpf.plugin/ebpf_vfs.c b/src/collectors/ebpf.plugin/ebpf_vfs.c
index f6c5f71f4f..c57136f04e 100644
--- a/src/collectors/ebpf.plugin/ebpf_vfs.c
+++ b/src/collectors/ebpf.plugin/ebpf_vfs.c
@@ -2104,7 +2104,7 @@ static void vfs_collector(ebpf_module_t *em)
netdata_apps_integration_flags_t apps = em->apps_charts;
ebpf_vfs_read_global_table(stats, maps_per_core);
- if (cgroups)
+ if (cgroups && shm_ebpf_cgroup.header)
read_update_vfs_cgroup();
pthread_mutex_lock(&lock);
@@ -2115,7 +2115,7 @@ static void vfs_collector(ebpf_module_t *em)
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
ebpf_vfs_send_apps_data(em, apps_groups_root_target);
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
+ if (cgroups && shm_ebpf_cgroup.header)
ebpf_vfs_send_cgroup_data(em);
pthread_mutex_unlock(&lock);
diff --git a/src/libnetdata/ebpf/ebpf.c b/src/libnetdata/ebpf/ebpf.c
index 5479130354..4e7c85943b 100644
--- a/src/libnetdata/ebpf/ebpf.c
+++ b/src/libnetdata/ebpf/ebpf.c
@@ -1266,8 +1266,10 @@ static void ebpf_update_target_with_conf(ebpf_module_t *em, netdata_ebpf_program
*
* @return it returns the new load mode.
*/
-static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file, netdata_ebpf_load_mode_t load,
- int kver, int is_rh)
+static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file __maybe_unused,
+ netdata_ebpf_load_mode_t load,
+ int kver __maybe_unused,
+ int is_rh __maybe_unused)
{
#ifdef LIBBPF_MAJOR_VERSION
if ((load & EBPF_LOAD_CORE) || (load & EBPF_LOAD_PLAY_DICE)) {