*/
 struct btf *btf__load_vmlinux_btf(void)
 {
+       const char *sysfs_btf_path = "/sys/kernel/btf/vmlinux";
+       /* fall back locations, trying to find vmlinux on disk */
        const char *locations[] = {
-               /* try canonical vmlinux BTF through sysfs first */
-               "/sys/kernel/btf/vmlinux",
-               /* fall back to trying to find vmlinux on disk otherwise */
                "/boot/vmlinux-%1$s",
                "/lib/modules/%1$s/vmlinux-%1$s",
                "/lib/modules/%1$s/build/vmlinux",
        struct btf *btf;
        int i, err;
 
-       uname(&buf);
+       /* is canonical sysfs location accessible? */
+       if (faccessat(AT_FDCWD, sysfs_btf_path, F_OK, AT_EACCESS) < 0) {
+               pr_warn("kernel BTF is missing at '%s', was CONFIG_DEBUG_INFO_BTF enabled?\n",
+                       sysfs_btf_path);
+       } else {
+               btf = btf__parse(sysfs_btf_path, NULL);
+               if (!btf) {
+                       err = -errno;
+                       pr_warn("failed to read kernel BTF from '%s': %d\n", sysfs_btf_path, err);
+                       return libbpf_err_ptr(err);
+               }
+               pr_debug("loaded kernel BTF from '%s'\n", path);
+               return btf;
+       }
 
+       /* try fallback locations */
+       uname(&buf);
        for (i = 0; i < ARRAY_SIZE(locations); i++) {
                snprintf(path, PATH_MAX, locations[i], buf.release);