1*f7c14bbaSAndroid Build Coastguard Worker<picture> 2*f7c14bbaSAndroid Build Coastguard Worker <source media="(prefers-color-scheme: dark)" srcset="assets/libbpf-logo-sideways-darkbg.png" width="40%"> 3*f7c14bbaSAndroid Build Coastguard Worker <img src="assets/libbpf-logo-sideways.png" width="40%"> 4*f7c14bbaSAndroid Build Coastguard Worker</picture> 5*f7c14bbaSAndroid Build Coastguard Worker 6*f7c14bbaSAndroid Build Coastguard WorkerLibbpf sync 7*f7c14bbaSAndroid Build Coastguard Worker=========== 8*f7c14bbaSAndroid Build Coastguard Worker 9*f7c14bbaSAndroid Build Coastguard WorkerLibbpf *authoritative source code* is developed as part of [bpf-next Linux source 10*f7c14bbaSAndroid Build Coastguard Workertree](https://kernel.googlesource.com/pub/scm/linux/kernel/git/bpf/bpf-next) under 11*f7c14bbaSAndroid Build Coastguard Worker`tools/lib/bpf` subdirectory and is periodically synced to Github. 12*f7c14bbaSAndroid Build Coastguard Worker 13*f7c14bbaSAndroid Build Coastguard WorkerMost of the mundane mechanical things like bpf and bpf-next tree merge, Git 14*f7c14bbaSAndroid Build Coastguard Workerhistory transformation, cherry-picking relevant commits, re-generating 15*f7c14bbaSAndroid Build Coastguard Workerauto-generated headers, etc. are taken care by 16*f7c14bbaSAndroid Build Coastguard Worker[sync-kernel.sh script](https://github.com/libbpf/libbpf/blob/master/scripts/sync-kernel.sh). 17*f7c14bbaSAndroid Build Coastguard WorkerBut occasionally human needs to do few extra things to make everything work 18*f7c14bbaSAndroid Build Coastguard Workernicely. 19*f7c14bbaSAndroid Build Coastguard Worker 20*f7c14bbaSAndroid Build Coastguard WorkerThis document goes over the process of syncing libbpf sources from Linux repo 21*f7c14bbaSAndroid Build Coastguard Workerto this Github repository. Feel free to contribute fixes and additions if you 22*f7c14bbaSAndroid Build Coastguard Workerrun into new problems not outlined here. 23*f7c14bbaSAndroid Build Coastguard Worker 24*f7c14bbaSAndroid Build Coastguard WorkerSetup expectations 25*f7c14bbaSAndroid Build Coastguard Worker------------------ 26*f7c14bbaSAndroid Build Coastguard Worker 27*f7c14bbaSAndroid Build Coastguard WorkerSync script has particular expectation of upstream Linux repo setup. It 28*f7c14bbaSAndroid Build Coastguard Workerexpects that current HEAD of that repo points to bpf-next's master branch and 29*f7c14bbaSAndroid Build Coastguard Workerthat there is a separate local branch pointing to bpf tree's master branch. 30*f7c14bbaSAndroid Build Coastguard WorkerThis is important, as the script will automatically merge their histories for 31*f7c14bbaSAndroid Build Coastguard Workerthe purpose of libbpf sync. 32*f7c14bbaSAndroid Build Coastguard Worker 33*f7c14bbaSAndroid Build Coastguard WorkerBelow, we assume that Linux repo is located at `~/linux`, it's current head is 34*f7c14bbaSAndroid Build Coastguard Workerat latest `bpf-next/master`, and libbpf's Github repo is located at 35*f7c14bbaSAndroid Build Coastguard Worker`~/libbpf`, checked out to latest commit on `master` branch. It doesn't matter 36*f7c14bbaSAndroid Build Coastguard Workerfrom where to run `sync-kernel.sh` script, but we'll be running it from inside 37*f7c14bbaSAndroid Build Coastguard Worker`~/libbpf`. 38*f7c14bbaSAndroid Build Coastguard Worker 39*f7c14bbaSAndroid Build Coastguard Worker``` 40*f7c14bbaSAndroid Build Coastguard Worker$ cd ~/linux && git remote -v | grep -E '^(bpf|bpf-next)' 41*f7c14bbaSAndroid Build Coastguard Workerbpf https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git (fetch) 42*f7c14bbaSAndroid Build Coastguard Workerbpf ssh://[email protected]/pub/scm/linux/kernel/git/bpf/bpf.git 43*f7c14bbaSAndroid Build Coastguard Worker(push) 44*f7c14bbaSAndroid Build Coastguard Workerbpf-next 45*f7c14bbaSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git (fetch) 46*f7c14bbaSAndroid Build Coastguard Workerbpf-next 47*f7c14bbaSAndroid Build Coastguard Workerssh://[email protected]/pub/scm/linux/kernel/git/bpf/bpf-next.git (push) 48*f7c14bbaSAndroid Build Coastguard Worker$ git branch -vv | grep -E '^? (master|bpf-master)' 49*f7c14bbaSAndroid Build Coastguard Worker* bpf-master 2d311f480b52 [bpf/master] riscv, bpf: Fix patch_text implicit declaration 50*f7c14bbaSAndroid Build Coastguard Worker master c8ee37bde402 [bpf-next/master] libbpf: Fix bpf_xdp_query() in old kernels 51*f7c14bbaSAndroid Build Coastguard Worker$ git checkout bpf-master && git pull && git checkout master && git pull 52*f7c14bbaSAndroid Build Coastguard Worker... 53*f7c14bbaSAndroid Build Coastguard Worker$ git log --oneline -n1 54*f7c14bbaSAndroid Build Coastguard Workerc8ee37bde402 (HEAD -> master, bpf-next/master) libbpf: Fix bpf_xdp_query() in old kernels 55*f7c14bbaSAndroid Build Coastguard Worker$ cd ~/libbpf && git checkout master && git pull 56*f7c14bbaSAndroid Build Coastguard WorkerYour branch is up to date with 'libbpf/master'. 57*f7c14bbaSAndroid Build Coastguard WorkerAlready up to date. 58*f7c14bbaSAndroid Build Coastguard Worker``` 59*f7c14bbaSAndroid Build Coastguard Worker 60*f7c14bbaSAndroid Build Coastguard WorkerRunning setup script 61*f7c14bbaSAndroid Build Coastguard Worker-------------------- 62*f7c14bbaSAndroid Build Coastguard Worker 63*f7c14bbaSAndroid Build Coastguard WorkerFirst step is to always run `sync-kernel.sh` script. It expects three arguments: 64*f7c14bbaSAndroid Build Coastguard Worker 65*f7c14bbaSAndroid Build Coastguard Worker``` 66*f7c14bbaSAndroid Build Coastguard Worker$ scripts/sync-kernel.sh <libbpf-repo> <kernel-repo> <bpf-branch> 67*f7c14bbaSAndroid Build Coastguard Worker``` 68*f7c14bbaSAndroid Build Coastguard Worker 69*f7c14bbaSAndroid Build Coastguard WorkerNote, that we'll store script's entire output in `/tmp/libbpf-sync.txt` and 70*f7c14bbaSAndroid Build Coastguard Workerput it into PR summary later on. **Please store scripts output and include it 71*f7c14bbaSAndroid Build Coastguard Workerin PR summary for others to check for anything unexpected and suspicious.** 72*f7c14bbaSAndroid Build Coastguard Worker 73*f7c14bbaSAndroid Build Coastguard Worker``` 74*f7c14bbaSAndroid Build Coastguard Worker$ scripts/sync-kernel.sh ~/libbpf ~/linux bpf-master | tee /tmp/libbpf-sync.txt 75*f7c14bbaSAndroid Build Coastguard WorkerDumping existing libbpf commit signatures... 76*f7c14bbaSAndroid Build Coastguard WorkerWORKDIR: /home/andriin/libbpf 77*f7c14bbaSAndroid Build Coastguard WorkerLINUX REPO: /home/andriin/linux 78*f7c14bbaSAndroid Build Coastguard WorkerLIBBPF REPO: /home/andriin/libbpf 79*f7c14bbaSAndroid Build Coastguard Worker... 80*f7c14bbaSAndroid Build Coastguard Worker``` 81*f7c14bbaSAndroid Build Coastguard Worker 82*f7c14bbaSAndroid Build Coastguard WorkerMost of the time this will go very uneventful. One expected case when sync 83*f7c14bbaSAndroid Build Coastguard Workerscript might require user intervention is if `bpf` tree has some libbpf fixes, 84*f7c14bbaSAndroid Build Coastguard Workerwhich is nowadays not a very frequent occurence. But if that happens, script 85*f7c14bbaSAndroid Build Coastguard Workerwill show you a diff between expected state as of latest bpf-next and synced 86*f7c14bbaSAndroid Build Coastguard WorkerGithub repo state. And will ask if these changes look good. Please use your 87*f7c14bbaSAndroid Build Coastguard Workerbest judgement to verify that differences are indeed from expected `bpf` tree 88*f7c14bbaSAndroid Build Coastguard Workerfixes. E.g., it might look like below: 89*f7c14bbaSAndroid Build Coastguard Worker 90*f7c14bbaSAndroid Build Coastguard Worker``` 91*f7c14bbaSAndroid Build Coastguard WorkerComparing list of files... 92*f7c14bbaSAndroid Build Coastguard WorkerComparing file contents... 93*f7c14bbaSAndroid Build Coastguard Worker--- /home/andriin/linux/include/uapi/linux/netdev.h 2023-02-27 16:54:42.270583372 -0800 94*f7c14bbaSAndroid Build Coastguard Worker+++ /home/andriin/libbpf/include/uapi/linux/netdev.h 2023-02-27 16:54:34.615530796 -0800 95*f7c14bbaSAndroid Build Coastguard Worker@@ -19,7 +19,7 @@ 96*f7c14bbaSAndroid Build Coastguard Worker * @NETDEV_XDP_ACT_XSK_ZEROCOPY: This feature informs if netdev supports AF_XDP 97*f7c14bbaSAndroid Build Coastguard Worker * in zero copy mode. 98*f7c14bbaSAndroid Build Coastguard Worker * @NETDEV_XDP_ACT_HW_OFFLOAD: This feature informs if netdev supports XDP hw 99*f7c14bbaSAndroid Build Coastguard Worker- * oflloading. 100*f7c14bbaSAndroid Build Coastguard Worker+ * offloading. 101*f7c14bbaSAndroid Build Coastguard Worker * @NETDEV_XDP_ACT_RX_SG: This feature informs if netdev implements non-linear 102*f7c14bbaSAndroid Build Coastguard Worker * XDP buffer support in the driver napi callback. 103*f7c14bbaSAndroid Build Coastguard Worker * @NETDEV_XDP_ACT_NDO_XMIT_SG: This feature informs if netdev implements 104*f7c14bbaSAndroid Build Coastguard Worker/home/andriin/linux/include/uapi/linux/netdev.h and /home/andriin/libbpf/include/uapi/linux/netdev.h are different! 105*f7c14bbaSAndroid Build Coastguard WorkerUnfortunately, there are some inconsistencies, please double check. 106*f7c14bbaSAndroid Build Coastguard WorkerDoes everything look good? [y/N]: 107*f7c14bbaSAndroid Build Coastguard Worker``` 108*f7c14bbaSAndroid Build Coastguard Worker 109*f7c14bbaSAndroid Build Coastguard WorkerIf it looks sensible and expected, type `y` and script will proceed. 110*f7c14bbaSAndroid Build Coastguard Worker 111*f7c14bbaSAndroid Build Coastguard WorkerIf sync is successful, your `~/linux` repo will be left in original state on 112*f7c14bbaSAndroid Build Coastguard Workerthe original HEAD commit. `~/libbpf` repo will now be on a new branch, named 113*f7c14bbaSAndroid Build Coastguard Worker`libbpf-sync-<timestamp>` (e.g., `libbpf-sync-2023-02-28T00-53-40.072Z`). 114*f7c14bbaSAndroid Build Coastguard Worker 115*f7c14bbaSAndroid Build Coastguard WorkerPush this branch into your fork of `libbpf/libbpf` Github repo and create a PR: 116*f7c14bbaSAndroid Build Coastguard Worker 117*f7c14bbaSAndroid Build Coastguard Worker``` 118*f7c14bbaSAndroid Build Coastguard Worker$ git push --set-upstream origin libbpf-sync-2023-02-28T00-53-40.072Z 119*f7c14bbaSAndroid Build Coastguard WorkerEnumerating objects: 130, done. 120*f7c14bbaSAndroid Build Coastguard WorkerCounting objects: 100% (115/115), done. 121*f7c14bbaSAndroid Build Coastguard WorkerDelta compression using up to 80 threads 122*f7c14bbaSAndroid Build Coastguard WorkerCompressing objects: 100% (28/28), done. 123*f7c14bbaSAndroid Build Coastguard WorkerWriting objects: 100% (32/32), 5.57 KiB | 1.86 MiB/s, done. 124*f7c14bbaSAndroid Build Coastguard WorkerTotal 32 (delta 21), reused 0 (delta 0), pack-reused 0 125*f7c14bbaSAndroid Build Coastguard Workerremote: Resolving deltas: 100% (21/21), completed with 9 local objects. 126*f7c14bbaSAndroid Build Coastguard Workerremote: 127*f7c14bbaSAndroid Build Coastguard Workerremote: Create a pull request for 'libbpf-sync-2023-02-28T00-53-40.072Z' on GitHub by visiting: 128*f7c14bbaSAndroid Build Coastguard Workerremote: https://github.com/anakryiko/libbpf/pull/new/libbpf-sync-2023-02-28T00-53-40.072Z 129*f7c14bbaSAndroid Build Coastguard Workerremote: 130*f7c14bbaSAndroid Build Coastguard WorkerTo github.com:anakryiko/libbpf.git 131*f7c14bbaSAndroid Build Coastguard Worker * [new branch] libbpf-sync-2023-02-28T00-53-40.072Z -> libbpf-sync-2023-02-28T00-53-40.072Z 132*f7c14bbaSAndroid Build Coastguard WorkerBranch 'libbpf-sync-2023-02-28T00-53-40.072Z' set up to track remote branch 'libbpf-sync-2023-02-28T00-53-40.072Z' from 'origin'. 133*f7c14bbaSAndroid Build Coastguard Worker``` 134*f7c14bbaSAndroid Build Coastguard Worker 135*f7c14bbaSAndroid Build Coastguard Worker**Please, adjust PR name to have a properly looking timestamp. Libbpf 136*f7c14bbaSAndroid Build Coastguard Workermaintainers will be very thankful for that!** 137*f7c14bbaSAndroid Build Coastguard Worker 138*f7c14bbaSAndroid Build Coastguard WorkerBy default Github will turn above branch name into PR with subject "Libbpf sync 139*f7c14bbaSAndroid Build Coastguard Worker2023 02 28 t00 53 40.072 z". Please fix this into a proper timestamp, e.g.: 140*f7c14bbaSAndroid Build Coastguard Worker"Libbpf sync 2023-02-28T00:53:40.072Z". Thank you! 141*f7c14bbaSAndroid Build Coastguard Worker 142*f7c14bbaSAndroid Build Coastguard Worker**Please don't forget to paste contents of /tmp/libbpf-sync.txt into PR 143*f7c14bbaSAndroid Build Coastguard Workersummary!** 144*f7c14bbaSAndroid Build Coastguard Worker 145*f7c14bbaSAndroid Build Coastguard WorkerOnce PR is created, libbpf CI will run a bunch of tests to check that 146*f7c14bbaSAndroid Build Coastguard Workereverything is good. In simple cases that would be all you'd need to do. In more 147*f7c14bbaSAndroid Build Coastguard Workercomplicated cases some extra adjustments might be necessary. 148*f7c14bbaSAndroid Build Coastguard Worker 149*f7c14bbaSAndroid Build Coastguard Worker**Please, keep naming and style consistent.** Prefix CI-related fixes with `ci: ` 150*f7c14bbaSAndroid Build Coastguard Workerprefix. If you had to modify sync script, prefix it with `sync: `. Also make 151*f7c14bbaSAndroid Build Coastguard Workersure that each such commit has `Signed-off-by: Your Full Name <[email protected]>`, 152*f7c14bbaSAndroid Build Coastguard Workerjust like you'd do that for Linux upstream patch. Libbpf closely follows kernel 153*f7c14bbaSAndroid Build Coastguard Workerconventions and styling, so please help maintaining that. 154*f7c14bbaSAndroid Build Coastguard Worker 155*f7c14bbaSAndroid Build Coastguard WorkerIncluding new sources 156*f7c14bbaSAndroid Build Coastguard Worker--------------------- 157*f7c14bbaSAndroid Build Coastguard Worker 158*f7c14bbaSAndroid Build Coastguard WorkerIf entirely new source files (typically `*.c`) were added to the library in the 159*f7c14bbaSAndroid Build Coastguard Workerkernel repository, it may be necessary to add these to the build system 160*f7c14bbaSAndroid Build Coastguard Workermanually (you may notice linker errors otherwise), because the script cannot 161*f7c14bbaSAndroid Build Coastguard Workerhandle such changes automatically. To that end, edit `src/Makefile` as 162*f7c14bbaSAndroid Build Coastguard Workernecessary. Commit 163*f7c14bbaSAndroid Build Coastguard Worker[c2495832ced4](https://github.com/libbpf/libbpf/commit/c2495832ced4239bcd376b9954db38a6addd89ca) 164*f7c14bbaSAndroid Build Coastguard Workeris an example of how to go about doing that. 165*f7c14bbaSAndroid Build Coastguard Worker 166*f7c14bbaSAndroid Build Coastguard WorkerSimilarly, if new public API header files were added, the `Makefile` will need 167*f7c14bbaSAndroid Build Coastguard Workerto be adjusted as well. 168*f7c14bbaSAndroid Build Coastguard Worker 169*f7c14bbaSAndroid Build Coastguard WorkerUpdating allow/deny lists 170*f7c14bbaSAndroid Build Coastguard Worker------------------------- 171*f7c14bbaSAndroid Build Coastguard Worker 172*f7c14bbaSAndroid Build Coastguard WorkerLibbpf CI intentionally runs a subset of latest BPF selftests on old kernel 173*f7c14bbaSAndroid Build Coastguard Worker(4.9 and 5.5, currently). It happens from time to time that some tests that 174*f7c14bbaSAndroid Build Coastguard Workerpreviously were successfully running on old kernels now don't, typically due to 175*f7c14bbaSAndroid Build Coastguard Workerreliance on some freshly added kernel feature. It might look something like this in [CI logs](https://github.com/libbpf/libbpf/actions/runs/4206303272/jobs/7299609578#step:4:2733): 176*f7c14bbaSAndroid Build Coastguard Worker 177*f7c14bbaSAndroid Build Coastguard Worker``` 178*f7c14bbaSAndroid Build Coastguard Worker All error logs: 179*f7c14bbaSAndroid Build Coastguard Worker serial_test_xdp_info:FAIL:get_xdp_none errno=2 180*f7c14bbaSAndroid Build Coastguard Worker #283 xdp_info:FAIL 181*f7c14bbaSAndroid Build Coastguard Worker Summary: 49/166 PASSED, 5 SKIPPED, 1 FAILED 182*f7c14bbaSAndroid Build Coastguard Worker``` 183*f7c14bbaSAndroid Build Coastguard Worker 184*f7c14bbaSAndroid Build Coastguard WorkerIn such case we can either work with upstream to fix test to be compatible with 185*f7c14bbaSAndroid Build Coastguard Workerold kernels, or we'll have to add a test into a denylist (or remove it from 186*f7c14bbaSAndroid Build Coastguard Workerallowlist, like was [done](https://github.com/libbpf/libbpf/commit/ea284299025bf85b85b4923191de6463cd43ccd6) 187*f7c14bbaSAndroid Build Coastguard Workerfor the case above). 188*f7c14bbaSAndroid Build Coastguard Worker 189*f7c14bbaSAndroid Build Coastguard Worker``` 190*f7c14bbaSAndroid Build Coastguard Worker$ find . -name '*LIST*' 191*f7c14bbaSAndroid Build Coastguard Worker./ci/vmtest/configs/ALLOWLIST-4.9.0 192*f7c14bbaSAndroid Build Coastguard Worker./ci/vmtest/configs/DENYLIST-5.5.0 193*f7c14bbaSAndroid Build Coastguard Worker./ci/vmtest/configs/DENYLIST-latest.s390x 194*f7c14bbaSAndroid Build Coastguard Worker./ci/vmtest/configs/DENYLIST-latest 195*f7c14bbaSAndroid Build Coastguard Worker./ci/vmtest/configs/ALLOWLIST-5.5.0 196*f7c14bbaSAndroid Build Coastguard Worker``` 197*f7c14bbaSAndroid Build Coastguard Worker 198*f7c14bbaSAndroid Build Coastguard WorkerPlease determine which tests need to be added/removed from which list. And then 199*f7c14bbaSAndroid Build Coastguard Workeradd that as a separate commit. **Please keep using the same branch name, so 200*f7c14bbaSAndroid Build Coastguard Workerthat the same PR can be updated.** There is no need to open new PRs for each 201*f7c14bbaSAndroid Build Coastguard Workersuch fix. 202*f7c14bbaSAndroid Build Coastguard Worker 203*f7c14bbaSAndroid Build Coastguard WorkerRegenerating vmlinux.h header 204*f7c14bbaSAndroid Build Coastguard Worker----------------------------- 205*f7c14bbaSAndroid Build Coastguard Worker 206*f7c14bbaSAndroid Build Coastguard WorkerTo compile latest BPF selftests against old kernels, we check in pre-generated 207*f7c14bbaSAndroid Build Coastguard Worker[vmlinux.h](https://github.com/libbpf/libbpf/blob/master/.github/actions/build-selftests/vmlinux.h) 208*f7c14bbaSAndroid Build Coastguard Workerheader file, located at `.github/actions/build-selftests/vmlinux.h`, which 209*f7c14bbaSAndroid Build Coastguard Workercontains type definitions from latest upstream kernel. When after libbpf sync 210*f7c14bbaSAndroid Build Coastguard Workerupstream BPF selftests require new kernel types, we'd need to regenerate 211*f7c14bbaSAndroid Build Coastguard Worker`vmlinux.h` and check it in as well. 212*f7c14bbaSAndroid Build Coastguard Worker 213*f7c14bbaSAndroid Build Coastguard WorkerThis will looks something like this in [CI logs](https://github.com/libbpf/libbpf/actions/runs/4198939244/jobs/7283214243#step:4:1903): 214*f7c14bbaSAndroid Build Coastguard Worker 215*f7c14bbaSAndroid Build Coastguard Worker``` 216*f7c14bbaSAndroid Build Coastguard Worker In file included from progs/test_spin_lock_fail.c:5: 217*f7c14bbaSAndroid Build Coastguard Worker /home/runner/work/libbpf/libbpf/.kernel/tools/testing/selftests/bpf/bpf_experimental.h:73:53: error: declaration of 'struct bpf_rb_root' will not be visible outside of this function [-Werror,-Wvisibility] 218*f7c14bbaSAndroid Build Coastguard Worker extern struct bpf_rb_node *bpf_rbtree_remove(struct bpf_rb_root *root, 219*f7c14bbaSAndroid Build Coastguard Worker ^ 220*f7c14bbaSAndroid Build Coastguard Worker /home/runner/work/libbpf/libbpf/.kernel/tools/testing/selftests/bpf/bpf_experimental.h:81:35: error: declaration of 'struct bpf_rb_root' will not be visible outside of this function [-Werror,-Wvisibility] 221*f7c14bbaSAndroid Build Coastguard Worker extern void bpf_rbtree_add(struct bpf_rb_root *root, struct bpf_rb_node *node, 222*f7c14bbaSAndroid Build Coastguard Worker ^ 223*f7c14bbaSAndroid Build Coastguard Worker /home/runner/work/libbpf/libbpf/.kernel/tools/testing/selftests/bpf/bpf_experimental.h:90:52: error: declaration of 'struct bpf_rb_root' will not be visible outside of this function [-Werror,-Wvisibility] 224*f7c14bbaSAndroid Build Coastguard Worker extern struct bpf_rb_node *bpf_rbtree_first(struct bpf_rb_root *root) __ksym; 225*f7c14bbaSAndroid Build Coastguard Worker ^ 226*f7c14bbaSAndroid Build Coastguard Worker 3 errors generated. 227*f7c14bbaSAndroid Build Coastguard Worker make: *** [Makefile:572: /home/runner/work/libbpf/libbpf/.kernel/tools/testing/selftests/bpf/test_spin_lock_fail.bpf.o] Error 1 228*f7c14bbaSAndroid Build Coastguard Worker make: *** Waiting for unfinished jobs.... 229*f7c14bbaSAndroid Build Coastguard Worker Error: Process completed with exit code 2. 230*f7c14bbaSAndroid Build Coastguard Worker``` 231*f7c14bbaSAndroid Build Coastguard Worker 232*f7c14bbaSAndroid Build Coastguard WorkerYou'll need to build latest upstream kernel from `bpf-next` tree, using BPF 233*f7c14bbaSAndroid Build Coastguard Workerselftest configs. Concat arch-agnostic and arch-specific configs, build kernel, 234*f7c14bbaSAndroid Build Coastguard Workerthen use bpftool to dump `vmlinux.h`: 235*f7c14bbaSAndroid Build Coastguard Worker 236*f7c14bbaSAndroid Build Coastguard Worker``` 237*f7c14bbaSAndroid Build Coastguard Worker$ cd ~/linux 238*f7c14bbaSAndroid Build Coastguard Worker$ cat tools/testing/selftests/bpf/config \ 239*f7c14bbaSAndroid Build Coastguard Worker tools/testing/selftests/bpf/config.x86_64 > .config 240*f7c14bbaSAndroid Build Coastguard Worker$ make -j$(nproc) olddefconfig all 241*f7c14bbaSAndroid Build Coastguard Worker... 242*f7c14bbaSAndroid Build Coastguard Worker$ bpftool btf dump file ~/linux/vmlinux format c > ~/libbpf/.github/actions/build-selftests/vmlinux.h 243*f7c14bbaSAndroid Build Coastguard Worker$ cd ~/libbpf && git add . && git commit -s 244*f7c14bbaSAndroid Build Coastguard Worker``` 245*f7c14bbaSAndroid Build Coastguard Worker 246*f7c14bbaSAndroid Build Coastguard WorkerCheck in generated `vmlinux.h`, don't forget to use `ci: ` commit prefix, add 247*f7c14bbaSAndroid Build Coastguard Workerit on top of sync commits. Push to Github and let libbpf CI do the checking for 248*f7c14bbaSAndroid Build Coastguard Workeryou. See [this commit](https://github.com/libbpf/libbpf/commit/34212c94a64df8eeb1dd5d064630a65e1dfd4c20) 249*f7c14bbaSAndroid Build Coastguard Workerfor reference. 250*f7c14bbaSAndroid Build Coastguard Worker 251*f7c14bbaSAndroid Build Coastguard WorkerTroubleshooting 252*f7c14bbaSAndroid Build Coastguard Worker--------------- 253*f7c14bbaSAndroid Build Coastguard Worker 254*f7c14bbaSAndroid Build Coastguard WorkerIf something goes wrong and sync script exits early or is terminated early by 255*f7c14bbaSAndroid Build Coastguard Workeruser, you might end up with `~/linux` repo on temporary sync-related branch. 256*f7c14bbaSAndroid Build Coastguard WorkerDon't worry, though, sync script never destroys repo state, it follows 257*f7c14bbaSAndroid Build Coastguard Worker"copy-on-write" philosophy and creates new branches where necessary. So it's 258*f7c14bbaSAndroid Build Coastguard Workervery easy to restore previous state. So if anything goes wrong, it's easy to 259*f7c14bbaSAndroid Build Coastguard Workerstart fresh: 260*f7c14bbaSAndroid Build Coastguard Worker 261*f7c14bbaSAndroid Build Coastguard Worker``` 262*f7c14bbaSAndroid Build Coastguard Worker$ git branch | grep -E 'libbpf-.*Z' 263*f7c14bbaSAndroid Build Coastguard Worker libbpf-baseline-2023-02-28T00-43-35.146Z 264*f7c14bbaSAndroid Build Coastguard Worker libbpf-bpf-baseline-2023-02-28T00-43-35.146Z 265*f7c14bbaSAndroid Build Coastguard Worker libbpf-bpf-tip-2023-02-28T00-43-35.146Z 266*f7c14bbaSAndroid Build Coastguard Worker libbpf-squash-base-2023-02-28T00-43-35.146Z 267*f7c14bbaSAndroid Build Coastguard Worker* libbpf-squash-tip-2023-02-28T00-43-35.146Z 268*f7c14bbaSAndroid Build Coastguard Worker$ git cherry-pick --abort 269*f7c14bbaSAndroid Build Coastguard Worker$ git checkout master && git branch | grep -E 'libbpf-.*Z' | xargs git br -D 270*f7c14bbaSAndroid Build Coastguard WorkerSwitched to branch 'master' 271*f7c14bbaSAndroid Build Coastguard WorkerYour branch is up to date with 'bpf-next/master'. 272*f7c14bbaSAndroid Build Coastguard WorkerDeleted branch libbpf-baseline-2023-02-28T00-43-35.146Z (was 951bce29c898). 273*f7c14bbaSAndroid Build Coastguard WorkerDeleted branch libbpf-bpf-baseline-2023-02-28T00-43-35.146Z (was 3a70e0d4c9d7). 274*f7c14bbaSAndroid Build Coastguard WorkerDeleted branch libbpf-bpf-tip-2023-02-28T00-43-35.146Z (was 2d311f480b52). 275*f7c14bbaSAndroid Build Coastguard WorkerDeleted branch libbpf-squash-base-2023-02-28T00-43-35.146Z (was 957f109ef883). 276*f7c14bbaSAndroid Build Coastguard WorkerDeleted branch libbpf-squash-tip-2023-02-28T00-43-35.146Z (was be66130d2339). 277*f7c14bbaSAndroid Build Coastguard WorkerDeleted branch libbpf-tip-2023-02-28T00-43-35.146Z (was 2d311f480b52). 278*f7c14bbaSAndroid Build Coastguard Worker``` 279*f7c14bbaSAndroid Build Coastguard Worker 280*f7c14bbaSAndroid Build Coastguard WorkerYou might need to do the same for your `~/libbpf` repo sometimes, depending at 281*f7c14bbaSAndroid Build Coastguard Workerwhich stage sync script was terminated. 282