summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2022-01-10 13:11:59 +0000
committerGitHub <noreply@github.com>2022-01-10 13:11:59 +0000
commitc2c0b688726fdf6ce4cd77449cb58b87e23769b7 (patch)
treef4e07b66eadef4f94143bfd4adb84d27186571bd
parenteebcb8520c526523a0a471887783ba63392d7e24 (diff)
Fix cachestat on kernel 5.15.x (eBPF) (#11833)
-rw-r--r--collectors/ebpf.plugin/ebpf_mdflush.c7
-rw-r--r--libnetdata/ebpf/ebpf.c29
-rw-r--r--libnetdata/ebpf/ebpf.h8
-rw-r--r--packaging/ebpf.checksums6
-rw-r--r--packaging/ebpf.version2
5 files changed, 36 insertions, 16 deletions
diff --git a/collectors/ebpf.plugin/ebpf_mdflush.c b/collectors/ebpf.plugin/ebpf_mdflush.c
index e2420ec8ee..38980713f5 100644
--- a/collectors/ebpf.plugin/ebpf_mdflush.c
+++ b/collectors/ebpf.plugin/ebpf_mdflush.c
@@ -294,6 +294,13 @@ void *ebpf_mdflush_thread(void *ptr)
ebpf_module_t *em = (ebpf_module_t *)ptr;
em->maps = mdflush_maps;
+ char *md_flush_request = ebpf_find_symbol("md_flush_request");
+ if (!md_flush_request) {
+ em->enabled = CONFIG_BOOLEAN_NO;
+ error("Cannot monitor MD devices, because md is not loaded.");
+ }
+ freez(md_flush_request);
+
if (!em->enabled) {
goto endmdflush;
}
diff --git a/libnetdata/ebpf/ebpf.c b/libnetdata/ebpf/ebpf.c
index 1ccaa7b417..3aef243a47 100644
--- a/libnetdata/ebpf/ebpf.c
+++ b/libnetdata/ebpf/ebpf.c
@@ -257,7 +257,9 @@ char *ebpf_kernel_suffix(int version, int isrh)
else
return "3.10";
} else {
- if (version >= NETDATA_EBPF_KERNEL_5_11)
+ if (version >= NETDATA_EBPF_KERNEL_5_15)
+ return "5.15";
+ else if (version >= NETDATA_EBPF_KERNEL_5_11)
return "5.11";
else if (version >= NETDATA_EBPF_KERNEL_5_10)
return "5.10";
@@ -375,18 +377,21 @@ static struct bpf_link **ebpf_attach_programs(struct bpf_object *obj, size_t len
struct bpf_link **links = callocz(length , sizeof(struct bpf_link *));
size_t i = 0;
struct bpf_program *prog;
+ ebpf_specify_name_t *w;
bpf_object__for_each_program(prog, obj)
{
- links[i] = bpf_program__attach(prog);
- if (libbpf_get_error(links[i]) && names) {
+ if (names) {
const char *name = bpf_program__name(prog);
- ebpf_specify_name_t *w = ebpf_find_names(names, name);
- if (w) {
- enum bpf_prog_type type = bpf_program__get_type(prog);
- if (type == BPF_PROG_TYPE_KPROBE)
- links[i] = bpf_program__attach_kprobe(prog, w->retprobe, w->optional);
- }
- }
+ w = ebpf_find_names(names, name);
+ } else
+ w = NULL;
+
+ if (w) {
+ enum bpf_prog_type type = bpf_program__get_type(prog);
+ if (type == BPF_PROG_TYPE_KPROBE)
+ links[i] = bpf_program__attach_kprobe(prog, w->retprobe, w->optional);
+ } else
+ links[i] = bpf_program__attach(prog);
if (libbpf_get_error(links[i])) {
links[i] = NULL;
@@ -483,7 +488,7 @@ struct bpf_link **ebpf_load_program(char *plugins_dir, ebpf_module_t *em, char *
return ebpf_attach_programs(*obj, count_programs, em->names);
}
-static char *ebpf_update_name(char *search)
+char *ebpf_find_symbol(char *search)
{
char filename[FILENAME_MAX + 1];
char *ret = NULL;
@@ -521,7 +526,7 @@ void ebpf_update_names(ebpf_specify_name_t *opt, ebpf_module_t *em)
size_t i = 0;
while (opt[i].program_name) {
opt[i].retprobe = (mode == MODE_RETURN);
- opt[i].optional = ebpf_update_name(opt[i].function_to_attach);
+ opt[i].optional = ebpf_find_symbol(opt[i].function_to_attach);
i++;
}
diff --git a/libnetdata/ebpf/ebpf.h b/libnetdata/ebpf/ebpf.h
index 73128f529b..1da28d4cb3 100644
--- a/libnetdata/ebpf/ebpf.h
+++ b/libnetdata/ebpf/ebpf.h
@@ -46,6 +46,13 @@
#define NETDATA_RH_8 2048
/**
+ * Kernel 5.15
+ *
+ * 331520 = 5*65536 + 15*256
+ */
+#define NETDATA_EBPF_KERNEL_5_15 331520
+
+/**
* Kernel 5.11
*
* 330240 = 5*65536 + 11*256
@@ -182,6 +189,7 @@ extern void ebpf_mount_config_name(char *filename, size_t length, char *path, co
extern int ebpf_load_config(struct config *config, char *filename);
extern void ebpf_update_module(ebpf_module_t *em);
extern void ebpf_update_names(ebpf_specify_name_t *opt, ebpf_module_t *em);
+extern char *ebpf_find_symbol(char *search);
extern void ebpf_load_addresses(ebpf_addresses_t *fa, int fd);
extern void ebpf_fill_algorithms(int *algorithms, size_t length, int algorithm);
extern char **ebpf_fill_histogram_dimension(size_t maximum);
diff --git a/packaging/ebpf.checksums b/packaging/ebpf.checksums
index 8ecbc9ce16..d98e99b0a8 100644
--- a/packaging/ebpf.checksums
+++ b/packaging/ebpf.checksums
@@ -1,3 +1,3 @@
-7ffd13d0f32df93bc7868a7cf040e75c40a9e041f6bb7f4a591cc6ce71b1cf72 netdata-kernel-collector-glibc-v0.8.6.tar.xz
-05c10d57252941b7f6dbb8a726a243416942c58738015014dd764b4bcb0c2f9c netdata-kernel-collector-musl-v0.8.6.tar.xz
-2a607729a9093538624a94dfdbf2a3660eb4eb199f86962d38806d8e1e420a71 netdata-kernel-collector-static-v0.8.6.tar.xz
+44f21082c348b81f73034a986904207ee050379d51d6a6733a71323f2d36c8dd netdata-kernel-collector-glibc-v0.9.0.tar.xz
+9589070de6b7fe29fb0ea8f23394625c2887ddf3007bca9e65cfdb11ce41a7f7 netdata-kernel-collector-musl-v0.9.0.tar.xz
+f39c5c97f10d08ce72551a64aef8f9264346608e7d215afc910a5fe2158db868 netdata-kernel-collector-static-v0.9.0.tar.xz
diff --git a/packaging/ebpf.version b/packaging/ebpf.version
index 85c3002dca..f979adec64 100644
--- a/packaging/ebpf.version
+++ b/packaging/ebpf.version
@@ -1 +1 @@
-v0.8.6
+v0.9.0