Adjust eBPF code. (#17550)
thiagoftsm committed
Apr 30, 2024 at 11:13 UTC
4c76a141ad330f422d31a837ebeb23b9b7b443f8
9 files changed
+21
-17
src/collectors/ebpf.plugin/ebpf_cachestat.c
+2
-2
@@ -1412,7 +1412,7 @@ static void cachestat_collector(ebpf_module_t *em)
1412
netdata_apps_integration_flags_t apps = em->apps_charts;
1413
ebpf_cachestat_read_global_tables(stats, maps_per_core);
1414
1415
- if (cgroups)
1415
+ if (cgroups && shm_ebpf_cgroup.header)
1416
ebpf_update_cachestat_cgroup();
1417
1418
pthread_mutex_lock(&lock);
@@ -1422,7 +1422,7 @@ static void cachestat_collector(ebpf_module_t *em)
1422
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
1423
ebpf_cache_send_apps_data(apps_groups_root_target);
1424
1425
- if (cgroups)
1425
+ if (cgroups && shm_ebpf_cgroup.header)
1426
ebpf_cachestat_send_cgroup_data(update_every);
1427
1428
pthread_mutex_unlock(&lock);
src/collectors/ebpf.plugin/ebpf_dcstat.c
+2
-2
@@ -1271,7 +1271,7 @@ static void dcstat_collector(ebpf_module_t *em)
1271
netdata_apps_integration_flags_t apps = em->apps_charts;
1272
ebpf_dc_read_global_tables(stats, maps_per_core);
1273
1274
- if (cgroups)
1274
+ if (cgroups && shm_ebpf_cgroup.header)
1275
ebpf_update_dc_cgroup();
1276
1277
pthread_mutex_lock(&lock);
@@ -1281,7 +1281,7 @@ static void dcstat_collector(ebpf_module_t *em)
1281
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
1282
ebpf_dcache_send_apps_data(apps_groups_root_target);
1283
1284
- if (cgroups)
1284
+ if (cgroups && shm_ebpf_cgroup.header)
1285
ebpf_dc_send_cgroup_data(update_every);
1286
1287
pthread_mutex_unlock(&lock);
src/collectors/ebpf.plugin/ebpf_fd.c
+4
-2
@@ -6,8 +6,10 @@
6
static char *fd_dimension_names[NETDATA_FD_SYSCALL_END] = { "open", "close" };
7
static char *fd_id_names[NETDATA_FD_SYSCALL_END] = { "do_sys_open", "__close_fd" };
8
9
+#ifdef LIBBPF_MAJOR_VERSION
10
static char *close_targets[NETDATA_EBPF_MAX_FD_TARGETS] = {"close_fd", "__close_fd"};
11
static char *open_targets[NETDATA_EBPF_MAX_FD_TARGETS] = {"do_sys_openat2", "do_sys_open"};
12
+#endif
13
14
static netdata_syscall_stat_t fd_aggregated_data[NETDATA_FD_SYSCALL_END];
15
static netdata_publish_syscall_t fd_publish_aggregated[NETDATA_FD_SYSCALL_END];
@@ -1213,7 +1215,7 @@ static void fd_collector(ebpf_module_t *em)
1215
netdata_apps_integration_flags_t apps = em->apps_charts;
1216
ebpf_fd_read_global_tables(stats, maps_per_core);
1217
1216
- if (cgroups)
1218
+ if (cgroups && shm_ebpf_cgroup.header)
1219
ebpf_update_fd_cgroup();
1220
1221
pthread_mutex_lock(&lock);
@@ -1223,7 +1225,7 @@ static void fd_collector(ebpf_module_t *em)
1225
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
1226
ebpf_fd_send_apps_data(em, apps_groups_root_target);
1227
1226
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
1228
+ if (cgroups && shm_ebpf_cgroup.header)
1229
ebpf_fd_send_cgroup_data(em);
1230
1231
pthread_mutex_unlock(&lock);
src/collectors/ebpf.plugin/ebpf_oomkill.c
+1
-1
@@ -470,7 +470,7 @@ static void oomkill_collector(ebpf_module_t *em)
470
stats[NETDATA_CONTROLLER_PID_TABLE_DEL] += (uint64_t) count;
471
472
pthread_mutex_lock(&lock);
473
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids) {
473
+ if (cgroups && shm_ebpf_cgroup.header) {
474
ebpf_update_oomkill_cgroup(keys, count);
475
// write everything from the ebpf map.
476
ebpf_oomkill_send_cgroup_data(update_every);
src/collectors/ebpf.plugin/ebpf_shm.c
+2
-2
@@ -1119,7 +1119,7 @@ static void shm_collector(ebpf_module_t *em)
1119
ebpf_shm_read_global_table(stats, maps_per_core);
1120
pthread_mutex_lock(&lock);
1121
1122
- if (cgroups) {
1122
+ if (cgroups && shm_ebpf_cgroup.header) {
1123
ebpf_update_shm_cgroup();
1124
}
1125
@@ -1129,7 +1129,7 @@ static void shm_collector(ebpf_module_t *em)
1129
ebpf_shm_send_apps_data(apps_groups_root_target);
1130
}
1131
1132
- if (cgroups) {
1132
+ if (cgroups && shm_ebpf_cgroup.header) {
1133
ebpf_shm_send_cgroup_data(update_every);
1134
}
1135
src/collectors/ebpf.plugin/ebpf_socket.c
+2
-2
@@ -2665,7 +2665,7 @@ static void socket_collector(ebpf_module_t *em)
2665
ebpf_socket_read_hash_global_tables(stats, maps_per_core);
2666
}
2667
2668
- if (cgroups)
2668
+ if (cgroups && shm_ebpf_cgroup.header)
2669
ebpf_update_socket_cgroup();
2670
2671
pthread_mutex_lock(&lock);
@@ -2675,7 +2675,7 @@ static void socket_collector(ebpf_module_t *em)
2675
if (socket_apps_enabled & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
2676
ebpf_socket_send_apps_data();
2677
2678
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
2678
+ if (cgroups && shm_ebpf_cgroup.header)
2679
ebpf_socket_send_cgroup_data(update_every);
2680
2681
fflush(stdout);
src/collectors/ebpf.plugin/ebpf_swap.c
+2
-2
@@ -929,7 +929,7 @@ static void swap_collector(ebpf_module_t *em)
929
netdata_apps_integration_flags_t apps = em->apps_charts;
930
ebpf_swap_read_global_table(stats, maps_per_core);
931
932
- if (cgroup)
932
+ if (cgroup && shm_ebpf_cgroup.header)
933
ebpf_update_swap_cgroup();
934
935
pthread_mutex_lock(&lock);
@@ -939,7 +939,7 @@ static void swap_collector(ebpf_module_t *em)
939
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
940
ebpf_swap_send_apps_data(apps_groups_root_target);
941
942
- if (cgroup && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
942
+ if (cgroup && shm_ebpf_cgroup.header)
943
ebpf_swap_send_cgroup_data(update_every);
944
945
pthread_mutex_unlock(&lock);
src/collectors/ebpf.plugin/ebpf_vfs.c
+2
-2
@@ -2104,7 +2104,7 @@ static void vfs_collector(ebpf_module_t *em)
2104
netdata_apps_integration_flags_t apps = em->apps_charts;
2105
ebpf_vfs_read_global_table(stats, maps_per_core);
2106
2107
- if (cgroups)
2107
+ if (cgroups && shm_ebpf_cgroup.header)
2108
read_update_vfs_cgroup();
2109
2110
pthread_mutex_lock(&lock);
@@ -2115,7 +2115,7 @@ static void vfs_collector(ebpf_module_t *em)
2115
if (apps & NETDATA_EBPF_APPS_FLAG_CHART_CREATED)
2116
ebpf_vfs_send_apps_data(em, apps_groups_root_target);
2117
2118
- if (cgroups && shm_ebpf_cgroup.header && ebpf_cgroup_pids)
2118
+ if (cgroups && shm_ebpf_cgroup.header)
2119
ebpf_vfs_send_cgroup_data(em);
2120
2121
pthread_mutex_unlock(&lock);
src/libnetdata/ebpf/ebpf.c
+4
-2
@@ -1266,8 +1266,10 @@ static void ebpf_update_target_with_conf(ebpf_module_t *em, netdata_ebpf_program
1266
*
1267
* @return it returns the new load mode.
1268
*/
1269
-static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file, netdata_ebpf_load_mode_t load,
1270
- int kver, int is_rh)
1269
+static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file __maybe_unused,
1270
+ netdata_ebpf_load_mode_t load,
1271
+ int kver __maybe_unused,
1272
+ int is_rh __maybe_unused)
1273
{
1274
#ifdef LIBBPF_MAJOR_VERSION
1275
if ((load & EBPF_LOAD_CORE) || (load & EBPF_LOAD_PLAY_DICE)) {