@cryptotaxi247 / netdata-1 / commits / 4e828eb9b

Update libbpf (#11480)

thiagoftsm committed Sep 20, 2021 at 16:51 UTC 4e828eb9b58be82a557344ee6a7747043274ee01
33 files changed +263 -202
collectors/ebpf.plugin/ebpf.c
+3 -16
@@ -67,7 +67,7 @@ struct config collector_config = { .first_section = NULL,
67 int running_on_kernel = 0;
68 char kernel_string[64];
69 int ebpf_nprocs;
70 -static int isrh;
70 +int isrh = 0;
71 uint32_t finalized_threads = 1;
72
73 pthread_mutex_t lock;
@@ -970,20 +970,6 @@ static void ebpf_allocate_common_vectors()
970 global_process_stat = callocz((size_t)ebpf_nprocs, sizeof(ebpf_process_stat_t));
971 }
972
973 -/**
974 - * Fill the ebpf_data structure with default values
975 - *
976 - * @param ef the pointer to set default values
977 - */
978 -void fill_ebpf_data(ebpf_data_t *ef)
979 -{
980 - memset(ef, 0, sizeof(ebpf_data_t));
981 - ef->kernel_string = kernel_string;
982 - ef->running_on_kernel = running_on_kernel;
983 - ef->map_fd = callocz(EBPF_MAX_MAPS, sizeof(int));
984 - ef->isrh = isrh;
985 -}
986 -
973 /**
974 * Define how to load the ebpf programs
975 *
@@ -1245,6 +1231,8 @@ void set_global_variables()
1231
1232 isrh = get_redhat_release();
1233 pid_max = get_system_pid_max();
1234 + running_on_kernel = ebpf_get_kernel_version();
1235 + ebpf_update_kernel(kernel_string, 63, isrh, running_on_kernel);
1236 }
1237
1238 /**
@@ -1654,7 +1642,6 @@ int main(int argc, char **argv)
1642 ebpf_load_thread_config();
1643 ebpf_manage_pid(getpid());
1644
1657 - running_on_kernel = get_kernel_version(kernel_string, 63);
1645 if (!has_condition_to_run(running_on_kernel)) {
1646 error("The current collector cannot run on this kernel.");
1647 return 2;
collectors/ebpf.plugin/ebpf.h
+1 -2
@@ -144,6 +144,7 @@ extern pthread_mutex_t lock;
144 extern int close_ebpf_plugin;
145 extern int ebpf_nprocs;
146 extern int running_on_kernel;
147 +extern int isrh;
148 extern char *ebpf_plugin_dir;
149 extern char kernel_string[64];
150
@@ -196,8 +197,6 @@ extern void write_err_chart(char *name, char *family, netdata_publish_syscall_t
197 extern void write_io_chart(char *chart, char *family, char *dwrite, long long vwrite,
198 char *dread, long long vread);
199
199 -extern void fill_ebpf_data(ebpf_data_t *ef);
200 -
200 extern void ebpf_create_charts_on_apps(char *name,
201 char *title,
202 char *units,
collectors/ebpf.plugin/ebpf_cachestat.c
+1 -7
@@ -3,7 +3,6 @@
3 #include "ebpf.h"
4 #include "ebpf_cachestat.h"
5
6 -static ebpf_data_t cachestat_data;
6 netdata_publish_cachestat_t **cachestat_pid;
7
8 static struct bpf_link **probe_links = NULL;
@@ -633,7 +632,6 @@ void *ebpf_cachestat_thread(void *ptr)
632
633 ebpf_module_t *em = (ebpf_module_t *)ptr;
634 em->maps = cachestat_maps;
636 - fill_ebpf_data(&cachestat_data);
635
636 ebpf_update_pid_table(&cachestat_maps[NETDATA_CACHESTAT_PID_STATS], em);
637
@@ -642,12 +640,8 @@ void *ebpf_cachestat_thread(void *ptr)
640
641 pthread_mutex_lock(&lock);
642 ebpf_cachestat_allocate_global_vectors(NETDATA_CACHESTAT_END);
645 - if (ebpf_update_kernel(&cachestat_data)) {
646 - pthread_mutex_unlock(&lock);
647 - goto endcachestat;
648 - }
643
650 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, cachestat_data.map_fd);
644 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
645 if (!probe_links) {
646 pthread_mutex_unlock(&lock);
647 goto endcachestat;
collectors/ebpf.plugin/ebpf_dcstat.c
+1 -4
@@ -7,8 +7,6 @@ static char *dcstat_counter_dimension_name[NETDATA_DCSTAT_IDX_END] = { "ratio",
7 static netdata_syscall_stat_t dcstat_counter_aggregated_data[NETDATA_DCSTAT_IDX_END];
8 static netdata_publish_syscall_t dcstat_counter_publish_aggregated[NETDATA_DCSTAT_IDX_END];
9
10 -static ebpf_data_t dcstat_data;
11 -
10 netdata_dcstat_pid_t *dcstat_vector = NULL;
11 netdata_publish_dcstat_t **dcstat_pid = NULL;
12
@@ -583,7 +581,6 @@ void *ebpf_dcstat_thread(void *ptr)
581
582 ebpf_module_t *em = (ebpf_module_t *)ptr;
583 em->maps = dcstat_maps;
586 - fill_ebpf_data(&dcstat_data);
584
585 ebpf_update_pid_table(&dcstat_maps[NETDATA_DCSTAT_PID_STATS], em);
586
@@ -596,7 +593,7 @@ void *ebpf_dcstat_thread(void *ptr)
593
594 pthread_mutex_lock(&lock);
595
599 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, dcstat_data.map_fd);
596 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
597 if (!probe_links) {
598 pthread_mutex_unlock(&lock);
599 goto enddcstat;
collectors/ebpf.plugin/ebpf_disk.c
+1 -9
@@ -18,8 +18,6 @@ static ebpf_local_maps_t disk_maps[] = {{.name = "tbl_disk_iocall", .internal_in
18 {.name = NULL, .internal_input = 0, .user_input = 0,
19 .type = NETDATA_EBPF_MAP_CONTROLLER,
20 .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}};
21 -static ebpf_data_t disk_data;
22 -
21 static avl_tree_lock disk_tree;
22 netdata_ebpf_disks_t *disk_list = NULL;
23
@@ -792,15 +790,9 @@ void *ebpf_disk_thread(void *ptr)
790 ebpf_module_t *em = (ebpf_module_t *)ptr;
791 em->maps = disk_maps;
792
795 - fill_ebpf_data(&disk_data);
796 -
793 if (!em->enabled)
794 goto enddisk;
795
800 - if (ebpf_update_kernel(&disk_data)) {
801 - goto enddisk;
802 - }
803 -
796 if (ebpf_disk_enable_tracepoints()) {
797 em->enabled = CONFIG_BOOLEAN_NO;
798 goto enddisk;
@@ -817,7 +809,7 @@ void *ebpf_disk_thread(void *ptr)
809 goto enddisk;
810 }
811
820 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, disk_data.map_fd);
812 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
813 if (!probe_links) {
814 goto enddisk;
815 }
collectors/ebpf.plugin/ebpf_fd.c
+1 -7
@@ -29,7 +29,6 @@ struct config fd_config = { .first_section = NULL, .last_section = NULL, .mutex
29 .index = {.avl_tree = { .root = NULL, .compar = appconfig_section_compare },
30 .rwlock = AVL_LOCK_INITIALIZER } };
31
32 -static ebpf_data_t fd_data;
32 static struct bpf_link **probe_links = NULL;
33 static struct bpf_object *objects = NULL;
34
@@ -82,7 +81,6 @@ static void ebpf_fd_cleanup(void *ptr)
81 }
82
83 ebpf_cleanup_publish_syscall(fd_publish_aggregated);
85 - freez(fd_data.map_fd);
84 freez(fd_thread.thread);
85 freez(fd_values);
86 freez(fd_vector);
@@ -499,17 +497,13 @@ void *ebpf_fd_thread(void *ptr)
497
498 ebpf_module_t *em = (ebpf_module_t *)ptr;
499 em->maps = fd_maps;
502 - fill_ebpf_data(&fd_data);
500
501 if (!em->enabled)
502 goto endfd;
503
507 - if (ebpf_update_kernel(&fd_data))
508 - goto endfd;
509 -
504 ebpf_fd_allocate_global_vectors();
505
512 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, fd_data.map_fd);
506 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
507 if (!probe_links) {
508 goto endfd;
509 }
collectors/ebpf.plugin/ebpf_filesystem.c
+29 -16
@@ -8,6 +8,28 @@ struct config fs_config = { .first_section = NULL,
8 .index = { .avl_tree = { .root = NULL, .compar = appconfig_section_compare },
9 .rwlock = AVL_LOCK_INITIALIZER } };
10
11 +static ebpf_local_maps_t fs_maps[] = {{.name = "tbl_ext4", .internal_input = NETDATA_KEY_CALLS_SYNC,
12 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
13 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
14 + {.name = "tbl_xfs", .internal_input = NETDATA_KEY_CALLS_SYNC,
15 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
16 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
17 + {.name = "tbl_nfs", .internal_input = NETDATA_KEY_CALLS_SYNC,
18 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
19 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
20 + {.name = "tbl_zfs", .internal_input = NETDATA_KEY_CALLS_SYNC,
21 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
22 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
23 + {.name = "tbl_btrfs", .internal_input = NETDATA_KEY_CALLS_SYNC,
24 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
25 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
26 + {.name = "tbl_ext_addr", .internal_input = 1,
27 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
28 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
29 + {.name = NULL, .internal_input = 0, .user_input = 0,
30 + .type = NETDATA_EBPF_MAP_CONTROLLER,
31 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}};
32 +
33 ebpf_filesystem_partitions_t localfs[] =
34 {{.filesystem = "ext4",
35 .optional_filesystem = NULL,
@@ -200,17 +222,8 @@ int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em)
222 for (i = 0; localfs[i].filesystem; i++) {
223 ebpf_filesystem_partitions_t *efp = &localfs[i];
224 if (!efp->probe_links && efp->flags & NETDATA_FILESYSTEM_LOAD_EBPF_PROGRAM) {
203 - ebpf_data_t *ed = &efp->kernel_info;
204 - fill_ebpf_data(ed);
205 -
206 - if (ebpf_update_kernel(ed)) {
207 - em->thread_name = saved_name;
208 - return -1;
209 - }
210 -
225 em->thread_name = efp->filesystem;
212 - efp->probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string,
213 - &efp->objects, ed->map_fd);
226 + efp->probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &efp->objects);
227 if (!efp->probe_links) {
228 em->thread_name = saved_name;
229 return -1;
@@ -218,8 +231,9 @@ int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em)
231 efp->flags |= NETDATA_FILESYSTEM_FLAG_HAS_PARTITION;
232
233 // Nedeed for filesystems like btrfs
221 - if ((efp->flags & NETDATA_FILESYSTEM_FILL_ADDRESS_TABLE) && (efp->addresses.function))
222 - ebpf_load_addresses(&efp->addresses, efp->kernel_info.map_fd[NETDATA_ADDR_FS_TABLE]);
234 + if ((efp->flags & NETDATA_FILESYSTEM_FILL_ADDRESS_TABLE) && (efp->addresses.function)) {
235 + ebpf_load_addresses(&efp->addresses, fs_maps[i + 1].map_fd);
236 + }
237 }
238 efp->flags &= ~NETDATA_FILESYSTEM_LOAD_EBPF_PROGRAM;
239 }
@@ -331,7 +345,6 @@ void ebpf_filesystem_cleanup_ebpf_data()
345 for (i = 0; localfs[i].filesystem; i++) {
346 ebpf_filesystem_partitions_t *efp = &localfs[i];
347 if (efp->probe_links) {
334 - freez(efp->kernel_info.map_fd);
348 freez(efp->family_name);
349
350 freez(efp->hread.name);
@@ -428,12 +441,11 @@ static inline netdata_ebpf_histogram_t *select_hist(ebpf_filesystem_partitions_t
441 *
442 * Read the table with number of calls for all functions
443 */
431 -static void read_filesystem_table(ebpf_filesystem_partitions_t *efp)
444 +static void read_filesystem_table(ebpf_filesystem_partitions_t *efp, int fd)
445 {
446 netdata_idx_t *values = filesystem_hash_values;
447 uint32_t key;
448 uint32_t idx;
436 - int fd = efp->kernel_info.map_fd[NETDATA_MAIN_FS_TABLE];
449 for (key = 0; key < NETDATA_KEY_CALLS_SYNC; key++) {
450 netdata_ebpf_histogram_t *w = select_hist(efp, &idx, key);
451 if (!w) {
@@ -471,7 +483,7 @@ static void read_filesystem_tables()
483 for (i = 0; localfs[i].filesystem; i++) {
484 ebpf_filesystem_partitions_t *efp = &localfs[i];
485 if (efp->flags & NETDATA_FILESYSTEM_FLAG_HAS_PARTITION) {
474 - read_filesystem_table(efp);
486 + read_filesystem_table(efp, fs_maps[i].map_fd);
487 }
488 }
489 }
@@ -603,6 +615,7 @@ void *ebpf_filesystem_thread(void *ptr)
615 netdata_thread_cleanup_push(ebpf_filesystem_cleanup, ptr);
616
617 ebpf_module_t *em = (ebpf_module_t *)ptr;
618 + em->maps = fs_maps;
619 ebpf_update_filesystem();
620
621 if (!em->enabled)
collectors/ebpf.plugin/ebpf_filesystem.h
-1
@@ -59,7 +59,6 @@ typedef struct ebpf_filesystem_partitions {
59 uint32_t flags;
60 uint32_t enabled;
61
62 - ebpf_data_t kernel_info;
62 ebpf_addresses_t addresses;
63 } ebpf_filesystem_partitions_t;
64
collectors/ebpf.plugin/ebpf_hardirq.c
+1 -9
@@ -36,8 +36,6 @@ static ebpf_local_maps_t hardirq_maps[] = {
36 }
37 };
38
39 -static ebpf_data_t hardirq_data;
40 -
39 #define HARDIRQ_TP_CLASS_IRQ "irq"
40 #define HARDIRQ_TP_CLASS_IRQ_VECTORS "irq_vectors"
41 static ebpf_tracepoint_t hardirq_tracepoints[] = {
@@ -466,22 +464,16 @@ void *ebpf_hardirq_thread(void *ptr)
464 ebpf_module_t *em = (ebpf_module_t *)ptr;
465 em->maps = hardirq_maps;
466
469 - fill_ebpf_data(&hardirq_data);
470 -
467 if (!em->enabled) {
468 goto endhardirq;
469 }
470
475 - if (ebpf_update_kernel(&hardirq_data)) {
476 - goto endhardirq;
477 - }
478 -
471 if (ebpf_enable_tracepoints(hardirq_tracepoints) == 0) {
472 em->enabled = CONFIG_BOOLEAN_NO;
473 goto endhardirq;
474 }
475
484 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, hardirq_data.map_fd);
476 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
477 if (!probe_links) {
478 goto endhardirq;
479 }
collectors/ebpf.plugin/ebpf_mount.c
+1 -6
@@ -10,7 +10,6 @@ static ebpf_local_maps_t mount_maps[] = {{.name = "tbl_mount", .internal_input =
10 .type = NETDATA_EBPF_MAP_CONTROLLER,
11 .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}};
12
13 -static ebpf_data_t mount_data;
13 static char *mount_dimension_name[NETDATA_EBPF_MOUNT_SYSCALL] = { "mount", "umount" };
14 static netdata_syscall_stat_t mount_aggregated_data[NETDATA_EBPF_MOUNT_SYSCALL];
15 static netdata_publish_syscall_t mount_publish_aggregated[NETDATA_EBPF_MOUNT_SYSCALL];
@@ -227,15 +226,11 @@ void *ebpf_mount_thread(void *ptr)
226
227 ebpf_module_t *em = (ebpf_module_t *)ptr;
228 em->maps = mount_maps;
230 - fill_ebpf_data(&mount_data);
229
230 if (!em->enabled)
231 goto endmount;
232
235 - if (ebpf_update_kernel(&mount_data))
236 - goto endmount;
237 -
238 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, mount_data.map_fd);
233 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
234 if (!probe_links) {
235 goto endmount;
236 }
collectors/ebpf.plugin/ebpf_oomkill.c
+1 -9
@@ -28,8 +28,6 @@ static ebpf_local_maps_t oomkill_maps[] = {
28 }
29 };
30
31 -static ebpf_data_t oomkill_data;
32 -
31 static ebpf_tracepoint_t oomkill_tracepoints[] = {
32 {.enabled = false, .class = "oom", .event = "mark_victim"},
33 /* end */
@@ -188,22 +186,16 @@ void *ebpf_oomkill_thread(void *ptr)
186 ebpf_module_t *em = (ebpf_module_t *)ptr;
187 em->maps = oomkill_maps;
188
191 - fill_ebpf_data(&oomkill_data);
192 -
189 if (!em->enabled) {
190 goto endoomkill;
191 }
192
197 - if (ebpf_update_kernel(&oomkill_data)) {
198 - goto endoomkill;
199 - }
200 -
193 if (ebpf_enable_tracepoints(oomkill_tracepoints) == 0) {
194 em->enabled = CONFIG_BOOLEAN_NO;
195 goto endoomkill;
196 }
197
206 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, oomkill_data.map_fd);
198 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
199 if (!probe_links) {
200 goto endoomkill;
201 }
collectors/ebpf.plugin/ebpf_process.c
+2 -12
@@ -34,8 +34,6 @@ static netdata_idx_t *process_hash_values = NULL;
34 static netdata_syscall_stat_t process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_END];
35 static netdata_publish_syscall_t process_publish_aggregated[NETDATA_KEY_PUBLISH_PROCESS_END];
36
37 -static ebpf_data_t process_data;
38 -
37 ebpf_process_stat_t **global_process_stats = NULL;
38 ebpf_process_publish_apps_t **current_apps_data = NULL;
39
@@ -561,8 +559,6 @@ static void ebpf_process_cleanup(void *ptr)
559 freez(global_process_stats);
560 freez(current_apps_data);
561
564 - freez(process_data.map_fd);
565 -
562 if (probe_links) {
563 struct bpf_program *prog;
564 size_t i = 0 ;
@@ -609,7 +605,7 @@ static void change_syscalls()
605 */
606 static void set_local_pointers()
607 {
612 - if (process_data.isrh >= NETDATA_MINIMUM_RH_VERSION && process_data.isrh < NETDATA_RH_8)
608 + if (isrh >= NETDATA_MINIMUM_RH_VERSION && isrh < NETDATA_RH_8)
609 change_syscalls();
610 }
611
@@ -663,20 +659,14 @@ void *ebpf_process_thread(void *ptr)
659 ebpf_module_t *em = (ebpf_module_t *)ptr;
660 em->maps = process_maps;
661 process_enabled = em->enabled;
666 - fill_ebpf_data(&process_data);
662
663 pthread_mutex_lock(&lock);
664 ebpf_process_allocate_global_vectors(NETDATA_KEY_PUBLISH_PROCESS_END);
665
671 - if (ebpf_update_kernel(&process_data)) {
672 - pthread_mutex_unlock(&lock);
673 - goto endprocess;
674 - }
675 -
666 ebpf_update_pid_table(&process_maps[0], em);
667
668 set_local_pointers();
679 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, process_data.map_fd);
669 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
670 if (!probe_links) {
671 pthread_mutex_unlock(&lock);
672 goto endprocess;
collectors/ebpf.plugin/ebpf_socket.c
+1 -10
@@ -54,8 +54,6 @@ static netdata_idx_t *socket_hash_values = NULL;
54 static netdata_syscall_stat_t socket_aggregated_data[NETDATA_MAX_SOCKET_VECTOR];
55 static netdata_publish_syscall_t socket_publish_aggregated[NETDATA_MAX_SOCKET_VECTOR];
56
57 -static ebpf_data_t socket_data;
58 -
57 ebpf_socket_publish_apps_t **socket_bandwidth_curr = NULL;
58 static ebpf_bandwidth_t *bandwidth_vector = NULL;
59
@@ -1900,7 +1898,6 @@ static void ebpf_socket_cleanup(void *ptr)
1898 clean_hostnames(network_viewer_opt.excluded_hostnames);
1899
1900 pthread_mutex_destroy(&nv_mutex);
1903 - freez(socket_data.map_fd);
1901
1902 freez(socket_threads.thread);
1903
@@ -2869,7 +2866,6 @@ void *ebpf_socket_thread(void *ptr)
2866
2867 ebpf_module_t *em = (ebpf_module_t *)ptr;
2868 em->maps = socket_maps;
2872 - fill_ebpf_data(&socket_data);
2869
2870 parse_network_viewer_section(&socket_config);
2871 parse_service_name_section(&socket_config);
@@ -2887,15 +2883,10 @@ void *ebpf_socket_thread(void *ptr)
2883 ebpf_socket_allocate_global_vectors(NETDATA_MAX_SOCKET_VECTOR);
2884 initialize_inbound_outbound();
2885
2890 - if (ebpf_update_kernel(&socket_data)) {
2891 - pthread_mutex_unlock(&lock);
2892 - goto endsocket;
2893 - }
2894 -
2886 if (running_on_kernel < NETDATA_EBPF_KERNEL_5_0)
2887 em->mode = MODE_ENTRY;
2888
2898 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, socket_data.map_fd);
2889 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
2890 if (!probe_links) {
2891 pthread_mutex_unlock(&lock);
2892 goto endsocket;
collectors/ebpf.plugin/ebpf_softirq.c
+1 -9
@@ -28,8 +28,6 @@ static ebpf_local_maps_t softirq_maps[] = {
28 }
29 };
30
31 -static ebpf_data_t softirq_data;
32 -
31 #define SOFTIRQ_TP_CLASS_IRQ "irq"
32 static ebpf_tracepoint_t softirq_tracepoints[] = {
33 {.enabled = false, .class = SOFTIRQ_TP_CLASS_IRQ, .event = "softirq_entry"},
@@ -246,22 +244,16 @@ void *ebpf_softirq_thread(void *ptr)
244 ebpf_module_t *em = (ebpf_module_t *)ptr;
245 em->maps = softirq_maps;
246
249 - fill_ebpf_data(&softirq_data);
250 -
247 if (!em->enabled) {
248 goto endsoftirq;
249 }
250
255 - if (ebpf_update_kernel(&softirq_data)) {
256 - goto endsoftirq;
257 - }
258 -
251 if (ebpf_enable_tracepoints(softirq_tracepoints) == 0) {
252 em->enabled = CONFIG_BOOLEAN_NO;
253 goto endsoftirq;
254 }
255
264 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, softirq_data.map_fd);
256 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
257 if (!probe_links) {
258 goto endsoftirq;
259 }
collectors/ebpf.plugin/ebpf_swap.c
+1 -7
@@ -15,7 +15,6 @@ static netdata_idx_t *swap_values = NULL;
15
16 netdata_publish_swap_t **swap_pid = NULL;
17
18 -static ebpf_data_t swap_data;
18 struct config swap_config = { .first_section = NULL,
19 .last_section = NULL,
20 .mutex = NETDATA_MUTEX_INITIALIZER,
@@ -421,18 +420,13 @@ void *ebpf_swap_thread(void *ptr)
420
421 ebpf_module_t *em = (ebpf_module_t *)ptr;
422 em->maps = swap_maps;
424 - fill_ebpf_data(&swap_data);
423
424 ebpf_update_pid_table(&swap_maps[NETDATA_PID_SWAP_TABLE], em);
425
426 if (!em->enabled)
427 goto endswap;
428
431 - if (ebpf_update_kernel(&swap_data)) {
432 - goto endswap;
433 - }
434 -
435 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, swap_data.map_fd);
429 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
430 if (!probe_links) {
431 goto endswap;
432 }
collectors/ebpf.plugin/ebpf_sync.c
+25 -14
@@ -3,8 +3,6 @@
3 #include "ebpf.h"
4 #include "ebpf_sync.h"
5
6 -static ebpf_data_t sync_data;
7 -
6 static char *sync_counter_dimension_name[NETDATA_SYNC_IDX_END] = { "sync", "syncfs", "msync", "fsync", "fdatasync",
7 "sync_file_range" };
8 static netdata_syscall_stat_t sync_counter_aggregated_data[NETDATA_SYNC_IDX_END];
@@ -17,6 +15,28 @@ static netdata_idx_t sync_hash_values[NETDATA_SYNC_IDX_END];
15 struct netdata_static_thread sync_threads = {"SYNC KERNEL", NULL, NULL, 1,
16 NULL, NULL, NULL};
17
18 +static ebpf_local_maps_t sync_maps[] = {{.name = "tbl_sync", .internal_input = NETDATA_SYNC_END,
19 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
20 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
21 + {.name = "tbl_syncfs", .internal_input = NETDATA_SYNC_END,
22 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
23 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
24 + {.name = "tbl_msync", .internal_input = NETDATA_SYNC_END,
25 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
26 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
27 + {.name = "tbl_fsync", .internal_input = NETDATA_SYNC_END,
28 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
29 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
30 + {.name = "tbl_fdatasync", .internal_input = NETDATA_SYNC_END,
31 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
32 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
33 + {.name = "tbl_syncfr", .internal_input = NETDATA_SYNC_END,
34 + .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
35 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
36 + {.name = NULL, .internal_input = 0, .user_input = 0,
37 + .type = NETDATA_EBPF_MAP_CONTROLLER,
38 + .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}};
39 +
40 struct config sync_config = { .first_section = NULL,
41 .last_section = NULL,
42 .mutex = NETDATA_MUTEX_INITIALIZER,
@@ -53,15 +73,8 @@ static int ebpf_sync_initialize_syscall(ebpf_module_t *em)
73 for (i = 0; local_syscalls[i].syscall; i++) {
74 ebpf_sync_syscalls_t *w = &local_syscalls[i];
75 if (!w->probe_links && w->enabled) {
56 - fill_ebpf_data(&w->kernel_info);
57 - if (ebpf_update_kernel(&w->kernel_info)) {
58 - em->thread_name = saved_name;
59 - error("Cannot update the kernel for eBPF module %s", w->syscall);
60 - return -1;
61 - }
62 -
76 em->thread_name = w->syscall;
64 - w->probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &w->objects, w->kernel_info.map_fd);
77 + w->probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &w->objects);
78 if (!w->probe_links) {
79 em->thread_name = saved_name;
80 return -1;
@@ -95,7 +108,7 @@ static void read_global_table()
108 int i;
109 for (i = 0; local_syscalls[i].syscall; i++) {
110 if (local_syscalls[i].enabled) {
98 - int fd = local_syscalls[i].kernel_info.map_fd[NETDATA_SYNC_GLOBLAL_TABLE];
111 + int fd = sync_maps[i].map_fd;
112 if (!bpf_map_lookup_elem(fd, &idx, &stored)) {
113 sync_hash_values[i] = stored;
114 }
@@ -228,8 +241,6 @@ void ebpf_sync_cleanup_objects()
241 for (i = 0; local_syscalls[i].syscall; i++) {
242 ebpf_sync_syscalls_t *w = &local_syscalls[i];
243 if (w->probe_links) {
231 - freez(w->kernel_info.map_fd);
232 -
244 struct bpf_program *prog;
245 size_t j = 0 ;
246 bpf_object__for_each_program(prog, w->objects) {
@@ -358,7 +369,7 @@ void *ebpf_sync_thread(void *ptr)
369 netdata_thread_cleanup_push(ebpf_sync_cleanup, ptr);
370
371 ebpf_module_t *em = (ebpf_module_t *)ptr;
361 - fill_ebpf_data(&sync_data);
372 + em->maps = sync_maps;
373
374 ebpf_sync_parse_syscalls();
375
collectors/ebpf.plugin/ebpf_sync.h
-2
@@ -37,8 +37,6 @@ typedef struct ebpf_sync_syscalls {
37
38 struct bpf_object *objects;
39 struct bpf_link **probe_links;
40 -
41 - ebpf_data_t kernel_info;
40 } ebpf_sync_syscalls_t;
41
42 enum netdata_sync_charts {
collectors/ebpf.plugin/ebpf_vfs.c
+1 -9
@@ -16,8 +16,6 @@ static netdata_publish_syscall_t vfs_publish_aggregated[NETDATA_KEY_PUBLISH_VFS_
16 netdata_publish_vfs_t **vfs_pid = NULL;
17 netdata_publish_vfs_t *vfs_vector = NULL;
18
19 -static ebpf_data_t vfs_data;
20 -
19 static ebpf_local_maps_t vfs_maps[] = {{.name = "tbl_vfs_pid", .internal_input = ND_EBPF_DEFAULT_PID_SIZE,
20 .user_input = 0, .type = NETDATA_EBPF_MAP_RESIZABLE | NETDATA_EBPF_MAP_PID,
21 .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED},
@@ -84,7 +82,6 @@ static void ebpf_vfs_cleanup(void *ptr)
82 UNUSED(dt);
83 }
84
87 - freez(vfs_data.map_fd);
85 freez(vfs_hash_values);
86 freez(vfs_vector);
87
@@ -896,7 +893,6 @@ void *ebpf_vfs_thread(void *ptr)
893
894 ebpf_module_t *em = (ebpf_module_t *)ptr;
895 em->maps = vfs_maps;
899 - fill_ebpf_data(&vfs_data);
896
897 ebpf_update_pid_table(&vfs_maps[NETDATA_VFS_PID], em);
898
@@ -905,11 +901,7 @@ void *ebpf_vfs_thread(void *ptr)
901 if (!em->enabled)
902 goto endvfs;
903
908 - if (ebpf_update_kernel(&vfs_data)) {
909 - goto endvfs;
910 - }
911 -
912 - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects, vfs_data.map_fd);
904 + probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects);
905 if (!probe_links) {
906 goto endvfs;
907 }
libnetdata/ebpf/ebpf.c
+31 -22
@@ -64,13 +64,19 @@ int clean_kprobe_events(FILE *out, int pid, netdata_ebpf_events_t *ptr)
64
65 //----------------------------------------------------------------------------------------------------------------------
66
67 -int get_kernel_version(char *out, int size)
67 +/**
68 + * Get Kernel version
69 + *
70 + * Get the current kernel from /proc and returns an integer value representing it
71 + *
72 + * @return it returns a value representing the kernel version.
73 + */
74 +int ebpf_get_kernel_version()
75 {
76 char major[16], minor[16], patch[16];
77 char ver[VERSION_STRING_LEN];
78 char *version = ver;
79
73 - out[0] = '\0';
80 int fd = open("/proc/sys/kernel/osrelease", O_RDONLY);
81 if (fd < 0)
82 return -1;
@@ -104,10 +110,6 @@ int get_kernel_version(char *out, int size)
110 *move++ = *version++;
111 *move = '\0';
112
107 - fd = snprintf(out, (size_t)size, "%s.%s.%s", major, minor, patch);
108 - if (fd > size)
109 - error("The buffer to store kernel version is not smaller than necessary.");
110 -
113 return ((int)(str2l(major) * 65536) + (int)(str2l(minor) * 256) + (int)str2l(patch));
114 }
115
@@ -272,14 +274,24 @@ char *ebpf_kernel_suffix(int version, int isrh)
274
275 //----------------------------------------------------------------------------------------------------------------------
276
275 -int ebpf_update_kernel(ebpf_data_t *ed)
277 +/**
278 + * Update Kernel
279 + *
280 + * Update string used to load eBPF programs
281 + *
282 + * @param ks vector to store the value
283 + * @param length available length to store kernel
284 + * @param isrh Is a Red Hat distribution?
285 + * @param version the kernel version
286 + */
287 +void ebpf_update_kernel(char *ks, size_t length, int isrh, int version)
288 {
277 - char *kernel = ebpf_kernel_suffix(ed->running_on_kernel, (ed->isrh < 0) ? 0 : 1);
278 - size_t length = strlen(kernel);
279 - strncpyz(ed->kernel_string, kernel, length);
280 - ed->kernel_string[length] = '\0';
281 -
282 - return 0;
289 + char *kernel = ebpf_kernel_suffix(version, (isrh < 0) ? 0 : 1);
290 + size_t len = strlen(kernel);
291 + if (len > length)
292 + len = length - 1;
293 + strncpyz(ks, kernel, len);
294 + ks[len] = '\0';
295 }
296
297 static int select_file(char *name, const char *program, size_t length, int mode, char *kernel_string)
@@ -386,15 +398,14 @@ static struct bpf_link **ebpf_attach_programs(struct bpf_object *obj, size_t len
398 return links;
399 }
400
389 -static void ebpf_update_maps(ebpf_module_t *em, int *map_fd, struct bpf_object *obj)
401 +static void ebpf_update_maps(ebpf_module_t *em, struct bpf_object *obj)
402 {
391 - if (!map_fd)
403 + if (!em->maps)
404 return;
405
406 ebpf_local_maps_t *maps = em->maps;
407 struct bpf_map *map;
396 - size_t i = 0;
397 - bpf_map__for_each(map, obj)
408 + bpf_map__for_each(map, obj)
409 {
410 int fd = bpf_map__fd(map);
411 if (maps) {
@@ -408,8 +419,6 @@ static void ebpf_update_maps(ebpf_module_t *em, int *map_fd, struct bpf_object *
419 j++;
420 }
421 }
411 - map_fd[i] = fd;
412 - i++;
422 }
423 }
424
@@ -420,7 +429,7 @@ static void ebpf_update_controller(ebpf_module_t *em, struct bpf_object *obj)
429 return;
430
431 struct bpf_map *map;
423 - bpf_map__for_each(map, obj)
432 + bpf_map__for_each(map, obj)
433 {
434 size_t i = 0;
435 while (maps[i].name) {
@@ -441,7 +450,7 @@ static void ebpf_update_controller(ebpf_module_t *em, struct bpf_object *obj)
450 }
451
452 struct bpf_link **ebpf_load_program(char *plugins_dir, ebpf_module_t *em, char *kernel_string,
444 - struct bpf_object **obj, int *map_fd)
453 + struct bpf_object **obj)
454 {
455 char lpath[4096];
456 char lname[128];
@@ -466,7 +475,7 @@ struct bpf_link **ebpf_load_program(char *plugins_dir, ebpf_module_t *em, char *
475 return NULL;
476 }
477
469 - ebpf_update_maps(em, map_fd, *obj);
478 + ebpf_update_maps(em, *obj);
479 ebpf_update_controller(em, *obj);
480
481 size_t count_programs = ebpf_count_programs(*obj);
libnetdata/ebpf/ebpf.h
+3 -4
@@ -166,16 +166,15 @@ typedef struct ebpf_module {
166 const char *config_file;
167 } ebpf_module_t;
168
169 -extern int get_kernel_version(char *out, int size);
169 +extern int ebpf_get_kernel_version();
170 extern int get_redhat_release();
171 extern int has_condition_to_run(int version);
172 extern char *ebpf_kernel_suffix(int version, int isrh);
173 -extern int ebpf_update_kernel(ebpf_data_t *ef);
173 +extern void ebpf_update_kernel(char *ks, size_t length, int isrh, int version);
174 extern struct bpf_link **ebpf_load_program(char *plugins_dir,
175 ebpf_module_t *em,
176 char *kernel_string,
177 - struct bpf_object **obj,
178 - int *map_fd);
177 + struct bpf_object **obj);
178
179 extern void ebpf_mount_config_name(char *filename, size_t length, char *path, const char *config);
180 extern int ebpf_load_config(struct config *config, char *filename);
netdata-installer.sh
+22 -21
@@ -944,8 +944,28 @@ bundle_jsonc
944
945 # -----------------------------------------------------------------------------
946
947 +get_kernel_version() {
948 + r="$(uname -r | cut -f 1 -d '-')"
949 +
950 + read -r -a p <<< "$(echo "${r}" | tr '.' ' ')"
951 +
952 + printf "%03d%03d%03d" "${p[0]}" "${p[1]}" "${p[2]}"
953 +}
954 +
955 +rename_libbpf_packaging() {
956 + if [ "$(get_kernel_version)" -ge "005004014" ]; then
957 + cp packaging/current_libbpf.checksums packaging/libbpf.checksums
958 + cp packaging/current_libbpf.version packaging/libbpf.version
959 + else
960 + cp packaging/libbpf_0_0_9.checksums packaging/libbpf.checksums
961 + cp packaging/libbpf_0_0_9.version packaging/libbpf.version
962 + fi
963 +}
964 +
965 +
966 build_libbpf() {
967 pushd "${1}/src" > /dev/null || exit 1
968 + mkdir root build
969 run env CFLAGS=-fPIC CXXFLAGS= LDFLAGS= BUILD_STATIC_ONLY=y OBJDIR=build DESTDIR=.. ${make} ${MAKEOPTS} install
970 popd > /dev/null || exit 1
971 }
@@ -970,6 +990,8 @@ bundle_libbpf() {
990 return 0
991 fi
992
993 + rename_libbpf_packaging
994 +
995 progress "Prepare libbpf"
996
997 LIBBPF_PACKAGE_VERSION="$(cat packaging/libbpf.version)"
@@ -1569,27 +1591,6 @@ install_go() {
1591
1592 install_go
1593
1572 -function get_kernel_version() {
1573 - r="$(uname -r | cut -f 1 -d '-')"
1574 -
1575 - read -r -a p <<< "$(echo "${r}" | tr '.' ' ')"
1576 -
1577 - printf "%03d%03d%03d" "${p[0]}" "${p[1]}" "${p[2]}"
1578 -}
1579 -
1580 -function get_rh_version() {
1581 - if [ ! -f /etc/redhat-release ]; then
1582 - printf "000000000"
1583 - return
1584 - fi
1585 -
1586 - r="$(cut -f 4 -d ' ' < /etc/redhat-release)"
1587 -
1588 - read -r -a p <<< "$(echo "${r}" | tr '.' ' ')"
1589 -
1590 - printf "%03d%03d%03d" "${p[0]}" "${p[1]}" "${p[2]}"
1591 -}
1592 -
1594 detect_libc() {
1595 libc=
1596 if ldd --version 2>&1 | grep -q -i glibc; then
packaging/current_ebpf.checksums new
+3
@@ -0,0 +1,3 @@
1 +826c2b1e17df316d5667ae78cab0fbc7aacbb65479afe601175a29fdb6499853 netdata-kernel-collector-glibc-v0.7.10.tar.xz
2 +e7d74be56d80c8a999bf0428c059e8dbfbcaed62eeb247f99970c4b01808ab6d netdata-kernel-collector-musl-v0.7.10.tar.xz
3 +f2dbf0402fcaf172b09bacf1e60dbb2ccd69cea5bc4af2a8f66be2e0e37d7025 netdata-kernel-collector-static-v0.7.10.tar.xz
packaging/current_ebpf.version new
+1
@@ -0,0 +1 @@
1 +v0.7.10
packaging/current_libbpf.checksums new
+1
@@ -0,0 +1 @@
1 +1e4c81c2695cad65fd6a585fb6d8195c933f81d4bc2352964d73d17ad0b08b40 v0.4.0_netdata.tar.gz
packaging/current_libbpf.version new
+1
@@ -0,0 +1 @@
1 +0.4.0_netdata
packaging/ebpf.checksums
+3 -3
@@ -1,3 +1,3 @@
1 -826c2b1e17df316d5667ae78cab0fbc7aacbb65479afe601175a29fdb6499853 netdata-kernel-collector-glibc-v0.7.10.tar.xz
2 -e7d74be56d80c8a999bf0428c059e8dbfbcaed62eeb247f99970c4b01808ab6d netdata-kernel-collector-musl-v0.7.10.tar.xz
3 -f2dbf0402fcaf172b09bacf1e60dbb2ccd69cea5bc4af2a8f66be2e0e37d7025 netdata-kernel-collector-static-v0.7.10.tar.xz
1 +7db767f09bd422c2e15c7bd8af47eea9c32f3c435a1166e02ac65abad36fd6e4 netdata-kernel-collector-glibc-v0.8.0.tar.xz
2 +705da99b6f7d782f1eca1924b12629826ae15844ab781555d7849a9baa682e50 netdata-kernel-collector-musl-v0.8.0.tar.xz
3 +13d48b50786d007cf10e35ce7b9641935b5df684d2637f122a7a51651dd5c8a6 netdata-kernel-collector-static-v0.8.0.tar.xz
packaging/ebpf.version
+2 -1
@@ -1 +1,2 @@
1 -v0.7.10
1 +v0.8.0
2 +
packaging/libbpf.checksums
+1 -1
@@ -1 +1 @@
1 -fc33402ba33c8f8c5aa18afbb86a9932965886f2906c50e8f2110a1a2126e3ee v0.0.9_netdata-1.tar.gz
1 +1e4c81c2695cad65fd6a585fb6d8195c933f81d4bc2352964d73d17ad0b08b40 v0.4.0_netdata.tar.gz
packaging/libbpf.version
+1 -1
@@ -1 +1 @@
1 -0.0.9_netdata-1
1 +0.4.0_netdata
packaging/libbpf_0_0_9.checksums new
+1
@@ -0,0 +1 @@
1 +fc33402ba33c8f8c5aa18afbb86a9932965886f2906c50e8f2110a1a2126e3ee v0.0.9_netdata-1.tar.gz
packaging/libbpf_0_0_9.version new
+1
@@ -0,0 +1 @@
1 +0.0.9_netdata-1
tests/ebpf/README.md new
+1
@@ -0,0 +1 @@
1 +The file `sync_tester.c` can be used to fill all dimensions present in synchronization submenu.
tests/ebpf/sync_tester.c new
+120
@@ -0,0 +1,120 @@
1 +#include <errno.h>
2 +#include <string.h>
3 +#include <stdio.h>
4 +#include <sys/stat.h>
5 +#include <sys/types.h>
6 +#include <sys/mman.h>
7 +#include <sys/types.h>
8 +
9 +#define _GNU_SOURCE /* See feature_test_macros(7) */
10 +#define __USE_GNU
11 +#include <fcntl.h>
12 +#include <unistd.h>
13 +
14 +void test_sync_file_range(char *output, char *text, size_t length)
15 +{
16 + int fd = open (output, O_WRONLY | O_CREAT | O_APPEND, 0660);
17 + if (fd < 0 ) {
18 + perror("Cannot get page size");
19 + return;
20 + }
21 +
22 + int i;
23 + size_t offset = 0;
24 + for ( i = 0 ; i < 10000; i++ ) {
25 + write(fd, text, length);
26 + sync_file_range(fd, offset, length, SYNC_FILE_RANGE_WRITE);
27 + offset += length;
28 + }
29 +
30 + close(fd);
31 + sleep(5);
32 +}
33 +
34 +// test based on IBM example https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_71/apis/msync.htm
35 +void test_msync(char *output, char *text, size_t length)
36 +{
37 + int pagesize = sysconf(_SC_PAGE_SIZE);
38 + if (pagesize < 0) {
39 + perror("Cannot get page size");
40 + return;
41 + }
42 +
43 + int fd = open(output, (O_CREAT | O_TRUNC | O_RDWR), (S_IRWXU | S_IRWXG | S_IRWXO));
44 + if (fd < 0 ) {
45 + perror("Cannot open file");
46 + return;
47 + }
48 +
49 + off_t lastoffset = lseek( fd, pagesize, SEEK_SET);
50 + ssize_t written = write(fd, " ", 1);
51 + if ( written != 1 ) {
52 + perror("Write error. ");
53 + close(fd);
54 + return;
55 + }
56 +
57 + off_t my_offset = 0;
58 + void *address = mmap(NULL, pagesize, PROT_WRITE, MAP_SHARED, fd, my_offset);
59 +
60 + if ( address == MAP_FAILED ) {
61 + perror("Map error. ");
62 + close(fd);
63 + return;
64 + }
65 +
66 + (void) strcpy( (char*) address, text);
67 +
68 + if ( msync( address, pagesize, MS_SYNC) < 0 ) {
69 + perror("msync failed with error:");
70 + }
71 +
72 + close(fd);
73 + sleep(5);
74 +}
75 +
76 +void test_synchronization(char *output, char *text, size_t length, int (*fcnt)(int))
77 +{
78 + int fd = open (output, O_WRONLY | O_CREAT | O_APPEND, 0660);
79 + if (fd < 0 ) {
80 + perror("Cannot get page size");
81 + return;
82 + }
83 +
84 + int i;
85 + for ( i = 0 ; i < 10000; i++ )
86 + write(fd, text, length);
87 +
88 + fcnt(fd);
89 + close(fd);
90 +
91 + sleep(5);
92 +}
93 +
94 +void remove_files(char **files) {
95 + size_t i = 0;
96 + while (files[i]) {
97 + unlink(files[i]);
98 + i++;
99 + }
100 +}
101 +
102 +int main()
103 +{
104 + char *default_text = { "This is a simple example to test a PR. The sleep is used to create different peaks on charts.\n" };
105 + char *files[] = { "fsync.txt", "fdatasync.txt", "syncfs.txt", "msync.txt", "sync_file_range.txt", NULL };
106 + size_t length = strlen(default_text);
107 + test_synchronization(files[0], default_text, length, fsync);
108 + test_synchronization(files[1], default_text, length, fdatasync);
109 + test_synchronization(files[2], default_text, length, syncfs);
110 +
111 + test_msync(files[3], default_text, length);
112 +
113 + test_sync_file_range(files[4], default_text, length);
114 +
115 + sync();
116 +
117 + remove_files(files);
118 +
119 + return 0;
120 +}