libbpf-tools: fix some minor issues of ext4dist
authorKenta Tada <Kenta.Tada@sony.com>
Fri, 2 Apr 2021 14:42:03 +0000 (23:42 +0900)
committeryonghong-song <ys114321@gmail.com>
Sun, 25 Apr 2021 17:06:42 +0000 (10:06 -0700)
* Fix the check of the existence of module BTFs
* Initialize the global variable

Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
libbpf-tools/ext4dist.bpf.c
libbpf-tools/ext4dist.c

index a68d93418803b525154ebc52b38698303ce0e974..a74a953dee1afc66483435c19c5414e5a5ffa670 100644 (file)
@@ -12,7 +12,7 @@ const volatile pid_t targ_tgid = 0;
 
 #define MAX_ENTRIES    10240
 
-struct hist hists[__MAX_FOP_TYPE];
+struct hist hists[__MAX_FOP_TYPE] = {};
 
 struct {
        __uint(type, BPF_MAP_TYPE_HASH);
index 2593e4318caabcb9635ac20974472d588a8d26d6..4d66ea93200f5fa495db7149bb90f0f666e6e1d1 100644 (file)
@@ -152,7 +152,7 @@ static bool should_fallback(void)
         * we can use fentry to get better performance, otherwise we need
         * to fall back to use kprobe to be compatible with the old kernel.
         */
-       if (is_kernel_module("ext4") && !access("/sys/kernel/btf/ext4", R_OK))
+       if (is_kernel_module("ext4") && access("/sys/kernel/btf/ext4", R_OK))
                return true;
        return false;
 }