summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2022-06-22 22:51:07 -0700
committerMaciej Żenczykowski <maze@google.com>2022-06-23 13:08:38 +0000
commit37b3d06333d05caa1a4ba26ad7d00f8e381d0162 (patch)
tree612e8d224624a5121f3358d69267f003b14e7919
parent98ec8cf05b8a00bf94f6318850a4f8af77927699 (diff)
downloadbpf-37b3d06333d05caa1a4ba26ad7d00f8e381d0162.tar.gz
bpfloader: add ability to disable btfloader
BTF support was added to bpfloader during Android T dev cycle. As it causes bpfloader boot time process to shell out to a new btfloader subprocess for every bpf.o file with BTF debugging information compiled in, I'm worried this might have unforeseen consequences - things like crashes or boot time bpfloader cpu regressions. However, BTF is exceedingly useful for debugging, and it would be a huge pity if we were forced to disable it and keep it disabled in mainline tethering module just to support Android T devices for the next 5+ years. It would also be a pity if the bpf.o files in prebuilt mainline tethering apex in dev branches (like tm-dev) did not include BTF debug information simply due to compatibility with older kernels or OSes, since this would require rebuilding the module everytime BTF information could be of use. One of the things functioning BTF enables is 'cat /sys/fs/bpf/map_*' as root on a userdebug build. Among other things this can be used to verify that in kernel bpf map state matches that dumped by the mainline module's pretty dump code. Even if there's issues wrt. BTF in Android T (or on older kernels), we can always fix them in Android U or later (for example build btfloader into bpfloader to avoid exec overhead, etc...). Bug: 218408035 Bug: 230585250 Bug: 235559605 Test: TreeHugger, cuttlefish devices boots, and: adb root && adb shell cat /sys/fs/bpf/map_time_in_state_cpu_last_pid_map continues to show information which is available due to BTF debug provided in /system/etc/bpf/time_in_state.o file (due to "btf: true" in Android.bp) Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I553e90e0414453f8f3aaca8cf05d5decc8b911a2
-rw-r--r--libbpf_android/Loader.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libbpf_android/Loader.cpp b/libbpf_android/Loader.cpp
index 47cf4c9..1c462dd 100644
--- a/libbpf_android/Loader.cpp
+++ b/libbpf_android/Loader.cpp
@@ -724,13 +724,16 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>&
ret = getSectionSymNames(elfFile, "maps", mapNames);
if (ret) return ret;
+ unsigned btfMinBpfLoaderVer = readSectionUint("btf_min_bpfloader_ver", elfFile, 0);
+ unsigned btfMinKernelVer = readSectionUint("btf_min_kernel_ver", elfFile, 0);
+ unsigned kvers = kernelVersion();
+
std::optional<unique_fd> btfFd;
- if (!readSectionByName(".BTF", elfFile, btfData)) {
+ if ((BPFLOADER_VERSION >= btfMinBpfLoaderVer) && (kvers >= btfMinKernelVer) &&
+ (!readSectionByName(".BTF", elfFile, btfData))) {
btfFd = getMapBtfInfo(elfPath, btfTypeIdMap);
}
- unsigned kvers = kernelVersion();
-
for (int i = 0; i < (int)mapNames.size(); i++) {
if (BPFLOADER_VERSION < md[i].bpfloader_min_ver) {
ALOGI("skipping map %s which requires bpfloader min ver 0x%05x", mapNames[i].c_str(),