0sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget$/translations/zh_CN/bpf/bpf_devel_QAmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/zh_TW/bpf/bpf_devel_QAmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/it_IT/bpf/bpf_devel_QAmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/ja_JP/bpf/bpf_devel_QAmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/ko_KR/bpf/bpf_devel_QAmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/sp_SP/bpf/bpf_devel_QAmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h!HOWTO interact with BPF subsystemh]h!HOWTO interact with BPF subsystem}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh>/var/lib/git/docbuild/linux/Documentation/bpf/bpf_devel_QA.rsthKubh paragraph)}(hThis document provides information for the BPF subsystem about various workflows related to reporting bugs, submitting patches, and queueing patches for stable kernels.h]hThis document provides information for the BPF subsystem about various workflows related to reporting bugs, submitting patches, and queueing patches for stable kernels.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hFor general information about submitting patches, please refer to Documentation/process/submitting-patches.rst. This document only describes additional specifics related to BPF.h]hFor general information about submitting patches, please refer to Documentation/process/submitting-patches.rst. This document only describes additional specifics related to BPF.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubhtopic)}(hhh]h bullet_list)}(hhh](h list_item)}(hhh](h)}(hhh]h reference)}(hhh]hReporting bugs}(hhhhhNhNubah}(h]id1ah ]h"]h$]h&]refidreporting-bugsuh1hhhubah}(h]h ]h"]h$]h&]uh1hhhubh)}(hhh]h)}(hhh]h)}(hhh]h)}(hhh]h,Q: How do I report bugs for BPF kernel code?}(hjhhhNhNubah}(h]id2ah ]h"]h$]h&]refid*q-how-do-i-report-bugs-for-bpf-kernel-codeuh1hhjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1hhhubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhubh)}(hhh](h)}(hhh]h)}(hhh]hSubmitting patches}(hj6hhhNhNubah}(h]id3ah ]h"]h$]h&]refidsubmitting-patchesuh1hhj3ubah}(h]h ]h"]h$]h&]uh1hhj0ubh)}(hhh](h)}(hhh]h)}(hhh]h)}(hhh]hHQ: How do I run BPF CI on my changes before sending them out for review?}(hjUhhhNhNubah}(h]id4ah ]h"]h$]h&]refidFq-how-do-i-run-bpf-ci-on-my-changes-before-sending-them-out-for-reviewuh1hhjRubah}(h]h ]h"]h$]h&]uh1hhjOubah}(h]h ]h"]h$]h&]uh1hhjLubh)}(hhh]h)}(hhh]h)}(hhh]hThis may also include issues related to XDP, BPF tracing, etc.h]h>This may also include issues related to XDP, BPF tracing, etc.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hxGiven netdev has a high volume of traffic, please also add the BPF maintainers to Cc (from kernel ``MAINTAINERS`` file):h](hbGiven netdev has a high volume of traffic, please also add the BPF maintainers to Cc (from kernel }(hjhhhNhNubhliteral)}(h``MAINTAINERS``h]h MAINTAINERS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh file):}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hhh](h)}(h#Alexei Starovoitov h]h)}(hj/h](hAlexei Starovoitov <}(hj1hhhNhNubh)}(hast@kernel.orgh]hast@kernel.org}(hj8hhhNhNubah}(h]h ]h"]h$]h&]refurimailto:ast@kernel.orguh1hhj1ubh>}(hj1hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK"hj-ubah}(h]h ]h"]h$]h&]uh1hhj*hhhhhNubh)}(h'Daniel Borkmann h]h)}(h&Daniel Borkmann h](hDaniel Borkmann <}(hj\hhhNhNubh)}(hdaniel@iogearbox.neth]hdaniel@iogearbox.net}(hjdhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:daniel@iogearbox.netuh1hhj\ubh>}(hj\hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK#hjXubah}(h]h ]h"]h$]h&]uh1hhj*hhhhhNubeh}(h]h ]h"]h$]h&]bullet*uh1hhhhK"hjhhubh)}(hIn case a buggy commit has already been identified, make sure to keep the actual commit authors in Cc as well for the report. They can typically be identified through the kernel's git tree.h]hIn case a buggy commit has already been identified, make sure to keep the actual commit authors in Cc as well for the report. They can typically be identified through the kernel’s git tree.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjhhubh)}(h~**Please do NOT report BPF issues to bugzilla.kernel.org since it is a guarantee that the reported issue will be overlooked.**h]hstrong)}(hjh]hzPlease do NOT report BPF issues to bugzilla.kernel.org since it is a guarantee that the reported issue will be overlooked.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhK)hjhhubeh}(h]jah ]h"],q: how do i report bugs for bpf kernel code?ah$]h&]uh1hhjhhhhhKubeh}(h]hah ]h"]reporting bugsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hSubmitting patchesh]hSubmitting patches}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj?uh1hhjhhhhhK-ubh)}(hhh](h)}(hHQ: How do I run BPF CI on my changes before sending them out for review?h]hHQ: How do I run BPF CI on my changes before sending them out for review?}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj^uh1hhjhhhhhK0ubh)}(hA: BPF CI is GitHub based and hosted at https://github.com/kernel-patches/bpf. While GitHub also provides a CLI that can be used to accomplish the same results, here we focus on the UI based workflow.h](h(A: BPF CI is GitHub based and hosted at }(hjhhhNhNubh)}(h%https://github.com/kernel-patches/bpfh]h%https://github.com/kernel-patches/bpf}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1hhjubh{. While GitHub also provides a CLI that can be used to accomplish the same results, here we focus on the UI based workflow.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK1hjhhubh)}(hCThe following steps lay out how to start a CI run for your patches:h]hCThe following steps lay out how to start a CI run for your patches:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hjhhubh)}(hhh](h)}(hUCreate a fork of the aforementioned repository in your own account (one time action) h]h)}(hTCreate a fork of the aforementioned repository in your own account (one time action)h]hTCreate a fork of the aforementioned repository in your own account (one time action)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK7hjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hClone the fork locally, check out a new branch tracking either the bpf-next or bpf branch, and apply your to-be-tested patches on top of it h]h)}(hClone the fork locally, check out a new branch tracking either the bpf-next or bpf branch, and apply your to-be-tested patches on top of ith]hClone the fork locally, check out a new branch tracking either the bpf-next or bpf branch, and apply your to-be-tested patches on top of it}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK:hj-ubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hPush the local branch to your fork and create a pull request against kernel-patches/bpf's bpf-next_base or bpf_base branch, respectively h]h)}(hPush the local branch to your fork and create a pull request against kernel-patches/bpf's bpf-next_base or bpf_base branch, respectivelyh]hPush the local branch to your fork and create a pull request against kernel-patches/bpf’s bpf-next_base or bpf_base branch, respectively}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK=hjEubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubeh}(h]h ]h"]h$]h&]j-uh1hhhhK7hjhhubh)}(hShortly after the pull request has been created, the CI workflow will run. Note that capacity is shared with patches submitted upstream being checked and so depending on utilization the run can take a while to finish.h]hShortly after the pull request has been created, the CI workflow will run. Note that capacity is shared with patches submitted upstream being checked and so depending on utilization the run can take a while to finish.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hjhhubh)}(hXENote furthermore that both base branches (bpf-next_base and bpf_base) will be updated as patches are pushed to the respective upstream branches they track. As such, your patch set will automatically (be attempted to) be rebased as well. This behavior can result in a CI run being aborted and restarted with the new base line.h]hXENote furthermore that both base branches (bpf-next_base and bpf_base) will be updated as patches are pushed to the respective upstream branches they track. As such, your patch set will automatically (be attempted to) be rebased as well. This behavior can result in a CI run being aborted and restarted with the new base line.}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhjhhubeh}(h]jdah ]h"]Hq: how do i run bpf ci on my changes before sending them out for review?ah$]h&]uh1hhjhhhhhK0ubh)}(hhh](h)}(hpull-request: bpf yyyy-mm-dd pull-request: bpf-next yyyy-mm-ddh]h>pull-request: bpf yyyy-mm-dd pull-request: bpf-next yyyy-mm-dd}hj3 sbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1j1 hhhKhjrhhubeh}(h]jah ]h"]0q: how do the changes make their way into linux?ah$]h&]uh1hhjhhhhhKoubh)}(hhh](h)}(hQQ: How do I indicate which tree (bpf vs. bpf-next) my patch should be applied to?h]hQQ: How do I indicate which tree (bpf vs. bpf-next) my patch should be applied to?}(hjM hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjJ hhhhhKubh)}(hXCA: The process is the very same as described in the netdev subsystem documentation at Documentation/process/maintainer-netdev.rst, so please read up on it. The subject line must indicate whether the patch is a fix or rather "next-like" content in order to let the maintainers know whether it is targeted at bpf or bpf-next.h]hXGA: The process is the very same as described in the netdev subsystem documentation at Documentation/process/maintainer-netdev.rst, so please read up on it. The subject line must indicate whether the patch is a fix or rather “next-like” content in order to let the maintainers know whether it is targeted at bpf or bpf-next.}(hj[ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjJ hhubh)}(hMFor fixes eventually landing in bpf -> net tree, the subject must look like::h]hLFor fixes eventually landing in bpf -> net tree, the subject must look like:}(hji hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjJ hhubj2 )}(h;git format-patch --subject-prefix='PATCH bpf' start..finishh]h;git format-patch --subject-prefix='PATCH bpf' start..finish}hjw sbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhKhjJ hhubh)}(hoFor features/improvements/etc that should eventually land in bpf-next -> net-next, the subject must look like::h]hnFor features/improvements/etc that should eventually land in bpf-next -> net-next, the subject must look like:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjJ hhubj2 )}(h@git format-patch --subject-prefix='PATCH bpf-next' start..finishh]h@git format-patch --subject-prefix='PATCH bpf-next' start..finish}hj sbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhKhjJ hhubh)}(hX If unsure whether the patch or patch series should go into bpf or net directly, or bpf-next or net-next directly, it is not a problem either if the subject line says net or net-next as target. It is eventually up to the maintainers to do the delegation of the patches.h]hX If unsure whether the patch or patch series should go into bpf or net directly, or bpf-next or net-next directly, it is not a problem either if the subject line says net or net-next as target. It is eventually up to the maintainers to do the delegation of the patches.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjJ hhubh)}(hIf it is clear that patches should go into bpf or bpf-next tree, please make sure to rebase the patches against those trees in order to reduce potential conflicts.h]hIf it is clear that patches should go into bpf or bpf-next tree, please make sure to rebase the patches against those trees in order to reduce potential conflicts.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjJ hhubh)}(hIn case the patch or patch series has to be reworked and sent out again in a second or later revision, it is also required to add a version number (``v2``, ``v3``, ...) into the subject prefix::h](hIn case the patch or patch series has to be reworked and sent out again in a second or later revision, it is also required to add a version number (}(hj hhhNhNubj)}(h``v2``h]hv2}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh, }(hj hhhNhNubj)}(h``v3``h]hv3}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh, ...) into the subject prefix:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjJ hhubj2 )}(hCgit format-patch --subject-prefix='PATCH bpf-next v2' start..finishh]hCgit format-patch --subject-prefix='PATCH bpf-next v2' start..finish}hj sbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhKhjJ hhubh)}(hWhen changes have been requested to the patch series, always send the whole patch series again with the feedback incorporated (never send individual diffs on top of the old series).h]hWhen changes have been requested to the patch series, always send the whole patch series again with the feedback incorporated (never send individual diffs on top of the old series).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjJ hhubeh}(h]jah ]h"]Qq: how do i indicate which tree (bpf vs. bpf-next) my patch should be applied to?ah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hGQ: What does it mean when a patch gets applied to bpf or bpf-next tree?h]hGQ: What does it mean when a patch gets applied to bpf or bpf-next tree?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj hhhhhKubh)}(hVA: It means that the patch looks good for mainline inclusion from a BPF point of view.h]hVA: It means that the patch looks good for mainline inclusion from a BPF point of view.}(hj# hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hBe aware that this is not a final verdict that the patch will automatically get accepted into net or net-next trees eventually:h]hBe aware that this is not a final verdict that the patch will automatically get accepted into net or net-next trees eventually:}(hj1 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hXOOn the bpf kernel mailing list reviews can come in at any point in time. If discussions around a patch conclude that they cannot get included as-is, we will either apply a follow-up fix or drop them from the trees entirely. Therefore, we also reserve to rebase the trees when deemed necessary. After all, the purpose of the tree is to:h]hXOOn the bpf kernel mailing list reviews can come in at any point in time. If discussions around a patch conclude that they cannot get included as-is, we will either apply a follow-up fix or drop them from the trees entirely. Therefore, we also reserve to rebase the trees when deemed necessary. After all, the purpose of the tree is to:}(hj? hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubhenumerated_list)}(hhh](h)}(hWaccumulate and stage BPF patches for integration into trees like net and net-next, and h]h)}(hVaccumulate and stage BPF patches for integration into trees like net and net-next, andh]hVaccumulate and stage BPF patches for integration into trees like net and net-next, and}(hjV hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjR ubah}(h]h ]h"]h$]h&]uh1hhjO hhhhhNubh)}(hbrun extensive BPF test suite and workloads on the patches before they make their way any further. h]h)}(harun extensive BPF test suite and workloads on the patches before they make their way any further.h]harun extensive BPF test suite and workloads on the patches before they make their way any further.}(hjn hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjj ubah}(h]h ]h"]h$]h&]uh1hhjO hhhhhNubeh}(h]h ]h"]h$]h&]enumtype lowerromanprefixhsuffix)uh1jM hj hhhhhKubh)}(hXYOnce the BPF pull request was accepted by David S. Miller, then the patches end up in net or net-next tree, respectively, and make their way from there further into mainline. Again, see the documentation for netdev subsystem at Documentation/process/maintainer-netdev.rst for additional information e.g. on how often they are merged to mainline.h]hXYOnce the BPF pull request was accepted by David S. Miller, then the patches end up in net or net-next tree, respectively, and make their way from there further into mainline. Again, see the documentation for netdev subsystem at Documentation/process/maintainer-netdev.rst for additional information e.g. on how often they are merged to mainline.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubeh}(h]jah ]h"]Gq: what does it mean when a patch gets applied to bpf or bpf-next tree?ah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h=Q: How long do I need to wait for feedback on my BPF patches?h]h=Q: How long do I need to wait for feedback on my BPF patches?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jj*uh1hhj hhhhhKubh)}(hA: We try to keep the latency low. The usual time to feedback will be around 2 or 3 business days. It may vary depending on the complexity of changes and current patch load.h]hA: We try to keep the latency low. The usual time to feedback will be around 2 or 3 business days. It may vary depending on the complexity of changes and current patch load.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubeh}(h]j0ah ]h"]=q: how long do i need to wait for feedback on my bpf patches?ah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hRQ: How often do you send pull requests to major kernel trees like net or net-next?h]hRQ: How often do you send pull requests to major kernel trees like net or net-next?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jjLuh1hhj hhhhhKubh)}(hnA: Pull requests will be sent out rather often in order to not accumulate too many patches in bpf or bpf-next.h]hnA: Pull requests will be sent out rather often in order to not accumulate too many patches in bpf or bpf-next.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hAs a rule of thumb, expect pull requests for each tree regularly at the end of the week. In some cases pull requests could additionally come also in the middle of the week depending on the current patch load or urgency.h]hAs a rule of thumb, expect pull requests for each tree regularly at the end of the week. In some cases pull requests could additionally come also in the middle of the week depending on the current patch load or urgency.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubeh}(h]jRah ]h"]Rq: how often do you send pull requests to major kernel trees like net or net-next?ah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hAQ: Are patches applied to bpf-next when the merge window is open?h]hAQ: Are patches applied to bpf-next when the merge window is open?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jjnuh1hhj hhhhhKubh)}(hA: For the time when the merge window is open, bpf-next will not be processed. This is roughly analogous to net-next patch processing, so feel free to read up on the netdev docs at Documentation/process/maintainer-netdev.rst about further details.h]hA: For the time when the merge window is open, bpf-next will not be processed. This is roughly analogous to net-next patch processing, so feel free to read up on the netdev docs at Documentation/process/maintainer-netdev.rst about further details.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hDuring those two weeks of merge window, we might ask you to resend your patch series once bpf-next is open again. Once Linus released a ``v*-rc1`` after the merge window, we continue processing of bpf-next.h](hDuring those two weeks of merge window, we might ask you to resend your patch series once bpf-next is open again. Once Linus released a }(hj hhhNhNubj)}(h ``v*-rc1``h]hv*-rc1}(hj# hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh< after the merge window, we continue processing of bpf-next.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hFor non-subscribers to kernel mailing lists, there is also a status page run by David S. Miller on net-next that provides guidance:h]hFor non-subscribers to kernel mailing lists, there is also a status page run by David S. Miller on net-next that provides guidance:}(hj; hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubj)}(h,http://vger.kernel.org/~davem/net-next.html h]h)}(h+http://vger.kernel.org/~davem/net-next.htmlh]h)}(hjO h]h+http://vger.kernel.org/~davem/net-next.html}(hjQ hhhNhNubah}(h]h ]h"]h$]h&]refurijO uh1hhjM ubah}(h]h ]h"]h$]h&]uh1hhhhKhjI ubah}(h]h ]h"]h$]h&]uh1jhhhKhj hhubeh}(h]jtah ]h"]Aq: are patches applied to bpf-next when the merge window is open?ah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h"Q: Verifier changes and test casesh]h"Q: Verifier changes and test cases}(hju hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjr hhhhhKubh)}(hWQ: I made a BPF verifier change, do I need to add test cases for BPF kernel selftests_?h](hLQ: I made a BPF verifier change, do I need to add test cases for BPF kernel }(hj hhhNhNubh)}(h selftests_h]h selftests}(hj hhhNhNubah}(h]h ]h"]h$]h&]name selftestsrefuridhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/uh1hhj resolvedKubh?}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjr hhubh)}(hXA: If the patch has changes to the behavior of the verifier, then yes, it is absolutely necessary to add test cases to the BPF kernel selftests_ suite. If they are not present and we think they are needed, then we might ask for them before accepting any changes.h](hA: If the patch has changes to the behavior of the verifier, then yes, it is absolutely necessary to add test cases to the BPF kernel }(hj hhhNhNubh)}(h selftests_h]h selftests}(hj hhhNhNubah}(h]h ]h"]h$]h&]name selftestsj j uh1hhj j Kubhv suite. If they are not present and we think they are needed, then we might ask for them before accepting any changes.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjr hhubh)}(hXIn particular, test_verifier.c is tracking a high number of BPF test cases, including a lot of corner cases that LLVM BPF back end may generate out of the restricted C code. Thus, adding test cases is absolutely crucial to make sure future changes do not accidentally affect prior use-cases. Thus, treat those test cases as: verifier behavior that is not tracked in test_verifier.c could potentially be subject to change.h]hXIn particular, test_verifier.c is tracking a high number of BPF test cases, including a lot of corner cases that LLVM BPF back end may generate out of the restricted C code. Thus, adding test cases is absolutely crucial to make sure future changes do not accidentally affect prior use-cases. Thus, treat those test cases as: verifier behavior that is not tracked in test_verifier.c could potentially be subject to change.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjr hhubeh}(h]jah ]h"]"q: verifier changes and test casesah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h'Q: samples/bpf preference vs selftests?h]h'Q: samples/bpf preference vs selftests?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj hhhhhM ubh)}(hPQ: When should I add code to ``samples/bpf/`` and when to BPF kernel selftests_?h](hQ: When should I add code to }(hj hhhNhNubj)}(h``samples/bpf/``h]h samples/bpf/}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh and when to BPF kernel }(hj hhhNhNubh)}(h selftests_h]h selftests}(hj hhhNhNubah}(h]h ]h"]h$]h&]name selftestsj j uh1hhj j Kubh?}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hj hhubh)}(hA: In general, we prefer additions to BPF kernel selftests_ rather than ``samples/bpf/``. The rationale is very simple: kernel selftests are regularly run by various bots to test for kernel regressions.h](h1A: In general, we prefer additions to BPF kernel }(hj$ hhhNhNubh)}(h selftests_h]h selftests}(hj, hhhNhNubah}(h]h ]h"]h$]h&]name selftestsj j uh1hhj$ j Kubh rather than }(hj$ hhhNhNubj)}(h``samples/bpf/``h]h samples/bpf/}(hj@ hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj$ ubhr. The rationale is very simple: kernel selftests are regularly run by various bots to test for kernel regressions.}(hj$ hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hThe more test cases we add to BPF selftests, the better the coverage and the less likely it is that those could accidentally break. It is not that BPF kernel selftests cannot demo how a specific feature can be used.h]hThe more test cases we add to BPF selftests, the better the coverage and the less likely it is that those could accidentally break. It is not that BPF kernel selftests cannot demo how a specific feature can be used.}(hjX hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hThat said, ``samples/bpf/`` may be a good place for people to get started, so it might be advisable that simple demos of features could go into ``samples/bpf/``, but advanced functional and corner-case testing rather into kernel selftests.h](h That said, }(hjf hhhNhNubj)}(h``samples/bpf/``h]h samples/bpf/}(hjn hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjf ubhu may be a good place for people to get started, so it might be advisable that simple demos of features could go into }(hjf hhhNhNubj)}(h``samples/bpf/``h]h samples/bpf/}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjf ubhO, but advanced functional and corner-case testing rather into kernel selftests.}(hjf hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hPIf your sample looks like a test case, then go for BPF kernel selftests instead!h]hPIf your sample looks like a test case, then go for BPF kernel selftests instead!}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]jah ]h"]'q: samples/bpf preference vs selftests?ah$]h&]uh1hhjhhhhhM ubh)}(hhh](h)}(h)Q: When should I add code to the bpftool?h]h)Q: When should I add code to the bpftool?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj hhhhhM!ubh)}(hXXA: The main purpose of bpftool (under tools/bpf/bpftool/) is to provide a central user space tool for debugging and introspection of BPF programs and maps that are active in the kernel. If UAPI changes related to BPF enable for dumping additional information of programs or maps, then bpftool should be extended as well to support dumping them.h]hXXA: The main purpose of bpftool (under tools/bpf/bpftool/) is to provide a central user space tool for debugging and introspection of BPF programs and maps that are active in the kernel. If UAPI changes related to BPF enable for dumping additional information of programs or maps, then bpftool should be extended as well to support dumping them.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hj hhubeh}(h]jah ]h"])q: when should i add code to the bpftool?ah$]h&]uh1hhjhhhhhM!ubh)}(hhh](h)}(h3Q: When should I add code to iproute2's BPF loader?h]h5Q: When should I add code to iproute2’s BPF loader?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj hhhhhM)ubh)}(hXoA: For UAPI changes related to the XDP or tc layer (e.g. ``cls_bpf``), the convention is that those control-path related changes are added to iproute2's BPF loader as well from user space side. This is not only useful to have UAPI changes properly designed to be usable, but also to make those changes available to a wider user base of major downstream distributions.h](h9A: For UAPI changes related to the XDP or tc layer (e.g. }(hj hhhNhNubj)}(h ``cls_bpf``h]hcls_bpf}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhX-), the convention is that those control-path related changes are added to iproute2’s BPF loader as well from user space side. This is not only useful to have UAPI changes properly designed to be usable, but also to make those changes available to a wider user base of major downstream distributions.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM*hj hhubeh}(h]jah ]h"]3q: when should i add code to iproute2's bpf loader?ah$]h&]uh1hhjhhhhhM)ubh)}(hhh](h)}(h;Q: Do you accept patches as well for iproute2's BPF loader?h]h=Q: Do you accept patches as well for iproute2’s BPF loader?}(hj hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj hhhhhM2ubh)}(hA: Patches for the iproute2’s BPF loader have to be sent to:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM3hj hhubj)}(hnetdev@vger.kernel.org h]h)}(hnetdev@vger.kernel.orgh]h)}(hj0 h]hnetdev@vger.kernel.org}(hj2 hhhNhNubah}(h]h ]h"]h$]h&]refurimailto:netdev@vger.kernel.orguh1hhj. ubah}(h]h ]h"]h$]h&]uh1hhhhM5hj* ubah}(h]h ]h"]h$]h&]uh1jhhhM5hj hhubh)}(h}While those patches are not processed by the BPF kernel maintainers, please keep them in Cc as well, so they can be reviewed.h]h}While those patches are not processed by the BPF kernel maintainers, please keep them in Cc as well, so they can be reviewed.}(hjM hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM7hj hhubh)}(hYThe official git repository for iproute2 is run by Stephen Hemminger and can be found at:h]hYThe official git repository for iproute2 is run by Stephen Hemminger and can be found at:}(hj[ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM:hj hhubj)}(hIhttps://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/ h]h)}(hHhttps://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/h]h)}(hjo h]hHhttps://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/}(hjq hhhNhNubah}(h]h ]h"]h$]h&]refurijo uh1hhjm ubah}(h]h ]h"]h$]h&]uh1hhhhM=hji ubah}(h]h ]h"]h$]h&]uh1jhhhM=hj hhubh)}(hXThe patches need to have a subject prefix of '``[PATCH iproute2 master]``' or '``[PATCH iproute2 net-next]``'. '``master``' or '``net-next``' describes the target branch where the patch should be applied to. Meaning, if kernel changes went into the net-next kernel tree, then the related iproute2 changes need to go into the iproute2 net-next branch, otherwise they can be targeted at master branch. The iproute2 net-next branch will get merged into the master branch after the current iproute2 version from master has been released.h](h0The patches need to have a subject prefix of ‘}(hj hhhNhNubj)}(h``[PATCH iproute2 master]``h]h[PATCH iproute2 master]}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh ’ or ‘}(hj hhhNhNubj)}(h``[PATCH iproute2 net-next]``h]h[PATCH iproute2 net-next]}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh’. ‘}(hj hhhNhNubj)}(h ``master``h]hmaster}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh ’ or ‘}(hj hhhNhNubj)}(h ``net-next``h]hnet-next}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhX’ describes the target branch where the patch should be applied to. Meaning, if kernel changes went into the net-next kernel tree, then the related iproute2 changes need to go into the iproute2 net-next branch, otherwise they can be targeted at master branch. The iproute2 net-next branch will get merged into the master branch after the current iproute2 version from master has been released.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM?hj hhubh)}(h|Like BPF, the patches end up in patchwork under the netdev project and are delegated to 'shemminger' for further processing:h]hLike BPF, the patches end up in patchwork under the netdev project and are delegated to ‘shemminger’ for further processing:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMHhj hhubj)}(h>http://patchwork.ozlabs.org/project/netdev/list/?delegate=389 h]h)}(h=http://patchwork.ozlabs.org/project/netdev/list/?delegate=389h]h)}(hj h]h=http://patchwork.ozlabs.org/project/netdev/list/?delegate=389}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurij uh1hhj ubah}(h]h ]h"]h$]h&]uh1hhhhMKhj ubah}(h]h ]h"]h$]h&]uh1jhhhMKhj hhubeh}(h]jah ]h"];q: do you accept patches as well for iproute2's bpf loader?ah$]h&]uh1hhjhhhhhM2ubh)}(hhh](h)}(hBQ: What is the minimum requirement before I submit my BPF patches?h]hBQ: What is the minimum requirement before I submit my BPF patches?}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj:uh1hhjhhhhhMNubh)}(hXA: When submitting patches, always take the time and properly test your patches *prior* to submission. Never rush them! If maintainers find that your patches have not been properly tested, it is a good way to get them grumpy. Testing patch submissions is a hard requirement!h](hPA: When submitting patches, always take the time and properly test your patches }(hj)hhhNhNubhemphasis)}(h*prior*h]hprior}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1j1hj)ubh to submission. Never rush them! If maintainers find that your patches have not been properly tested, it is a good way to get them grumpy. Testing patch submissions is a hard requirement!}(hj)hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMOhjhhubh)}(hXSNote, fixes that go to bpf tree *must* have a ``Fixes:`` tag included. The same applies to fixes that target bpf-next, where the affected commit is in net-next (or in some cases bpf-next). The ``Fixes:`` tag is crucial in order to identify follow-up commits and tremendously helps for people having to do backporting, so it is a must have!h](h Note, fixes that go to bpf tree }(hjKhhhNhNubj2)}(h*must*h]hmust}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1j1hjKubh have a }(hjKhhhNhNubj)}(h ``Fixes:``h]hFixes:}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jhjKubh tag included. The same applies to fixes that target bpf-next, where the affected commit is in net-next (or in some cases bpf-next). The }(hjKhhhNhNubj)}(h ``Fixes:``h]hFixes:}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjKubh tag is crucial in order to identify follow-up commits and tremendously helps for people having to do backporting, so it is a must have!}(hjKhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMThjhhubh)}(hWe also don't accept patches with an empty commit message. Take your time and properly write up a high quality commit message, it is essential!h]hWe also don’t accept patches with an empty commit message. Take your time and properly write up a high quality commit message, it is essential!}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMZhjhhubh)}(hXIThink about it this way: other developers looking at your code a month from now need to understand *why* a certain change has been done that way, and whether there have been flaws in the analysis or assumptions that the original author did. Thus providing a proper rationale and describing the use-case for the changes is a must.h](hcThink about it this way: other developers looking at your code a month from now need to understand }(hjhhhNhNubj2)}(h*why*h]hwhy}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j1hjubh a certain change has been done that way, and whether there have been flaws in the analysis or assumptions that the original author did. Thus providing a proper rationale and describing the use-case for the changes is a must.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM^hjhhubh)}(hXPatch submissions with >1 patch must have a cover letter which includes a high level description of the series. This high level summary will then be placed into the merge commit by the BPF maintainers such that it is also accessible from the git log for future reference.h]hXPatch submissions with >1 patch must have a cover letter which includes a high level description of the series. This high level summary will then be placed into the merge commit by the BPF maintainers such that it is also accessible from the git log for future reference.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMdhjhhubeh}(h]j@ah ]h"]Bq: what is the minimum requirement before i submit my bpf patches?ah$]h&]uh1hhjhhhhhMNubh)}(hhh](h)}(h(Q: Features changing BPF JIT and/or LLVMh]h(Q: Features changing BPF JIT and/or LLVM}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj\uh1hhjhhhhhMjubh)}(hQ: What do I need to consider when adding a new instruction or feature that would require BPF JIT and/or LLVM integration as well?h]hQ: What do I need to consider when adding a new instruction or feature that would require BPF JIT and/or LLVM integration as well?}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMkhjhhubh)}(hXA: We try hard to keep all BPF JITs up to date such that the same user experience can be guaranteed when running BPF programs on different architectures without having the program punt to the less efficient interpreter in case the in-kernel BPF JIT is enabled.h]hXA: We try hard to keep all BPF JITs up to date such that the same user experience can be guaranteed when running BPF programs on different architectures without having the program punt to the less efficient interpreter in case the in-kernel BPF JIT is enabled.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMnhjhhubh)}(hX-If you are unable to implement or test the required JIT changes for certain architectures, please work together with the related BPF JIT developers in order to get the feature implemented in a timely manner. Please refer to the git log (``arch/*/net/``) to locate the necessary people for helping out.h](hIf you are unable to implement or test the required JIT changes for certain architectures, please work together with the related BPF JIT developers in order to get the feature implemented in a timely manner. Please refer to the git log (}(hjhhhNhNubj)}(h``arch/*/net/``h]h arch/*/net/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh1) to locate the necessary people for helping out.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMshjhhubh)}(hAlso always make sure to add BPF test cases (e.g. test_bpf.c and test_verifier.c) for new instructions, so that they can receive broad test coverage and help run-time testing the various BPF JITs.h]hAlso always make sure to add BPF test cases (e.g. test_bpf.c and test_verifier.c) for new instructions, so that they can receive broad test coverage and help run-time testing the various BPF JITs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMyhjhhubh)}(hIn case of new BPF instructions, once the changes have been accepted into the Linux kernel, please implement support into LLVM's BPF back end. See LLVM_ section below for further information.h](hIn case of new BPF instructions, once the changes have been accepted into the Linux kernel, please implement support into LLVM’s BPF back end. See }(hj-hhhNhNubh)}(hLLVM_h]hLLVM}(hj5hhhNhNubah}(h]h ]h"]h$]h&]nameLLVMjjuh1hhj-j Kubh' section below for further information.}(hj-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM}hjhhubeh}(h]jbah ]h"](q: features changing bpf jit and/or llvmah$]h&]uh1hhjhhhhhMjubh)}(hhh](h)}(h/Q: What "BPF_INTERNAL" symbol namespace is for?sh]h3Q: What “BPF_INTERNAL” symbol namespace is for?}(hjYhhhNhNubah}(h]h ]h"]h$]h&]jj~uh1hhjVhhhhhMubh)}(hX9A: Symbols exported as BPF_INTERNAL can only be used by BPF infrastructure like preload kernel modules with light skeleton. Most symbols outside of BPF_INTERNAL are not expected to be used by code outside of BPF either. Symbols may lack the designation because they predate the namespaces, or due to an oversight.h]hX9A: Symbols exported as BPF_INTERNAL can only be used by BPF infrastructure like preload kernel modules with light skeleton. Most symbols outside of BPF_INTERNAL are not expected to be used by code outside of BPF either. Symbols may lack the designation because they predate the namespaces, or due to an oversight.}(hjghhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjVhhubeh}(h]jah ]h"]/q: what "bpf_internal" symbol namespace is for?ah$]h&]uh1hhjhhhhhMubeh}(h]jEah ]h"]submitting patchesah$]h&]uh1hhhhhhhhK-ubh)}(hhh](h)}(hStable submissionh]hStable submission}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjhhhhhMubh)}(hhh](h)}(hDQ: I need a specific BPF commit in stable kernels. What should I do?h]hDQ: I need a specific BPF commit in stable kernels. What should I do?}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjhhhhhMubh)}(hA: In case you need a specific fix in stable kernels, first check whether the commit has already been applied in the related ``linux-*.y`` branches:h](h}A: In case you need a specific fix in stable kernels, first check whether the commit has already been applied in the related }(hjhhhNhNubj)}(h ``linux-*.y``h]h linux-*.y}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh branches:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hIhttps://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/ h]h)}(hHhttps://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/h]h)}(hjh]hHhttps://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1hhjubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jhhhMhjhhubh)}(hIf not the case, then drop an email to the BPF maintainers with the netdev kernel mailing list in Cc and ask for the fix to be queued up:h]hIf not the case, then drop an email to the BPF maintainers with the netdev kernel mailing list in Cc and ask for the fix to be queued up:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hnetdev@vger.kernel.org h]h)}(hnetdev@vger.kernel.orgh]h)}(hjh]hnetdev@vger.kernel.org}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:netdev@vger.kernel.orguh1hhjubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jhhhMhjhhubh)}(hThe process in general is the same as on netdev itself, see also the the documentation on networking subsystem at Documentation/process/maintainer-netdev.rst.h]hThe process in general is the same as on netdev itself, see also the the documentation on networking subsystem at Documentation/process/maintainer-netdev.rst.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]jah ]h"]Dq: i need a specific bpf commit in stable kernels. what should i do?ah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hFQ: Do you also backport to kernels not currently maintained as stable?h]hFQ: Do you also backport to kernels not currently maintained as stable?}(hj0hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj-hhhhhMubh)}(hA: No. If you need a specific BPF commit in kernels that are currently not maintained by the stable maintainers, then you are on your own.h]hA: No. If you need a specific BPF commit in kernels that are currently not maintained by the stable maintainers, then you are on your own.}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-hhubh)}(hCThe current stable and longterm stable kernels are all listed here:h]hCThe current stable and longterm stable kernels are all listed here:}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-hhubj)}(hhttps://www.kernel.org/ h]h)}(hhttps://www.kernel.org/h]h)}(hj`h]hhttps://www.kernel.org/}(hjbhhhNhNubah}(h]h ]h"]h$]h&]refurij`uh1hhj^ubah}(h]h ]h"]h$]h&]uh1hhhhMhjZubah}(h]h ]h"]h$]h&]uh1jhhhMhj-hhubeh}(h]jah ]h"]Fq: do you also backport to kernels not currently maintained as stable?ah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hCQ: The BPF patch I am about to submit needs to go to stable as wellh]hCQ: The BPF patch I am about to submit needs to go to stable as well}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjhhhhhMubh)}(hWhat should I do?h]hWhat should I do?}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hA: The same rules apply as with netdev patch submissions in general, see the netdev docs at Documentation/process/maintainer-netdev.rst.h]hA: The same rules apply as with netdev patch submissions in general, see the netdev docs at Documentation/process/maintainer-netdev.rst.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hX6Never add "``Cc: stable@vger.kernel.org``" to the patch description, but ask the BPF maintainers to queue the patches instead. This can be done with a note, for example, under the ``---`` part of the patch which does not go into the git log. Alternatively, this can be done as a simple request by mail instead.h](h Never add “}(hjhhhNhNubj)}(h``Cc: stable@vger.kernel.org``h]hCc: stable@vger.kernel.org}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh” to the patch description, but ask the BPF maintainers to queue the patches instead. This can be done with a note, for example, under the }(hjhhhNhNubj)}(h``---``h]h---}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh{ part of the patch which does not go into the git log. Alternatively, this can be done as a simple request by mail instead.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]jah ]h"]Cq: the bpf patch i am about to submit needs to go to stable as wellah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hQ: Queue stable patchesh]hQ: Queue stable patches}(hjhhhNhNubah}(h]h ]h"]h$]h&]jj1uh1hhjhhhhhMubh)}(hQQ: Where do I find currently queued BPF patches that will be submitted to stable?h]hQQ: Where do I find currently queued BPF patches that will be submitted to stable?}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(huA: Once patches that fix critical bugs got applied into the bpf tree, they are queued up for stable submission under:h]huA: Once patches that fix critical bugs got applied into the bpf tree, they are queued up for stable submission under:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h7http://patchwork.ozlabs.org/bundle/bpf/stable/?state=* h]h)}(h6http://patchwork.ozlabs.org/bundle/bpf/stable/?state=*h]h)}(hjh]h6http://patchwork.ozlabs.org/bundle/bpf/stable/?state=*}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1hhjubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jhhhMhjhhubh)}(hjThey will be on hold there at minimum until the related commit made its way into the mainline kernel tree.h]hjThey will be on hold there at minimum until the related commit made its way into the mainline kernel tree.}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hAfter having been under broader exposure, the queued patches will be submitted by the BPF maintainers to the stable maintainers.h]hAfter having been under broader exposure, the queued patches will be submitted by the BPF maintainers to the stable maintainers.}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]j7ah ]h"]q: queue stable patchesah$]h&]uh1hhjhhhhhMubeh}(h]jah ]h"]stable submissionah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hTesting patchesh]hTesting patches}(hjehhhNhNubah}(h]h ]h"]h$]h&]jj_uh1hhjbhhhhhMubh)}(hhh](h)}(hQ: How to run BPF selftestsh]hQ: How to run BPF selftests}(hjvhhhNhNubah}(h]h ]h"]h$]h&]jj~uh1hhjshhhhhMubh)}(hA: After you have booted into the newly compiled kernel, navigate to the BPF selftests_ suite in order to test BPF functionality (current working directory points to the root of the cloned git tree)::h](hMA: After you have booted into the newly compiled kernel, navigate to the BPF }(hjhhhNhNubh)}(h selftests_h]h selftests}(hjhhhNhNubah}(h]h ]h"]h$]h&]name selftestsj j uh1hhjj Kubhp suite in order to test BPF functionality (current working directory points to the root of the cloned git tree):}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjshhubj2 )}(h($ cd tools/testing/selftests/bpf/ $ makeh]h($ cd tools/testing/selftests/bpf/ $ make}hjsbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhMhjshhubh)}(hTo run the verifier tests::h]hTo run the verifier tests:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubj2 )}(h$ sudo ./test_verifierh]h$ sudo ./test_verifier}hjsbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhMhjshhubh)}(hThe verifier tests print out all the current checks being performed. The summary at the end of running all tests will dump information of test successes and failures::h]hThe verifier tests print out all the current checks being performed. The summary at the end of running all tests will dump information of test successes and failures:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubj2 )}(hSummary: 418 PASSED, 0 FAILEDh]hSummary: 418 PASSED, 0 FAILED}hjsbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhMhjshhubh)}(hLIn order to run through all BPF selftests, the following command is needed::h]hKIn order to run through all BPF selftests, the following command is needed:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubj2 )}(h$ sudo make run_testsh]h$ sudo make run_tests}hjsbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhMhjshhubh)}(hLSee :doc:`kernel selftest documentation ` for details.h](hSee }(hjhhhNhNubh)}(h;:doc:`kernel selftest documentation `h]hinline)}(hjh]hkernel selftest documentation}(hjhhhNhNubah}(h]h ](xrefstdstd-doceh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocbpf/bpf_devel_QA refdomainj!reftypedoc refexplicitrefwarn reftarget/dev-tools/kselftestuh1hhhhMhjubh for details.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjshhubh)}(hTo maximize the number of tests passing, the .config of the kernel under test should match the config file fragment in tools/testing/selftests/bpf as closely as possible.h]hTo maximize the number of tests passing, the .config of the kernel under test should match the config file fragment in tools/testing/selftests/bpf as closely as possible.}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubh)}(hXFinally to ensure support for latest BPF Type Format features - discussed in Documentation/bpf/btf.rst - pahole version 1.16 is required for kernels built with CONFIG_DEBUG_INFO_BTF=y. pahole is delivered in the dwarves package or can be built from source ath]hXFinally to ensure support for latest BPF Type Format features - discussed in Documentation/bpf/btf.rst - pahole version 1.16 is required for kernels built with CONFIG_DEBUG_INFO_BTF=y. pahole is delivered in the dwarves package or can be built from source at}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubh)}(h https://github.com/acmel/dwarvesh]h)}(hj]h]h https://github.com/acmel/dwarves}(hj_hhhNhNubah}(h]h ]h"]h$]h&]refurij]uh1hhj[ubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubh)}(hXpahole starts to use libbpf definitions and APIs since v1.13 after the commit 21507cd3e97b ("pahole: add libbpf as submodule under lib/bpf"). It works well with the git repository because the libbpf submodule will use "git submodule update --init --recursive" to update.h]hXpahole starts to use libbpf definitions and APIs since v1.13 after the commit 21507cd3e97b (“pahole: add libbpf as submodule under lib/bpf”). It works well with the git repository because the libbpf submodule will use “git submodule update --init --recursive” to update.}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubh)}(hX1Unfortunately, the default github release source code does not contain libbpf submodule source code and this will cause build issues, the tarball from https://git.kernel.org/pub/scm/devel/pahole/pahole.git/ is same with github, you can get the source tarball with corresponding libbpf submodule codes fromh](hUnfortunately, the default github release source code does not contain libbpf submodule source code and this will cause build issues, the tarball from }(hjhhhNhNubh)}(h7https://git.kernel.org/pub/scm/devel/pahole/pahole.git/h]h7https://git.kernel.org/pub/scm/devel/pahole/pahole.git/}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1hhjubhc is same with github, you can get the source tarball with corresponding libbpf submodule codes from}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjshhubh)}(h&https://fedorapeople.org/~acme/dwarvesh]h)}(hjh]h&https://fedorapeople.org/~acme/dwarves}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1hhjubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubh)}(hLSome distros have pahole version 1.16 packaged already, e.g. Fedora, Gentoo.h]hLSome distros have pahole version 1.16 packaged already, e.g. Fedora, Gentoo.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjshhubeh}(h]jah ]h"]q: how to run bpf selftestsah$]h&]uh1hhjbhhhhhMubh)}(hhh](h)}(hEQ: Which BPF kernel selftests version should I run my kernel against?h]hEQ: Which BPF kernel selftests version should I run my kernel against?}(hjhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhjhhhhhMubh)}(hA: If you run a kernel ``xyz``, then always run the BPF kernel selftests from that kernel ``xyz`` as well. Do not expect that the BPF selftest from the latest mainline tree will pass all the time.h](hA: If you run a kernel }(hjhhhNhNubj)}(h``xyz``h]hxyz}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh<, then always run the BPF kernel selftests from that kernel }(hjhhhNhNubj)}(h``xyz``h]hxyz}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhc as well. Do not expect that the BPF selftest from the latest mainline tree will pass all the time.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hX In particular, test_bpf.c and test_verifier.c have a large number of test cases and are constantly updated with new BPF test sequences, or existing ones are adapted to verifier changes e.g. due to verifier becoming smarter and being able to better track certain things.h]hX In particular, test_bpf.c and test_verifier.c have a large number of test cases and are constantly updated with new BPF test sequences, or existing ones are adapted to verifier changes e.g. due to verifier becoming smarter and being able to better track certain things.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]jah ]h"]Eq: which bpf kernel selftests version should i run my kernel against?ah$]h&]uh1hhjbhhhhhMubeh}(h]jeah ]h"]testing patchesah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hLLVMh]hLLVM}(hj1hhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj.hhhhhMubh)}(hhh](h)}(h)Q: Where do I find LLVM with BPF support?h]h)Q: Where do I find LLVM with BPF support?}(hjBhhhNhNubah}(h]h ]h"]h$]h&]jjuh1hhj?hhhhhM ubh)}(hEA: The BPF back end for LLVM is upstream in LLVM since version 3.7.1.h]hEA: The BPF back end for LLVM is upstream in LLVM since version 3.7.1.}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj?hhubh)}(hAll major distributions these days ship LLVM with BPF back end enabled, so for the majority of use-cases it is not required to compile LLVM by hand anymore, just install the distribution provided package.h]hAll major distributions these days ship LLVM with BPF back end enabled, so for the majority of use-cases it is not required to compile LLVM by hand anymore, just install the distribution provided package.}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj?hhubh)}(hyLLVM's static compiler lists the supported targets through ``llc --version``, make sure BPF targets are listed. Example::h](h=LLVM’s static compiler lists the supported targets through }(hjlhhhNhNubj)}(h``llc --version``h]h llc --version}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1jhjlubh,, make sure BPF targets are listed. Example:}(hjlhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj?hhubj2 )}(hX$ llc --version LLVM (http://llvm.org/): LLVM version 10.0.0 Optimized build. Default target: x86_64-unknown-linux-gnu Host CPU: skylake Registered Targets: aarch64 - AArch64 (little endian) bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64h]hX$ llc --version LLVM (http://llvm.org/): LLVM version 10.0.0 Optimized build. Default target: x86_64-unknown-linux-gnu Host CPU: skylake Registered Targets: aarch64 - AArch64 (little endian) bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64}hjsbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhMhj?hhubh)}(hFor developers in order to utilize the latest features added to LLVM's BPF back end, it is advisable to run the latest LLVM releases. Support for new BPF kernel features such as additions to the BPF instruction set are often developed together.h]hFor developers in order to utilize the latest features added to LLVM’s BPF back end, it is advisable to run the latest LLVM releases. Support for new BPF kernel features such as additions to the BPF instruction set are often developed together.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM$hj?hhubh)}(hhjhhubh)}(hSet ``-DLLVM_TARGETS_TO_BUILD`` equal to the target you wish to build, you will find a full list of targets within the llvm-project/llvm/lib/Target directory.h](hSet }(hjhhhNhNubj)}(h``-DLLVM_TARGETS_TO_BUILD``h]h-DLLVM_TARGETS_TO_BUILD}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh equal to the target you wish to build, you will find a full list of targets within the llvm-project/llvm/lib/Target directory.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMAhjhhubeh}(h]jah ]h"]2q: got it, so how do i build llvm manually anyway?ah$]h&]uh1hhj.hhhhhM,ubh)}(hhh](h)}(hQ: Reporting LLVM BPF issuesh]hQ: Reporting LLVM BPF issues}(hj?hhhNhNubah}(h]h ]h"]h$]h&]jj1uh1hhj<hhhhhMFubh)}(hQ: Should I notify BPF kernel maintainers about issues in LLVM's BPF code generation back end or about LLVM generated code that the verifier refuses to accept?h]hQ: Should I notify BPF kernel maintainers about issues in LLVM’s BPF code generation back end or about LLVM generated code that the verifier refuses to accept?}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMGhj<hhubh)}(hA: Yes, please do!h]hA: Yes, please do!}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMKhj<hhubh)}(hLLVM's BPF back end is a key piece of the whole BPF infrastructure and it ties deeply into verification of programs from the kernel side. Therefore, any issues on either side need to be investigated and fixed whenever necessary.h]hLLVM’s BPF back end is a key piece of the whole BPF infrastructure and it ties deeply into verification of programs from the kernel side. Therefore, any issues on either side need to be investigated and fixed whenever necessary.}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMMhj<hhubh)}(h{Therefore, please make sure to bring them up at netdev kernel mailing list and Cc BPF maintainers for LLVM and kernel bits:h]h{Therefore, please make sure to bring them up at netdev kernel mailing list and Cc BPF maintainers for LLVM and kernel bits:}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMRhj<hhubh)}(hhh](h)}(hYonghong Song h]h)}(hjh](hYonghong Song <}(hjhhhNhNubh)}(h yhs@fb.comh]h yhs@fb.com}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:yhs@fb.comuh1hhjubh>}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMUhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h#Alexei Starovoitov h]h)}(hjh](hAlexei Starovoitov <}(hjhhhNhNubh)}(hast@kernel.orgh]hast@kernel.org}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:ast@kernel.orguh1hhjubh>}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMVhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h'Daniel Borkmann h]h)}(h&Daniel Borkmann h](hDaniel Borkmann <}(hjhhhNhNubh)}(hdaniel@iogearbox.neth]hdaniel@iogearbox.net}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:daniel@iogearbox.netuh1hhjubh>}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMWhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubeh}(h]h ]h"]h$]h&]jjuh1hhhhMUhj<hhubh)}(hCLLVM also has an issue tracker where BPF related bugs can be found:h]hCLLVM also has an issue tracker where BPF related bugs can be found:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMYhj<hhubj)}(h2https://bugs.llvm.org/buglist.cgi?quicksearch=bpf h]h)}(h1https://bugs.llvm.org/buglist.cgi?quicksearch=bpfh]h)}(hj$h]h1https://bugs.llvm.org/buglist.cgi?quicksearch=bpf}(hj&hhhNhNubah}(h]h ]h"]h$]h&]refurij$uh1hhj"ubah}(h]h ]h"]h$]h&]uh1hhhhM[hjubah}(h]h ]h"]h$]h&]uh1jhhhM[hj<hhubh)}(hWHowever, it is better to reach out through mailing lists with having maintainers in Cc.h]hWHowever, it is better to reach out through mailing lists with having maintainers in Cc.}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM]hj<hhubeh}(h]j7ah ]h"]q: reporting llvm bpf issuesah$]h&]uh1hhj.hhhhhMFubh)}(hhh](h)}(h*Q: New BPF instruction for kernel and LLVMh]h*Q: New BPF instruction for kernel and LLVM}(hjXhhhNhNubah}(h]h ]h"]h$]h&]jjSuh1hhjUhhhhhMaubh)}(hVQ: I have added a new BPF instruction to the kernel, how can I integrate it into LLVM?h]hVQ: I have added a new BPF instruction to the kernel, how can I integrate it into LLVM?}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhjUhhubh)}(hA: LLVM has a ``-mcpu`` selector for the BPF back end in order to allow the selection of BPF instruction set extensions. By default the ``generic`` processor target is used, which is the base instruction set (v1) of BPF.h](hA: LLVM has a }(hjthhhNhNubj)}(h ``-mcpu``h]h-mcpu}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjtubhq selector for the BPF back end in order to allow the selection of BPF instruction set extensions. By default the }(hjthhhNhNubj)}(h ``generic``h]hgeneric}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjtubhI processor target is used, which is the base instruction set (v1) of BPF.}(hjthhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMehjUhhubh)}(hLLVM has an option to select ``-mcpu=probe`` where it will probe the host kernel for supported BPF instruction set extensions and selects the optimal set automatically.h](hLLVM has an option to select }(hjhhhNhNubj)}(h``-mcpu=probe``h]h -mcpu=probe}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh| where it will probe the host kernel for supported BPF instruction set extensions and selects the optimal set automatically.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMjhjUhhubh)}(hKFor cross-compilation, a specific version can be select manually as well ::h]hHFor cross-compilation, a specific version can be select manually as well}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMnhjUhhubj2 )}(h$ llc -march bpf -mcpu=help Available CPUs for this target: generic - Select the generic processor. probe - Select the probe processor. v1 - Select the v1 processor. v2 - Select the v2 processor. [...]h]h$ llc -march bpf -mcpu=help Available CPUs for this target: generic - Select the generic processor. probe - Select the probe processor. v1 - Select the v1 processor. v2 - Select the v2 processor. [...]}hjsbah}(h]h ]h"]h$]h&]jA jB uh1j1 hhhMphjUhhubh)}(hXNewly added BPF instructions to the Linux kernel need to follow the same scheme, bump the instruction set version and implement probing for the extensions such that ``-mcpu=probe`` users can benefit from the optimization transparently when upgrading their kernels.h](hNewly added BPF instructions to the Linux kernel need to follow the same scheme, bump the instruction set version and implement probing for the extensions such that }(hjhhhNhNubj)}(h``-mcpu=probe``h]h -mcpu=probe}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhT users can benefit from the optimization transparently when upgrading their kernels.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMyhjUhhubh)}(hwIf you are unable to implement support for the newly added BPF instruction please reach out to BPF developers for help.h]hwIf you are unable to implement support for the newly added BPF instruction please reach out to BPF developers for help.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM~hjUhhubh)}(hWBy the way, the BPF kernel selftests run with ``-mcpu=probe`` for better test coverage.h](h.By the way, the BPF kernel selftests run with }(hjhhhNhNubj)}(h``-mcpu=probe``h]h -mcpu=probe}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh for better test coverage.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjUhhubeh}(h]jYah ]h"]*q: new bpf instruction for kernel and llvmah$]h&]uh1hhj.hhhhhMaubh)}(hhh](h)}(hQ: clang flag for target bpf?h]hQ: clang flag for target bpf?}(hj:hhhNhNubah}(h]h ]h"]h$]h&]jjuuh1hhj7hhhhhMubh)}(hQ: In some cases clang flag ``--target=bpf`` is used but in other cases the default clang target, which matches the underlying architecture, is used. What is the difference and when I should use which?h](hQ: In some cases clang flag }(hjHhhhNhNubj)}(h``--target=bpf``h]h --target=bpf}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjHubh is used but in other cases the default clang target, which matches the underlying architecture, is used. What is the difference and when I should use which?}(hjHhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj7hhubh)}(hA: Although LLVM IR generation and optimization try to stay architecture independent, ``--target=`` still has some impact on generated code:h](hVA: Although LLVM IR generation and optimization try to stay architecture independent, }(hjhhhhNhNubj)}(h``--target=``h]h--target=}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1jhjhubh) still has some impact on generated code:}(hjhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj7hhubh)}(hhh](h)}(hXBPF program may recursively include header file(s) with file scope inline assembly codes. The default target can handle this well, while ``bpf`` target may fail if bpf backend assembler does not understand these assembly codes, which is true in most cases. h]h)}(hXBPF program may recursively include header file(s) with file scope inline assembly codes. The default target can handle this well, while ``bpf`` target may fail if bpf backend assembler does not understand these assembly codes, which is true in most cases.h](hBPF program may recursively include header file(s) with file scope inline assembly codes. The default target can handle this well, while }(hjhhhNhNubj)}(h``bpf``h]hbpf}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhp target may fail if bpf backend assembler does not understand these assembly codes, which is true in most cases.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hWhen compiled without ``-g``, additional elf sections, e.g., .eh_frame and .rela.eh_frame, may be present in the object file with default target, but not with ``bpf`` target. h]h)}(hWhen compiled without ``-g``, additional elf sections, e.g., .eh_frame and .rela.eh_frame, may be present in the object file with default target, but not with ``bpf`` target.h](hWhen compiled without }(hjhhhNhNubj)}(h``-g``h]h-g}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh, additional elf sections, e.g., .eh_frame and .rela.eh_frame, may be present in the object file with default target, but not with }(hjhhhNhNubj)}(h``bpf``h]hbpf}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh target.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXUThe default target may turn a C switch statement into a switch table lookup and jump operation. Since the switch table is placed in the global readonly section, the bpf program will fail to load. The bpf target does not support switch table optimization. The clang option ``-fno-jump-tables`` can be used to disable switch table generation. h]h)}(hXTThe default target may turn a C switch statement into a switch table lookup and jump operation. Since the switch table is placed in the global readonly section, the bpf program will fail to load. The bpf target does not support switch table optimization. The clang option ``-fno-jump-tables`` can be used to disable switch table generation.h](hXThe default target may turn a C switch statement into a switch table lookup and jump operation. Since the switch table is placed in the global readonly section, the bpf program will fail to load. The bpf target does not support switch table optimization. The clang option }(hjhhhNhNubj)}(h``-fno-jump-tables``h]h-fno-jump-tables}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh0 can be used to disable switch table generation.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXFor clang ``--target=bpf``, it is guaranteed that pointer or long / unsigned long types will always have a width of 64 bit, no matter whether underlying clang binary or default target (or kernel) is 32 bit. However, when native clang target is used, then it will compile these types based on the underlying architecture's conventions, meaning in case of 32 bit architecture, pointer or long / unsigned long types e.g. in BPF context structure will have width of 32 bit while the BPF LLVM back end still operates in 64 bit. The native target is mostly needed in tracing for the case of walking ``pt_regs`` or other kernel structures where CPU's register width matters. Otherwise, ``clang --target=bpf`` is generally recommended. h]h)}(hXFor clang ``--target=bpf``, it is guaranteed that pointer or long / unsigned long types will always have a width of 64 bit, no matter whether underlying clang binary or default target (or kernel) is 32 bit. However, when native clang target is used, then it will compile these types based on the underlying architecture's conventions, meaning in case of 32 bit architecture, pointer or long / unsigned long types e.g. in BPF context structure will have width of 32 bit while the BPF LLVM back end still operates in 64 bit. The native target is mostly needed in tracing for the case of walking ``pt_regs`` or other kernel structures where CPU's register width matters. Otherwise, ``clang --target=bpf`` is generally recommended.h](h For clang }(hjhhhNhNubj)}(h``--target=bpf``h]h --target=bpf}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhX9, it is guaranteed that pointer or long / unsigned long types will always have a width of 64 bit, no matter whether underlying clang binary or default target (or kernel) is 32 bit. However, when native clang target is used, then it will compile these types based on the underlying architecture’s conventions, meaning in case of 32 bit architecture, pointer or long / unsigned long types e.g. in BPF context structure will have width of 32 bit while the BPF LLVM back end still operates in 64 bit. The native target is mostly needed in tracing for the case of walking }(hjhhhNhNubj)}(h ``pt_regs``h]hpt_regs}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhM or other kernel structures where CPU’s register width matters. Otherwise, }(hjhhhNhNubj)}(h``clang --target=bpf``h]hclang --target=bpf}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh is generally recommended.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubeh}(h]h ]h"]h$]h&]jjcuh1hhhhMhj7hhubh)}(h#You should use default target when:h]h#You should use default target when:}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj7hhubh)}(hhh](h)}(hYour program includes a header file, e.g., ptrace.h, which eventually pulls in some header files containing file scope host assembly codes. h]h)}(hYour program includes a header file, e.g., ptrace.h, which eventually pulls in some header files containing file scope host assembly codes.h]hYour program includes a header file, e.g., ptrace.h, which eventually pulls in some header files containing file scope host assembly codes.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhj}hhhhhNubh)}(hHYou can add ``-fno-jump-tables`` to work around the switch table issue. h]h)}(hGYou can add ``-fno-jump-tables`` to work around the switch table issue.h](h You can add }(hjhhhNhNubj)}(h``-fno-jump-tables``h]h-fno-jump-tables}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh' to work around the switch table issue.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhj}hhhhhNubeh}(h]h ]h"]h$]h&]jjcuh1hhhhMhj7hhubh)}(hTOtherwise, you can use ``bpf`` target. Additionally, you *must* use bpf target when:h](hOtherwise, you can use }(hjhhhNhNubj)}(h``bpf``h]hbpf}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh target. Additionally, you }(hjhhhNhNubj2)}(h*must*h]hmust}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j1hjubh use bpf target when:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj7hhubh)}(hhh]h)}(hXYour program uses data structures with pointer or long / unsigned long types that interface with BPF helpers or context data structures. Access into these structures is verified by the BPF verifier and may result in verification failures if the native architecture is not aligned with the BPF architecture, e.g. 64-bit. An example of this is BPF_PROG_TYPE_SK_MSG require ``--target=bpf`` h]h)}(hXYour program uses data structures with pointer or long / unsigned long types that interface with BPF helpers or context data structures. Access into these structures is verified by the BPF verifier and may result in verification failures if the native architecture is not aligned with the BPF architecture, e.g. 64-bit. An example of this is BPF_PROG_TYPE_SK_MSG require ``--target=bpf``h](hXsYour program uses data structures with pointer or long / unsigned long types that interface with BPF helpers or context data structures. Access into these structures is verified by the BPF verifier and may result in verification failures if the native architecture is not aligned with the BPF architecture, e.g. 64-bit. An example of this is BPF_PROG_TYPE_SK_MSG require }(hjhhhNhNubj)}(h``--target=bpf``h]h --target=bpf}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubah}(h]h ]h"]h$]h&]jjcuh1hhhhMhj7hhubhcomment)}(hLinksh]hLinks}hj+sbah}(h]h ]h"]h$]h&]jA jB uh1j)hj7hhhhhMubhtarget)}(hv.. _selftests: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/h]h}(h] selftestsah ]h"] selftestsah$]h&]j j uh1j9hMhj7hhhh referencedKubh)}(hHappy BPF hacking!h]hHappy BPF hacking!}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj7hhubeh}(h]j{ah ]h"]q: clang flag for target bpf?ah$]h&]uh1hhj.hhhhhMubeh}(h]jah ]h"]llvmah$]h&]uh1hhhhhhhhMjGKubeh}(h]!howto-interact-with-bpf-subsystemah ]h"]!howto interact with bpf subsystemah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}( selftests](j j j j, jellvm]j5aurefids}nameids}(jijfjjjhjjjjEjjdjjjojjG jj jj jj j0j jRjo jtj jj jj jj jjjjj@jSjbjyjj_jj*jjjjjjXj7j+jejjj$jjajjjj9jjRj7j4jYjZj{jDjAu nametypes}(jijjjjjjjojG j j j j jo j j j j jjjSjyj_j*jjjXj+jj$jajj9jRj4jZjDuh}(jfhjhhjjjjEjjdjjjjjjjrjjJ jj j0j jRj jtj jjr jj jj jj jj j@jjbjjjVjjjjjj-jjj7jjejbjjsjjjj.jj?jjj7j<jYjUj{j7jAj;hhjjj?j6j^jUjjwjjjjjjjjj*j!jLjCjnjejjjjjjjjjjj:j1j\jSj~jujjjjjjjjj1j(j_jVj~jujjjjjjjjj1j(jSjJjujlu footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}jK"sRparse_messages]transform_messages] transformerN include_log] decorationNhhub.