€•Œsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ/translations/zh_CN/bpf/kfuncs”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/zh_TW/bpf/kfuncs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/it_IT/bpf/kfuncs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/ja_JP/bpf/kfuncs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/ko_KR/bpf/kfuncs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/pt_BR/bpf/kfuncs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ/translations/sp_SP/bpf/kfuncs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)�”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…”�”}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ8/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs.rst”h´KubhŒtarget”“”)�”}”(hŒ.. _kfuncs-header-label:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œkfuncs-header-label”uh1hÈh´Khhh²hh³hÇubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒBPF Kernel Functions (kfuncs)”h]”hŒBPF Kernel Functions (kfuncs)”…”�”}”(hhÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhhØh²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒ1. Introduction”h]”hŒ1. Introduction”…”�”}”(hhîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhhëh²hh³hÇh´K ubhŒ paragraph”“”)�”}”(hX…BPF Kernel Functions or more commonly known as kfuncs are functions in the Linux kernel which are exposed for use by BPF programs. Unlike normal BPF helpers, kfuncs do not have a stable interface and can change from one kernel release to another. Hence, BPF programs need to be updated in response to changes in the kernel. See :ref:`BPF_kfunc_lifecycle_expectations` for more information.”h]”(hXHBPF Kernel Functions or more commonly known as kfuncs are functions in the Linux kernel which are exposed for use by BPF programs. Unlike normal BPF helpers, kfuncs do not have a stable interface and can change from one kernel release to another. Hence, BPF programs need to be updated in response to changes in the kernel. See ”…”�”}”(hhþh²hh³Nh´Nubh)�”}”(hŒ':ref:`BPF_kfunc_lifecycle_expectations`”h]”hŒinline”“”)�”}”(hjh]”hŒ BPF_kfunc_lifecycle_expectations”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œ bpf/kfuncs”Œ refdomain”jŒreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆŒ reftarget”Œ bpf_kfunc_lifecycle_expectations”uh1hh³hÇh´K hhþubhŒ for more information.”…”�”}”(hhþh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K hhëh²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ1. introduction”ah$]”h&]”uh1hÖhhØh²hh³hÇh´K ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2. Defining a kfunc”h]”hŒ2. Defining a kfunc”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj=h²hh³hÇh´Kubhý)�”}”(hX8There are two ways to expose a kernel function to BPF programs, either make an existing function in the kernel visible, or add a new wrapper for BPF. In both cases, care must be taken that BPF program can only call such function in a valid context. To enforce this, visibility of a kfunc can be per program type.”h]”hX8There are two ways to expose a kernel function to BPF programs, either make an existing function in the kernel visible, or add a new wrapper for BPF. In both cases, care must be taken that BPF program can only call such function in a valid context. To enforce this, visibility of a kfunc can be per program type.”…”�”}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Khj=h²hubhý)�”}”(hŒiIf you are not creating a BPF wrapper for existing kernel function, skip ahead to :ref:`BPF_kfunc_nodef`.”h]”(hŒRIf you are not creating a BPF wrapper for existing kernel function, skip ahead to ”…”�”}”(hj\h²hh³Nh´Nubh)�”}”(hŒ:ref:`BPF_kfunc_nodef`”h]”j )�”}”(hjfh]”hŒBPF_kfunc_nodef”…”�”}”(hjhh²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjdubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jrŒreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj)Œbpf_kfunc_nodef”uh1hh³hÇh´Khj\ubhŒ.”…”�”}”(hj\h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Khj=h²hubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.1 Creating a wrapper kfunc”h]”hŒ2.1 Creating a wrapper kfunc”…”�”}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjŽh²hh³hÇh´Kubhý)�”}”(hXWhen defining a wrapper kfunc, the wrapper function should have extern linkage. This prevents the compiler from optimizing away dead code, as this wrapper kfunc is not invoked anywhere in the kernel itself. It is not necessary to provide a prototype in a header for the wrapper kfunc.”h]”hXWhen defining a wrapper kfunc, the wrapper function should have extern linkage. This prevents the compiler from optimizing away dead code, as this wrapper kfunc is not invoked anywhere in the kernel itself. It is not necessary to provide a prototype in a header for the wrapper kfunc.”…”�”}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K hjŽh²hubhý)�”}”(hŒAn example is given below::”h]”hŒAn example is given below:”…”�”}”(hj­h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K%hjŽh²hubhŒ literal_block”“”)�”}”(hŒÏ/* Disables missing prototype warnings */ __bpf_kfunc_start_defs(); __bpf_kfunc struct task_struct *bpf_find_get_task_by_vpid(pid_t nr) { return find_get_task_by_vpid(nr); } __bpf_kfunc_end_defs();”h]”hŒÏ/* Disables missing prototype warnings */ __bpf_kfunc_start_defs(); __bpf_kfunc struct task_struct *bpf_find_get_task_by_vpid(pid_t nr) { return find_get_task_by_vpid(nr); } __bpf_kfunc_end_defs();”…”�”}”hj½sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j»h³hÇh´K'hjŽh²hubhý)�”}”(hŒÜA wrapper kfunc is often needed when we need to annotate parameters of the kfunc. Otherwise one may directly make the kfunc visible to the BPF program by registering it with the BPF subsystem. See :ref:`BPF_kfunc_nodef`.”h]”(hŒÅA wrapper kfunc is often needed when we need to annotate parameters of the kfunc. Otherwise one may directly make the kfunc visible to the BPF program by registering it with the BPF subsystem. See ”…”�”}”(hjËh²hh³Nh´Nubh)�”}”(hŒ:ref:`BPF_kfunc_nodef`”h]”j )�”}”(hjÕh]”hŒBPF_kfunc_nodef”…”�”}”(hj×h²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjÓubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jáŒreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj)Œbpf_kfunc_nodef”uh1hh³hÇh´K1hjËubhŒ.”…”�”}”(hjËh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K1hjŽh²hubeh}”(h]”Œcreating-a-wrapper-kfunc”ah ]”h"]”Œ2.1 creating a wrapper kfunc”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.2 kfunc Parameters”h]”hŒ2.2 kfunc Parameters”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´K6ubhý)�”}”(hX%All kfuncs now require trusted arguments by default. This means that all pointer arguments must be valid, and all pointers to BTF objects must be passed in their unmodified form (at a zero offset, and without having been obtained from walking another pointer, with exceptions described below).”h]”hX%All kfuncs now require trusted arguments by default. This means that all pointer arguments must be valid, and all pointers to BTF objects must be passed in their unmodified form (at a zero offset, and without having been obtained from walking another pointer, with exceptions described below).”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K8hjh²hubhý)�”}”(hŒQThere are two types of pointers to kernel objects which are considered "trusted":”h]”hŒUThere are two types of pointers to kernel objects which are considered “trustedâ€�:”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K=hjh²hubhŒenumerated_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒIPointers which are passed as tracepoint or struct_ops callback arguments.”h]”hý)�”}”(hj;h]”hŒIPointers which are passed as tracepoint or struct_ops callback arguments.”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K?hj9ubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hj4h²hh³hÇh´Nubj8)�”}”(hŒ6Pointers which were returned from a KF_ACQUIRE kfunc. ”h]”hý)�”}”(hŒ5Pointers which were returned from a KF_ACQUIRE kfunc.”h]”hŒ5Pointers which were returned from a KF_ACQUIRE kfunc.”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K@hjPubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hj4h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1j2hjh²hh³hÇh´K?ubhý)�”}”(hŒpPointers to non-BTF objects (e.g. scalar pointers) may also be passed to kfuncs, and may have a non-zero offset.”h]”hŒpPointers to non-BTF objects (e.g. scalar pointers) may also be passed to kfuncs, and may have a non-zero offset.”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KBhjh²hubhý)�”}”(hŒtThe definition of "valid" pointers is subject to change at any time, and has absolutely no ABI stability guarantees.”h]”hŒxThe definition of “validâ€� pointers is subject to change at any time, and has absolutely no ABI stability guarantees.”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KEhjh²hubhý)�”}”(hXMAs mentioned above, a nested pointer obtained from walking a trusted pointer is no longer trusted, with one exception. If a struct type has a field that is guaranteed to be valid (trusted or rcu, as in KF_RCU description below) as long as its parent pointer is valid, the following macros can be used to express that to the verifier:”h]”hXMAs mentioned above, a nested pointer obtained from walking a trusted pointer is no longer trusted, with one exception. If a struct type has a field that is guaranteed to be valid (trusted or rcu, as in KF_RCU description below) as long as its parent pointer is valid, the following macros can be used to express that to the verifier:”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KHhjh²hubhŒ bullet_list”“”)�”}”(hhh]”(j8)�”}”(hŒ``BTF_TYPE_SAFE_TRUSTED``”h]”hý)�”}”(hj¤h]”hŒliteral”“”)�”}”(hj¤h]”hŒBTF_TYPE_SAFE_TRUSTED”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj¦ubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KNhj¢ubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjŸh²hh³hÇh´Nubj8)�”}”(hŒ``BTF_TYPE_SAFE_RCU``”h]”hý)�”}”(hjÆh]”jª)�”}”(hjÆh]”hŒBTF_TYPE_SAFE_RCU”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÈubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KOhjÄubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjŸh²hh³hÇh´Nubj8)�”}”(hŒ``BTF_TYPE_SAFE_RCU_OR_NULL`` ”h]”hý)�”}”(hŒ``BTF_TYPE_SAFE_RCU_OR_NULL``”h]”jª)�”}”(hjêh]”hŒBTF_TYPE_SAFE_RCU_OR_NULL”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjèubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KPhjäubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjŸh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1j�h³hÇh´KNhjh²hubhý)�”}”(hŒ For example,”h]”hŒ For example,”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KRhjh²hubj¼)�”}”(hŒBBTF_TYPE_SAFE_TRUSTED(struct socket) { struct sock *sk; };”h]”hŒBBTF_TYPE_SAFE_TRUSTED(struct socket) { struct sock *sk; };”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒforce”‰Œlanguage”Œc”Œhighlight_args”}”uh1j»h³hÇh´KThjh²hubhý)�”}”(hŒor”h]”hŒor”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KZhjh²hubj¼)�”}”(hŒÍBTF_TYPE_SAFE_RCU(struct task_struct) { const cpumask_t *cpus_ptr; struct css_set __rcu *cgroups; struct task_struct __rcu *real_parent; struct task_struct *group_leader; };”h]”hŒÍBTF_TYPE_SAFE_RCU(struct task_struct) { const cpumask_t *cpus_ptr; struct css_set __rcu *cgroups; struct task_struct __rcu *real_parent; struct task_struct *group_leader; };”…”�”}”hj<sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´K\hjh²hubhý)�”}”(hŒIn other words, you must:”h]”hŒIn other words, you must:”…”�”}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kehjh²hubj3)�”}”(hhh]”(j8)�”}”(hŒhj‡h²hh³hÇubeh}”(h]”Œ$arena-and-arena-nullable-annotations”ah ]”h"]”Œ/2.3.8 __arena and __arena__nullable annotations”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Mubh×)�”}”(hhh]”(hÜ)�”}”(hŒ%2.4 Using an existing kernel function”h]”hŒ%2.4 Using an existing kernel function”…”�”}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj}h²hh³hÇh´MAubhý)�”}”(hX When an existing function in the kernel is fit for consumption by BPF programs, it can be directly registered with the BPF subsystem. However, care must still be taken to review the context in which it will be invoked by the BPF program and whether it is safe to do so.”h]”hX When an existing function in the kernel is fit for consumption by BPF programs, it can be directly registered with the BPF subsystem. However, care must still be taken to review the context in which it will be invoked by the BPF program and whether it is safe to do so.”…”�”}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MChj}h²hubeh}”(h]”(Œ!using-an-existing-kernel-function”jteh ]”h"]”(Œ%2.4 using an existing kernel function”Œbpf_kfunc_nodef”eh$]”h&]”uh1hÖhj=h²hh³hÇh´MAŒexpect_referenced_by_name”}”j¢jjsŒexpect_referenced_by_id”}”jtjjsubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5 Annotating kfuncs”h]”hŒ2.5 Annotating kfuncs”…”�”}”(hj¬h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj©h²hh³hÇh´MIubhý)�”}”(hŒÂIn addition to kfuncs' arguments, verifier may need more information about the type of kfunc(s) being registered with the BPF subsystem. To do so, we define flags on a set of kfuncs as follows::”h]”hŒÃIn addition to kfuncs’ arguments, verifier may need more information about the type of kfunc(s) being registered with the BPF subsystem. To do so, we define flags on a set of kfuncs as follows:”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MKhj©h²hubj¼)�”}”(hŒ¦BTF_KFUNCS_START(bpf_task_set) BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_put_pid, KF_RELEASE) BTF_KFUNCS_END(bpf_task_set)”h]”hŒ¦BTF_KFUNCS_START(bpf_task_set) BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_put_pid, KF_RELEASE) BTF_KFUNCS_END(bpf_task_set)”…”�”}”hjÈsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j»h³hÇh´MOhj©h²hubhý)�”}”(hŒ„This set encodes the BTF ID of each kfunc listed above, and encodes the flags along with it. It is also allowed to specify no flags.”h]”hŒ„This set encodes the BTF ID of each kfunc listed above, and encodes the flags along with it. It is also allowed to specify no flags.”…”�”}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MThj©h²hubhý)�”}”(hXkfunc definitions should also always be annotated with the ``__bpf_kfunc`` macro. This prevents issues such as the compiler inlining the kfunc, or the function being elided in an LTO build as it's not used in the rest of the kernel. Developers should not manually add annotations to their kfunc to prevent these issues. If an annotation is required to prevent such an issue with your kfunc, it is a bug and should be added to the definition of the macro so that other kfuncs are similarly protected. An example is given below::”h]”(hŒ;kfunc definitions should also always be annotated with the ”…”�”}”(hjäh²hh³Nh´Nubjª)�”}”(hŒ``__bpf_kfunc``”h]”hŒ __bpf_kfunc”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjäubhXÆ macro. This prevents issues such as the compiler inlining the kfunc, or the function being elided in an LTO build as it’s not used in the rest of the kernel. Developers should not manually add annotations to their kfunc to prevent these issues. If an annotation is required to prevent such an issue with your kfunc, it is a bug and should be added to the definition of the macro so that other kfuncs are similarly protected. An example is given below:”…”�”}”(hjäh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MWhj©h²hubj¼)�”}”(hŒA__bpf_kfunc struct task_struct *bpf_get_task_pid(s32 pid) { ... }”h]”hŒA__bpf_kfunc struct task_struct *bpf_get_task_pid(s32 pid) { ... }”…”�”}”hj sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j»h³hÇh´M_hj©h²hubhý)�”}”(hXÝNote that kfuncs must not be declared ``static``. A kfunc can be called from a BPF program ``*.c`` file outside the compilation unit that defines it, so its externally visible name must remain available for BTF ID lookup. ``static`` linkage allows the compiler to rename the function, which can break this BTF-based kfunc resolution. Further note that sparse may warn that an otherwise unreferenced kfunc should be static. Such warnings should be ignored for kfunc definitions.”h]”(hŒ&Note that kfuncs must not be declared ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ ``static``”h]”hŒstatic”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒ+. A kfunc can be called from a BPF program ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ``*.c``”h]”hŒ*.c”…”�”}”(hj, h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒ| file outside the compilation unit that defines it, so its externally visible name must remain available for BTF ID lookup. ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ ``static``”h]”hŒstatic”…”�”}”(hj> h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒõ linkage allows the compiler to rename the function, which can break this BTF-based kfunc resolution. Further note that sparse may warn that an otherwise unreferenced kfunc should be static. Such warnings should be ignored for kfunc definitions.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mdhj©h²hubeh}”(h]”Œannotating-kfuncs”ah ]”h"]”Œ2.5 annotating kfuncs”ah$]”h&]”uh1hÖhj=h²hh³hÇh´MIubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.1 KF_ACQUIRE flag”h]”hŒ2.5.1 KF_ACQUIRE flag”…”�”}”(hja h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj^ h²hh³hÇh´Mmubhý)�”}”(hX§The KF_ACQUIRE flag is used to indicate that the kfunc returns a pointer to a refcounted object. The verifier will then ensure that the pointer to the object is eventually released using a release kfunc, or transferred to a map using a referenced kptr (by invoking bpf_kptr_xchg). If not, the verifier fails the loading of the BPF program until no lingering references remain in all possible explored states of the program.”h]”hX§The KF_ACQUIRE flag is used to indicate that the kfunc returns a pointer to a refcounted object. The verifier will then ensure that the pointer to the object is eventually released using a release kfunc, or transferred to a map using a referenced kptr (by invoking bpf_kptr_xchg). If not, the verifier fails the loading of the BPF program until no lingering references remain in all possible explored states of the program.”…”�”}”(hjo h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mohj^ h²hubeh}”(h]”Œkf-acquire-flag”ah ]”h"]”Œ2.5.1 kf_acquire flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Mmubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.2 KF_RET_NULL flag”h]”hŒ2.5.2 KF_RET_NULL flag”…”�”}”(hjˆ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj… h²hh³hÇh´Mwubhý)�”}”(hXVThe KF_RET_NULL flag is used to indicate that the pointer returned by the kfunc may be NULL. Hence, it forces the user to do a NULL check on the pointer returned from the kfunc before making use of it (dereferencing or passing to another helper). This flag is often used in pairing with KF_ACQUIRE flag, but both are orthogonal to each other.”h]”hXVThe KF_RET_NULL flag is used to indicate that the pointer returned by the kfunc may be NULL. Hence, it forces the user to do a NULL check on the pointer returned from the kfunc before making use of it (dereferencing or passing to another helper). This flag is often used in pairing with KF_ACQUIRE flag, but both are orthogonal to each other.”…”�”}”(hj– h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Myhj… h²hubeh}”(h]”Œkf-ret-null-flag”ah ]”h"]”Œ2.5.2 kf_ret_null flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Mwubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.3 KF_RELEASE flag”h]”hŒ2.5.3 KF_RELEASE flag”…”�”}”(hj¯ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj¬ h²hh³hÇh´M€ubhý)�”}”(hXThe KF_RELEASE flag is used to indicate that the kfunc releases the pointer passed in to it. There can be only one referenced pointer that can be passed in. All copies of the pointer being released are invalidated as a result of invoking kfunc with this flag.”h]”hXThe KF_RELEASE flag is used to indicate that the kfunc releases the pointer passed in to it. There can be only one referenced pointer that can be passed in. All copies of the pointer being released are invalidated as a result of invoking kfunc with this flag.”…”�”}”(hj½ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M‚hj¬ h²hubeh}”(h]”Œkf-release-flag”ah ]”h"]”Œ2.5.3 kf_release flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´M€ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.4 KF_SLEEPABLE flag”h]”hŒ2.5.4 KF_SLEEPABLE flag”…”�”}”(hjÖ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÓ h²hh³hÇh´Mˆubhý)�”}”(hŒ„The KF_SLEEPABLE flag is used for kfuncs that may sleep. Such kfuncs can only be called by sleepable BPF programs (BPF_F_SLEEPABLE).”h]”hŒ„The KF_SLEEPABLE flag is used for kfuncs that may sleep. Such kfuncs can only be called by sleepable BPF programs (BPF_F_SLEEPABLE).”…”�”}”(hjä h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MŠhjÓ h²hubeh}”(h]”Œkf-sleepable-flag”ah ]”h"]”Œ2.5.4 kf_sleepable flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Mˆubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.5 KF_DESTRUCTIVE flag”h]”hŒ2.5.5 KF_DESTRUCTIVE flag”…”�”}”(hjý h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjú h²hh³hÇh´MŽubhý)�”}”(hX6The KF_DESTRUCTIVE flag is used to indicate functions calling which is destructive to the system. For example such a call can result in system rebooting or panicking. Due to this additional restrictions apply to these calls. At the moment they only require CAP_SYS_BOOT capability, but more can be added later.”h]”hX6The KF_DESTRUCTIVE flag is used to indicate functions calling which is destructive to the system. For example such a call can result in system rebooting or panicking. Due to this additional restrictions apply to these calls. At the moment they only require CAP_SYS_BOOT capability, but more can be added later.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M�hjú h²hubeh}”(h]”Œkf-destructive-flag”ah ]”h"]”Œ2.5.5 kf_destructive flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´MŽubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.6 KF_RCU flag”h]”hŒ2.5.6 KF_RCU flag”…”�”}”(hj$ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj! h²hh³hÇh´M—ubhý)�”}”(hX0The KF_RCU flag allows kfuncs to opt out of the default trusted args requirement and accept RCU pointers with weaker guarantees. The kfuncs marked with KF_RCU expect either PTR_TRUSTED or MEM_RCU arguments. The verifier guarantees that the objects are valid and there is no use-after-free. The pointers are not NULL, but the object's refcount could have reached zero. The kfuncs need to consider doing refcnt != 0 check, especially when returning a KF_ACQUIRE pointer. Note as well that a KF_ACQUIRE kfunc that is KF_RCU should very likely also be KF_RET_NULL.”h]”hX2The KF_RCU flag allows kfuncs to opt out of the default trusted args requirement and accept RCU pointers with weaker guarantees. The kfuncs marked with KF_RCU expect either PTR_TRUSTED or MEM_RCU arguments. The verifier guarantees that the objects are valid and there is no use-after-free. The pointers are not NULL, but the object’s refcount could have reached zero. The kfuncs need to consider doing refcnt != 0 check, especially when returning a KF_ACQUIRE pointer. Note as well that a KF_ACQUIRE kfunc that is KF_RCU should very likely also be KF_RET_NULL.”…”�”}”(hj2 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M™hj! h²hubeh}”(h]”Œ kf-rcu-flag”ah ]”h"]”Œ2.5.6 kf_rcu flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´M—ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.7 KF_RCU_PROTECTED flag”h]”hŒ2.5.7 KF_RCU_PROTECTED flag”…”�”}”(hjK h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjH h²hh³hÇh´M£ubhý)�”}”(hŒòThe KF_RCU_PROTECTED flag is used to indicate that the kfunc must be invoked in an RCU critical section. This is assumed by default in non-sleepable programs, and must be explicitly ensured by calling ``bpf_rcu_read_lock`` for sleepable ones.”h]”(hŒÉThe KF_RCU_PROTECTED flag is used to indicate that the kfunc must be invoked in an RCU critical section. This is assumed by default in non-sleepable programs, and must be explicitly ensured by calling ”…”�”}”(hjY h²hh³Nh´Nubjª)�”}”(hŒ``bpf_rcu_read_lock``”h]”hŒbpf_rcu_read_lock”…”�”}”(hja h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjY ubhŒ for sleepable ones.”…”�”}”(hjY h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M¥hjH h²hubhý)�”}”(hŒ¨If the kfunc returns a pointer value, this flag also enforces that the returned pointer is RCU protected, and can only be used while the RCU critical section is active.”h]”hŒ¨If the kfunc returns a pointer value, this flag also enforces that the returned pointer is RCU protected, and can only be used while the RCU critical section is active.”…”�”}”(hjy h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MªhjH h²hubhý)�”}”(hX#The flag is distinct from the ``KF_RCU`` flag, which only ensures that its arguments are at least RCU protected pointers. This may transitively imply that RCU protection is ensured, but it does not work in cases of kfuncs which require RCU protection but do not take RCU protected arguments.”h]”(hŒThe flag is distinct from the ”…”�”}”(hj‡ h²hh³Nh´Nubjª)�”}”(hŒ ``KF_RCU``”h]”hŒKF_RCU”…”�”}”(hj� h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj‡ ubhŒû flag, which only ensures that its arguments are at least RCU protected pointers. This may transitively imply that RCU protection is ensured, but it does not work in cases of kfuncs which require RCU protection but do not take RCU protected arguments.”…”�”}”(hj‡ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M®hjH h²hubhÉ)�”}”(hŒ.. _KF_deprecated_flag:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÔŒkf-deprecated-flag”uh1hÈh´M³hjH h²hh³hÇubeh}”(h]”Œkf-rcu-protected-flag”ah ]”h"]”Œ2.5.7 kf_rcu_protected flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´M£ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.8 KF_DEPRECATED flag”h]”hŒ2.5.8 KF_DEPRECATED flag”…”�”}”(hj½ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjº h²hh³hÇh´M¶ubhý)�”}”(hX¹The KF_DEPRECATED flag is used for kfuncs which are scheduled to be changed or removed in a subsequent kernel release. A kfunc that is marked with KF_DEPRECATED should also have any relevant information captured in its kernel doc. Such information typically includes the kfunc's expected remaining lifespan, a recommendation for new functionality that can replace it if any is available, and possibly a rationale for why it is being removed.”h]”hX»The KF_DEPRECATED flag is used for kfuncs which are scheduled to be changed or removed in a subsequent kernel release. A kfunc that is marked with KF_DEPRECATED should also have any relevant information captured in its kernel doc. Such information typically includes the kfunc’s expected remaining lifespan, a recommendation for new functionality that can replace it if any is available, and possibly a rationale for why it is being removed.”…”�”}”(hjË h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M¸hjº h²hubhý)�”}”(hXGNote that while on some occasions, a KF_DEPRECATED kfunc may continue to be supported and have its KF_DEPRECATED flag removed, it is likely to be far more difficult to remove a KF_DEPRECATED flag after it's been added than it is to prevent it from being added in the first place. As described in :ref:`BPF_kfunc_lifecycle_expectations`, users that rely on specific kfuncs are encouraged to make their use-cases known as early as possible, and participate in upstream discussions regarding whether to keep, change, deprecate, or remove those kfuncs if and when such discussions occur.”h]”(hX*Note that while on some occasions, a KF_DEPRECATED kfunc may continue to be supported and have its KF_DEPRECATED flag removed, it is likely to be far more difficult to remove a KF_DEPRECATED flag after it’s been added than it is to prevent it from being added in the first place. As described in ”…”�”}”(hjÙ h²hh³Nh´Nubh)�”}”(hŒ':ref:`BPF_kfunc_lifecycle_expectations`”h]”j )�”}”(hjã h]”hŒ BPF_kfunc_lifecycle_expectations”…”�”}”(hjå h²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjá ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jï Œreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj)Œ bpf_kfunc_lifecycle_expectations”uh1hh³hÇh´MÀhjÙ ubhŒø, users that rely on specific kfuncs are encouraged to make their use-cases known as early as possible, and participate in upstream discussions regarding whether to keep, change, deprecate, or remove those kfuncs if and when such discussions occur.”…”�”}”(hjÙ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÀhjº h²hubeh}”(h]”(j± Œid1”eh ]”h"]”(Œ2.5.8 kf_deprecated flag”Œkf_deprecated_flag”eh$]”h&]”uh1hÖhj=h²hh³hÇh´M¶j¥}”j j§ sj§}”j± j§ subh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.9 KF_IMPLICIT_ARGS flag”h]”hŒ2.5.9 KF_IMPLICIT_ARGS flag”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj h²hh³hÇh´MÊubhý)�”}”(hŒËThe KF_IMPLICIT_ARGS flag is used to indicate that the BPF signature of the kfunc is different from it's kernel signature, and the values for implicit arguments are provided at load time by the verifier.”h]”hŒÍThe KF_IMPLICIT_ARGS flag is used to indicate that the BPF signature of the kfunc is different from it’s kernel signature, and the values for implicit arguments are provided at load time by the verifier.”…”�”}”(hj' h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÌhj h²hubhý)�”}”(hŒjOnly arguments of specific types are implicit. Currently only ``struct bpf_prog_aux *`` type is supported.”h]”(hŒ>Only arguments of specific types are implicit. Currently only ”…”�”}”(hj5 h²hh³Nh´Nubjª)�”}”(hŒ``struct bpf_prog_aux *``”h]”hŒstruct bpf_prog_aux *”…”�”}”(hj= h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj5 ubhŒ type is supported.”…”�”}”(hj5 h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÐhj h²hubhý)�”}”(hŒÉA kfunc with KF_IMPLICIT_ARGS flag therefore has two types in BTF: one function matching the kernel declaration (with _impl suffix in the name by convention), and another matching the intended BPF API.”h]”hŒÉA kfunc with KF_IMPLICIT_ARGS flag therefore has two types in BTF: one function matching the kernel declaration (with _impl suffix in the name by convention), and another matching the intended BPF API.”…”�”}”(hjU h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÓhj h²hubhý)�”}”(hŒuVerifier only allows calls to the non-_impl version of a kfunc, that uses a signature without the implicit arguments.”h]”hŒuVerifier only allows calls to the non-_impl version of a kfunc, that uses a signature without the implicit arguments.”…”�”}”(hjc h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M×hj h²hubhý)�”}”(hŒExample declaration:”h]”hŒExample declaration:”…”�”}”(hjq h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÚhj h²hubj¼)�”}”(hX__bpf_kfunc int bpf_task_work_schedule_signal(struct task_struct *task, struct bpf_task_work *tw, void *map__const_map, bpf_task_work_callback_t callback, struct bpf_prog_aux *aux) { ... }”h]”hX__bpf_kfunc int bpf_task_work_schedule_signal(struct task_struct *task, struct bpf_task_work *tw, void *map__const_map, bpf_task_work_callback_t callback, struct bpf_prog_aux *aux) { ... }”…”�”}”hj sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´MÜhj h²hubhý)�”}”(hŒExample usage in BPF program:”h]”hŒExample usage in BPF program:”…”�”}”(hjŽ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mâhj h²hubj¼)�”}”(hŒy/* note that the last argument is omitted */ bpf_task_work_schedule_signal(task, &work->tw, &arrmap, task_work_callback);”h]”hŒy/* note that the last argument is omitted */ bpf_task_work_schedule_signal(task, &work->tw, &arrmap, task_work_callback);”…”�”}”hjœ sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´Mähj h²hubeh}”(h]”Œkf-implicit-args-flag”ah ]”h"]”Œ2.5.9 kf_implicit_args flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´MÊubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.5.10 KF_PERFMON flag”h]”hŒ2.5.10 KF_PERFMON flag”…”�”}”(hj¶ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj³ h²hh³hÇh´Mêubhý)�”}”(hX†The KF_PERFMON flag is used for kfuncs that can expose kernel memory or kernel addresses to the BPF program, for example by reading through a pointer that the verifier does not check. Calling such a kfunc requires CAP_PERFMON, or CAP_SYS_ADMIN, in the same way that the equivalent BPF helpers are gated in bpf_base_func_proto(). A program loaded with CAP_BPF alone is rejected at load time.”h]”hX†The KF_PERFMON flag is used for kfuncs that can expose kernel memory or kernel addresses to the BPF program, for example by reading through a pointer that the verifier does not check. Calling such a kfunc requires CAP_PERFMON, or CAP_SYS_ADMIN, in the same way that the equivalent BPF helpers are gated in bpf_base_func_proto(). A program loaded with CAP_BPF alone is rejected at load time.”…”�”}”(hjÄ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mìhj³ h²hubeh}”(h]”Œkf-perfmon-flag”ah ]”h"]”Œ2.5.10 kf_perfmon flag”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Mêubh×)�”}”(hhh]”(hÜ)�”}”(hŒ2.6 Registering the kfuncs”h]”hŒ2.6 Registering the kfuncs”…”�”}”(hjÝ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÚ h²hh³hÇh´Môubhý)�”}”(hŒ¸Once the kfunc is prepared for use, the final step to making it visible is registering it with the BPF subsystem. Registration is done per BPF program type. An example is shown below::”h]”hŒ·Once the kfunc is prepared for use, the final step to making it visible is registering it with the BPF subsystem. Registration is done per BPF program type. An example is shown below:”…”�”}”(hjë h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MöhjÚ h²hubj¼)�”}”(hX¾BTF_KFUNCS_START(bpf_task_set) BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_put_pid, KF_RELEASE) BTF_KFUNCS_END(bpf_task_set) static const struct btf_kfunc_id_set bpf_task_kfunc_set = { .owner = THIS_MODULE, .set = &bpf_task_set, }; static int init_subsystem(void) { return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_task_kfunc_set); } late_initcall(init_subsystem);”h]”hX¾BTF_KFUNCS_START(bpf_task_set) BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_put_pid, KF_RELEASE) BTF_KFUNCS_END(bpf_task_set) static const struct btf_kfunc_id_set bpf_task_kfunc_set = { .owner = THIS_MODULE, .set = &bpf_task_set, }; static int init_subsystem(void) { return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_task_kfunc_set); } late_initcall(init_subsystem);”…”�”}”hjù sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j»h³hÇh´MúhjÚ h²hubhý)�”}”(hX¡At kernel build time the ``resolve_btfids`` tool finds all kfuncs declared with ``BTF_KFUNCS_START()`` and emits their BTF annotations into the kernel's BTF. For each kfunc it emits a ``bpf_kfunc`` BTF decl tag, a ``bpf_fastcall`` decl tag when the kfunc is flagged ``KF_FASTCALL``, and the ``address_space(1)`` type attribute on the return value and/or arguments that use arena pointers (see sections 2.3.8 and 2.8).”h]”(hŒAt kernel build time the ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ``resolve_btfids``”h]”hŒresolve_btfids”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒ% tool finds all kfuncs declared with ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ``BTF_KFUNCS_START()``”h]”hŒBTF_KFUNCS_START()”…”�”}”(hj! h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒT and emits their BTF annotations into the kernel’s BTF. For each kfunc it emits a ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ ``bpf_kfunc``”h]”hŒ bpf_kfunc”…”�”}”(hj3 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒ BTF decl tag, a ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ``bpf_fastcall``”h]”hŒ bpf_fastcall”…”�”}”(hjE h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒ$ decl tag when the kfunc is flagged ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ``KF_FASTCALL``”h]”hŒ KF_FASTCALL”…”�”}”(hjW h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒ , and the ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ``address_space(1)``”h]”hŒaddress_space(1)”…”�”}”(hji h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒj type attribute on the return value and/or arguments that use arena pointers (see sections 2.3.8 and 2.8).”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M hjÚ h²hubeh}”(h]”Œregistering-the-kfuncs”ah ]”h"]”Œ2.6 registering the kfuncs”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Môubh×)�”}”(hhh]”(hÜ)�”}”(hŒ,2.7 Specifying no-cast aliases with ___init”h]”hŒ,2.7 Specifying no-cast aliases with ___init”…”�”}”(hjŒ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj‰ h²hh³hÇh´Mubhý)�”}”(hX=The verifier will always enforce that the BTF type of a pointer passed to a kfunc by a BPF program, matches the type of pointer specified in the kfunc definition. The verifier, does, however, allow types that are equivalent according to the C standard to be passed to the same kfunc arg, even if their BTF_IDs differ.”h]”hX=The verifier will always enforce that the BTF type of a pointer passed to a kfunc by a BPF program, matches the type of pointer specified in the kfunc definition. The verifier, does, however, allow types that are equivalent according to the C standard to be passed to the same kfunc arg, even if their BTF_IDs differ.”…”�”}”(hjš h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhj‰ h²hubhý)�”}”(hŒ/For example, for the following type definition:”h]”hŒ/For example, for the following type definition:”…”�”}”(hj¨ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhj‰ h²hubj¼)�”}”(hŒLstruct bpf_cpumask { cpumask_t cpumask; refcount_t usage; };”h]”hŒLstruct bpf_cpumask { cpumask_t cpumask; refcount_t usage; };”…”�”}”hj¶ sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´Mhj‰ h²hubhý)�”}”(hXThe verifier would allow a ``struct bpf_cpumask *`` to be passed to a kfunc taking a ``cpumask_t *`` (which is a typedef of ``struct cpumask *``). For instance, both ``struct cpumask *`` and ``struct bpf_cpmuask *`` can be passed to bpf_cpumask_test_cpu().”h]”(hŒThe verifier would allow a ”…”�”}”(hjÅ h²hh³Nh´Nubjª)�”}”(hŒ``struct bpf_cpumask *``”h]”hŒstruct bpf_cpumask *”…”�”}”(hjÍ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÅ ubhŒ" to be passed to a kfunc taking a ”…”�”}”(hjÅ h²hh³Nh´Nubjª)�”}”(hŒ``cpumask_t *``”h]”hŒ cpumask_t *”…”�”}”(hjß h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÅ ubhŒ (which is a typedef of ”…”�”}”(hjÅ h²hh³Nh´Nubjª)�”}”(hŒ``struct cpumask *``”h]”hŒstruct cpumask *”…”�”}”(hjñ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÅ ubhŒ). For instance, both ”…”�”}”(hjÅ h²hh³Nh´Nubjª)�”}”(hŒ``struct cpumask *``”h]”hŒstruct cpumask *”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÅ ubhŒ and ”…”�”}”(hjÅ h²hh³Nh´Nubjª)�”}”(hŒ``struct bpf_cpmuask *``”h]”hŒstruct bpf_cpmuask *”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÅ ubhŒ) can be passed to bpf_cpumask_test_cpu().”…”�”}”(hjÅ h²hh³•Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M#hj‰ h²hubhý)�”}”(hŒiIn some cases, this type-aliasing behavior is not desired. ``struct nf_conn___init`` is one such example:”h]”(hŒ;In some cases, this type-aliasing behavior is not desired. ”…”�”}”(hj- h²hh³Nh´Nubjª)�”}”(hŒ``struct nf_conn___init``”h]”hŒstruct nf_conn___init”…”�”}”(hj5 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj- ubhŒ is one such example:”…”�”}”(hj- h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M(hj‰ h²hubj¼)�”}”(hŒ5struct nf_conn___init { struct nf_conn ct; };”h]”hŒ5struct nf_conn___init { struct nf_conn ct; };”…”�”}”hjM sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´M+hj‰ h²hubhý)�”}”(hX£The C standard would consider these types to be equivalent, but it would not always be safe to pass either type to a trusted kfunc. ``struct nf_conn___init`` represents an allocated ``struct nf_conn`` object that has *not yet been initialized*, so it would therefore be unsafe to pass a ``struct nf_conn___init *`` to a kfunc that's expecting a fully initialized ``struct nf_conn *`` (e.g. ``bpf_ct_change_timeout()``).”h]”(hŒ„The C standard would consider these types to be equivalent, but it would not always be safe to pass either type to a trusted kfunc. ”…”�”}”(hj\ h²hh³Nh´Nubjª)�”}”(hŒ``struct nf_conn___init``”h]”hŒstruct nf_conn___init”…”�”}”(hjd h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj\ ubhŒ represents an allocated ”…”�”}”(hj\ h²hh³Nh´Nubjª)�”}”(hŒ``struct nf_conn``”h]”hŒstruct nf_conn”…”�”}”(hjv h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj\ ubhŒ object that has ”…”�”}”(hj\ h²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ*not yet been initialized*”h]”hŒnot yet been initialized”…”�”}”(hjŠ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jˆ hj\ ubhŒ,, so it would therefore be unsafe to pass a ”…”�”}”(hj\ h²hh³Nh´Nubjª)�”}”(hŒ``struct nf_conn___init *``”h]”hŒstruct nf_conn___init *”…”�”}”(hjœ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj\ ubhŒ3 to a kfunc that’s expecting a fully initialized ”…”�”}”(hj\ h²hh³Nh´Nubjª)�”}”(hŒ``struct nf_conn *``”h]”hŒstruct nf_conn *”…”�”}”(hj® h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj\ ubhŒ (e.g. ”…”�”}”(hj\ h²hh³Nh´Nubjª)�”}”(hŒ``bpf_ct_change_timeout()``”h]”hŒbpf_ct_change_timeout()”…”�”}”(hjÀ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj\ ubhŒ).”…”�”}”(hj\ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M1hj‰ h²hubhý)�”}”(hŒ¸In order to accommodate such requirements, the verifier will enforce strict PTR_TO_BTF_ID type matching if two types have the exact same name, with one being suffixed with ``___init``.”h]”(hŒ¬In order to accommodate such requirements, the verifier will enforce strict PTR_TO_BTF_ID type matching if two types have the exact same name, with one being suffixed with ”…”�”}”(hjØ h²hh³Nh´Nubjª)�”}”(hŒ ``___init``”h]”hŒ___init”…”�”}”(hjà h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjØ ubhŒ.”…”�”}”(hjØ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M8hj‰ h²hubhÉ)�”}”(hŒ.. _BPF_kfunc_arena_access:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÔŒbpf-kfunc-arena-access”uh1hÈh´M<hj‰ h²hh³hÇubeh}”(h]”Œ$specifying-no-cast-aliases-with-init”ah ]”h"]”Œ+2.7 specifying no-cast aliases with ___init”ah$]”h&]”uh1hÖhj=h²hh³hÇh´Mubh×)�”}”(hhh]”(hÜ)�”}”(hŒ22.8 Accessing arena memory through kfunc arguments”h]”hŒ22.8 Accessing arena memory through kfunc arguments”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj h²hh³hÇh´M?ubhý)�”}”(hXA read or write at any address inside an arena does not oops the kernel. Unallocated arena pages are lazily backed by a scratch page and the access is reported through the program's BPF stream as an error. Only the BPF program's correctness is affected; the kernel itself remains intact.”h]”hX#A read or write at any address inside an arena does not oops the kernel. Unallocated arena pages are lazily backed by a scratch page and the access is reported through the program’s BPF stream as an error. Only the BPF program’s correctness is affected; the kernel itself remains intact.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MAhj h²hubhý)�”}”(hXThe arena is followed by a ``GUARD_SZ / 2`` (32 KiB) guard region that is also covered by this recovery. A kfunc handed an arena pointer may therefore access up to ``GUARD_SZ / 2`` past it without bounds-checking against the arena. Larger accesses must verify the range explicitly.”h]”(hŒThe arena is followed by a ”…”�”}”(hj*h²hh³Nh´Nubjª)�”}”(hŒ``GUARD_SZ / 2``”h]”hŒ GUARD_SZ / 2”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj*ubhŒy (32 KiB) guard region that is also covered by this recovery. A kfunc handed an arena pointer may therefore access up to ”…”�”}”(hj*h²hh³Nh´Nubjª)�”}”(hŒ``GUARD_SZ / 2``”h]”hŒ GUARD_SZ / 2”…”�”}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj*ubhŒe past it without bounds-checking against the arena. Larger accesses must verify the range explicitly.”…”�”}”(hj*h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MGhj h²hubhÉ)�”}”(hŒ%.. _BPF_kfunc_lifecycle_expectations:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÔŒ bpf-kfunc-lifecycle-expectations”uh1hÈh´MLhj h²hh³hÇubeh}”(h]”(Œ.accessing-arena-memory-through-kfunc-arguments”jeh ]”h"]”(Œ22.8 accessing arena memory through kfunc arguments”Œbpf_kfunc_arena_access”eh$]”h&]”uh1hÖhj=h²hh³hÇh´M?j¥}”jmjø sj§}”jjø subeh}”(h]”Œdefining-a-kfunc”ah ]”h"]”Œ2. defining a kfunc”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒ3. kfunc lifecycle expectations”h]”hŒ3. kfunc lifecycle expectations”…”�”}”(hj}h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjzh²hh³hÇh´MOubhý)�”}”(hXMkfuncs provide a kernel <-> kernel API, and thus are not bound by any of the strict stability restrictions associated with kernel <-> user UAPIs. This means they can be thought of as similar to EXPORT_SYMBOL_GPL, and can therefore be modified or removed by a maintainer of the subsystem they're defined in when it's deemed necessary.”h]”hXQkfuncs provide a kernel <-> kernel API, and thus are not bound by any of the strict stability restrictions associated with kernel <-> user UAPIs. This means they can be thought of as similar to EXPORT_SYMBOL_GPL, and can therefore be modified or removed by a maintainer of the subsystem they’re defined in when it’s deemed necessary.”…”�”}”(hj‹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MQhjzh²hubhý)�”}”(hXçLike any other change to the kernel, maintainers will not change or remove a kfunc without having a reasonable justification. Whether or not they'll choose to change a kfunc will ultimately depend on a variety of factors, such as how widely used the kfunc is, how long the kfunc has been in the kernel, whether an alternative kfunc exists, what the norm is in terms of stability for the subsystem in question, and of course what the technical cost is of continuing to support the kfunc.”h]”hXéLike any other change to the kernel, maintainers will not change or remove a kfunc without having a reasonable justification. Whether or not they’ll choose to change a kfunc will ultimately depend on a variety of factors, such as how widely used the kfunc is, how long the kfunc has been in the kernel, whether an alternative kfunc exists, what the norm is in terms of stability for the subsystem in question, and of course what the technical cost is of continuing to support the kfunc.”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MWhjzh²hubhý)�”}”(hŒ'There are several implications of this:”h]”hŒ'There are several implications of this:”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M_hjzh²hubj3)�”}”(hhh]”(j8)�”}”(hX<kfuncs that are widely used or have been in the kernel for a long time will be more difficult to justify being changed or removed by a maintainer. In other words, kfuncs that are known to have a lot of users and provide significant value provide stronger incentives for maintainers to invest the time and complexity in supporting them. It is therefore important for developers that are using kfuncs in their BPF programs to communicate and explain how and why those kfuncs are being used, and to participate in discussions regarding those kfuncs when they occur upstream. ”h]”hý)�”}”(hX;kfuncs that are widely used or have been in the kernel for a long time will be more difficult to justify being changed or removed by a maintainer. In other words, kfuncs that are known to have a lot of users and provide significant value provide stronger incentives for maintainers to invest the time and complexity in supporting them. It is therefore important for developers that are using kfuncs in their BPF programs to communicate and explain how and why those kfuncs are being used, and to participate in discussions regarding those kfuncs when they occur upstream.”h]”hX;kfuncs that are widely used or have been in the kernel for a long time will be more difficult to justify being changed or removed by a maintainer. In other words, kfuncs that are known to have a lot of users and provide significant value provide stronger incentives for maintainers to invest the time and complexity in supporting them. It is therefore important for developers that are using kfuncs in their BPF programs to communicate and explain how and why those kfuncs are being used, and to participate in discussions regarding those kfuncs when they occur upstream.”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mahj¸ubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjµh²hh³hÇh´Nubj8)�”}”(hXÏUnlike regular kernel symbols marked with EXPORT_SYMBOL_GPL, BPF programs that call kfuncs are generally not part of the kernel tree. This means that refactoring cannot typically change callers in-place when a kfunc changes, as is done for e.g. an upstreamed driver being updated in place when a kernel symbol is changed. Unlike with regular kernel symbols, this is expected behavior for BPF symbols, and out-of-tree BPF programs that use kfuncs should be considered relevant to discussions and decisions around modifying and removing those kfuncs. The BPF community will take an active role in participating in upstream discussions when necessary to ensure that the perspectives of such users are taken into account. ”h]”(hý)�”}”(hXAUnlike regular kernel symbols marked with EXPORT_SYMBOL_GPL, BPF programs that call kfuncs are generally not part of the kernel tree. This means that refactoring cannot typically change callers in-place when a kfunc changes, as is done for e.g. an upstreamed driver being updated in place when a kernel symbol is changed.”h]”hXAUnlike regular kernel symbols marked with EXPORT_SYMBOL_GPL, BPF programs that call kfuncs are generally not part of the kernel tree. This means that refactoring cannot typically change callers in-place when a kfunc changes, as is done for e.g. an upstreamed driver being updated in place when a kernel symbol is changed.”…”�”}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MjhjÐubhý)�”}”(hX‹Unlike with regular kernel symbols, this is expected behavior for BPF symbols, and out-of-tree BPF programs that use kfuncs should be considered relevant to discussions and decisions around modifying and removing those kfuncs. The BPF community will take an active role in participating in upstream discussions when necessary to ensure that the perspectives of such users are taken into account.”h]”hX‹Unlike with regular kernel symbols, this is expected behavior for BPF symbols, and out-of-tree BPF programs that use kfuncs should be considered relevant to discussions and decisions around modifying and removing those kfuncs. The BPF community will take an active role in participating in upstream discussions when necessary to ensure that the perspectives of such users are taken into account.”…”�”}”(hjâh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MphjÐubeh}”(h]”h ]”h"]”h$]”h&]”uh1j7hjµh²hh³hÇh´Nubj8)�”}”(hX•A kfunc will never have any hard stability guarantees. BPF APIs cannot and will not ever hard-block a change in the kernel purely for stability reasons. That being said, kfuncs are features that are meant to solve problems and provide value to users. The decision of whether to change or remove a kfunc is a multivariate technical decision that is made on a case-by-case basis, and which is informed by data points such as those mentioned above. It is expected that a kfunc being removed or changed with no warning will not be a common occurrence or take place without sound justification, but it is a possibility that must be accepted if one is to use kfuncs. ”h]”hý)�”}”(hX”A kfunc will never have any hard stability guarantees. BPF APIs cannot and will not ever hard-block a change in the kernel purely for stability reasons. That being said, kfuncs are features that are meant to solve problems and provide value to users. The decision of whether to change or remove a kfunc is a multivariate technical decision that is made on a case-by-case basis, and which is informed by data points such as those mentioned above. It is expected that a kfunc being removed or changed with no warning will not be a common occurrence or take place without sound justification, but it is a possibility that must be accepted if one is to use kfuncs.”h]”hX”A kfunc will never have any hard stability guarantees. BPF APIs cannot and will not ever hard-block a change in the kernel purely for stability reasons. That being said, kfuncs are features that are meant to solve problems and provide value to users. The decision of whether to change or remove a kfunc is a multivariate technical decision that is made on a case-by-case basis, and which is informed by data points such as those mentioned above. It is expected that a kfunc being removed or changed with no warning will not be a common occurrence or take place without sound justification, but it is a possibility that must be accepted if one is to use kfuncs.”…”�”}”(hjúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mwhjöubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjµh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jnŒ loweralpha”jphjqŒ)”uh1j2hjzh²hh³hÇh´Maubh×)�”}”(hhh]”(hÜ)�”}”(hŒ3.1 kfunc deprecation”h]”hŒ3.1 kfunc deprecation”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´Mƒubhý)�”}”(hXèAs described above, while sometimes a maintainer may find that a kfunc must be changed or removed immediately to accommodate some changes in their subsystem, usually kfuncs will be able to accommodate a longer and more measured deprecation process. For example, if a new kfunc comes along which provides superior functionality to an existing kfunc, the existing kfunc may be deprecated for some period of time to allow users to migrate their BPF programs to use the new one. Or, if a kfunc has no known users, a decision may be made to remove the kfunc (without providing an alternative API) after some deprecation period so as to provide users with a window to notify the kfunc maintainer if it turns out that the kfunc is actually being used.”h]”hXèAs described above, while sometimes a maintainer may find that a kfunc must be changed or removed immediately to accommodate some changes in their subsystem, usually kfuncs will be able to accommodate a longer and more measured deprecation process. For example, if a new kfunc comes along which provides superior functionality to an existing kfunc, the existing kfunc may be deprecated for some period of time to allow users to migrate their BPF programs to use the new one. Or, if a kfunc has no known users, a decision may be made to remove the kfunc (without providing an alternative API) after some deprecation period so as to provide users with a window to notify the kfunc maintainer if it turns out that the kfunc is actually being used.”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M…hjh²hubhý)�”}”(hX›It's expected that the common case will be that kfuncs will go through a deprecation period rather than being changed or removed without warning. As described in :ref:`KF_deprecated_flag`, the kfunc framework provides the KF_DEPRECATED flag to kfunc developers to signal to users that a kfunc has been deprecated. Once a kfunc has been marked with KF_DEPRECATED, the following procedure is followed for removal:”h]”(hŒ¤It’s expected that the common case will be that kfuncs will go through a deprecation period rather than being changed or removed without warning. As described in ”…”�”}”(hj5h²hh³Nh´Nubh)�”}”(hŒ:ref:`KF_deprecated_flag`”h]”j )�”}”(hj?h]”hŒKF_deprecated_flag”…”�”}”(hjAh²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hj=ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jKŒreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj)Œkf_deprecated_flag”uh1hh³hÇh´M�hj5ubhŒà, the kfunc framework provides the KF_DEPRECATED flag to kfunc developers to signal to users that a kfunc has been deprecated. Once a kfunc has been marked with KF_DEPRECATED, the following procedure is followed for removal:”…”�”}”(hj5h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M�hjh²hubj3)�”}”(hhh]”(j8)�”}”(hXHAny relevant information for deprecated kfuncs is documented in the kfunc's kernel docs. This documentation will typically include the kfunc's expected remaining lifespan, a recommendation for new functionality that can replace the usage of the deprecated function (or an explanation as to why no such replacement exists), etc. ”h]”hý)�”}”(hXGAny relevant information for deprecated kfuncs is documented in the kfunc's kernel docs. This documentation will typically include the kfunc's expected remaining lifespan, a recommendation for new functionality that can replace the usage of the deprecated function (or an explanation as to why no such replacement exists), etc.”h]”hXKAny relevant information for deprecated kfuncs is documented in the kfunc’s kernel docs. This documentation will typically include the kfunc’s expected remaining lifespan, a recommendation for new functionality that can replace the usage of the deprecated function (or an explanation as to why no such replacement exists), etc.”…”�”}”(hjnh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M—hjjubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjgh²hh³hÇh´Nubj8)�”}”(hX!The deprecated kfunc is kept in the kernel for some period of time after it was first marked as deprecated. This time period will be chosen on a case-by-case basis, and will typically depend on how widespread the use of the kfunc is, how long it has been in the kernel, and how hard it is to move to alternatives. This deprecation time period is "best effort", and as described :ref:`above`, circumstances may sometimes dictate that the kfunc be removed before the full intended deprecation period has elapsed. ”h]”hý)�”}”(hX The deprecated kfunc is kept in the kernel for some period of time after it was first marked as deprecated. This time period will be chosen on a case-by-case basis, and will typically depend on how widespread the use of the kfunc is, how long it has been in the kernel, and how hard it is to move to alternatives. This deprecation time period is "best effort", and as described :ref:`above`, circumstances may sometimes dictate that the kfunc be removed before the full intended deprecation period has elapsed.”h]”(hX~The deprecated kfunc is kept in the kernel for some period of time after it was first marked as deprecated. This time period will be chosen on a case-by-case basis, and will typically depend on how widespread the use of the kfunc is, how long it has been in the kernel, and how hard it is to move to alternatives. This deprecation time period is “best effortâ€�, and as described ”…”�”}”(hj†h²hh³Nh´Nubh)�”}”(hŒ.:ref:`above`”h]”j )�”}”(hj�h]”hŒabove”…”�”}”(hj’h²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjŽubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”jœŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj)Œ bpf_kfunc_lifecycle_expectations”uh1hh³hÇh´M�hj†ubhŒx, circumstances may sometimes dictate that the kfunc be removed before the full intended deprecation period has elapsed.”…”�”}”(hj†h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M�hj‚ubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjgh²hh³hÇh´Nubj8)�”}”(hŒˆAfter the deprecation period the kfunc will be removed. At this point, BPF programs calling the kfunc will be rejected by the verifier. ”h]”hý)�”}”(hŒ‡After the deprecation period the kfunc will be removed. At this point, BPF programs calling the kfunc will be rejected by the verifier.”h]”hŒ‡After the deprecation period the kfunc will be removed. At this point, BPF programs calling the kfunc will be rejected by the verifier.”…”�”}”(hjÂh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M¦hj¾ubah}”(h]”h ]”h"]”h$]”h&]”uh1j7hjgh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jnjojphjqjruh1j2hjh²hh³hÇh´M—ubeh}”(h]”Œkfunc-deprecation”ah ]”h"]”Œ3.1 kfunc deprecation”ah$]”h&]”uh1hÖhjzh²hh³hÇh´Mƒubeh}”(h]”(Œkfunc-lifecycle-expectations”jfeh ]”h"]”(Œ3. kfunc lifecycle expectations”Œ bpf_kfunc_lifecycle_expectations”eh$]”h&]”uh1hÖhhØh²hh³hÇh´MOj¥}”jêj\sj§}”jfj\subh×)�”}”(hhh]”(hÜ)�”}”(hŒ4. Core kfuncs”h]”hŒ4. Core kfuncs”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjïh²hh³hÇh´Mªubhý)�”}”(hŒ¶The BPF subsystem provides a number of "core" kfuncs that are potentially applicable to a wide variety of different possible use cases and programs. Those kfuncs are documented here.”h]”hŒºThe BPF subsystem provides a number of “coreâ€� kfuncs that are potentially applicable to a wide variety of different possible use cases and programs. Those kfuncs are documented here.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M¬hjïh²hubh×)�”}”(hhh]”(hÜ)�”}”(hŒ4.1 struct task_struct * kfuncs”h]”hŒ4.1 struct task_struct * kfuncs”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´M±ubhý)�”}”(hŒ]There are a number of kfuncs that allow ``struct task_struct *`` objects to be used as kptrs:”h]”(hŒ(There are a number of kfuncs that allow ”…”�”}”(hjh²hh³Nh´Nubjª)�”}”(hŒ``struct task_struct *``”h]”hŒstruct task_struct *”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjubhŒ objects to be used as kptrs:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M³hjh²hubhŒindex”“”)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(Œsingle”Œbpf_task_acquire (C function)”Œc.bpf_task_acquire”hNt”auh1j?hjh²hh³Nh´NubhŒdesc”“”)�”}”(hhh]”(hŒdesc_signature”“”)�”}”(hŒI__bpf_kfunc struct task_struct * bpf_task_acquire (struct task_struct *p)”h]”hŒdesc_signature_line”“”)�”}”(hŒG__bpf_kfunc struct task_struct *bpf_task_acquire(struct task_struct *p)”h]”(hŒ __bpf_kfunc”…”�”}”(hj]h²hh³Nh´NubhŒdesc_sig_space”“”)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjgh²hh³Nh´Nubah}”(h]”h ]”Œw”ah"]”h$]”h&]”uh1jehj]h²hh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M ubhŒdesc_sig_keyword”“”)�”}”(hŒstruct”h]”hŒstruct”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”Œk”ah"]”h$]”h&]”uh1jwhj]h²hh³jvh´M ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj]h²hh³jvh´M ubh)�”}”(hhh]”hŒ desc_sig_name”“”)�”}”(hŒ task_struct”h]”hŒ task_struct”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”Œn”ah"]”h$]”h&]”uh1j™hj–ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”Œ identifier”Œ reftarget”j�Œmodname”NŒ classname”NŒ c:parent_key”Œsphinx.domains.c”Œ LookupKey”“”)�”}”Œdata”]”j·Œ ASTIdentifier”“”)�”}”j²Œbpf_task_acquire”sbŒc.bpf_task_acquire”†”asbuh1hhj]h²hh³jvh´M ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj]h²hh³jvh´M ubhŒdesc_sig_punctuation”“”)�”}”(hj h]”hŒ*”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”Œp”ah"]”h$]”h&]”uh1jÓhj]h²hh³jvh´M ubhŒ desc_name”“”)�”}”(hŒbpf_task_acquire”h]”jš)�”}”(hjÂh]”hŒbpf_task_acquire”…”�”}”(hjéh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjåubah}”(h]”h ]”(Œsig-name”Œdescname”eh"]”h$]”h&]”hÅhÆuh1jãhj]h²hh³jvh´M ubhŒdesc_parameterlist”“”)�”}”(hŒ(struct task_struct *p)”h]”hŒdesc_parameter”“”)�”}”(hŒstruct task_struct *p”h]”(jx)�”}”(hj{h]”hŒstruct”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhjubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjubh)�”}”(hhh]”jš)�”}”(hŒ task_struct”h]”hŒ task_struct”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj%ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”j*Œmodname”NŒ classname”Nj¶j¹)�”}”j¼]”jÀŒc.bpf_task_acquire”†”asbuh1hhjubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhjubjš)�”}”(hjßh]”hŒp”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhjubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jþhj]h²hh³jvh´M ubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒ add_permalink”ˆuh1j[Œsphinx_line_type”Œ declarator”hjWh²hh³jvh´M ubah}”(h]”jNah ]”(Œsig”Œ sig-object”eh"]”h$]”h&]”Œ is_multiline”ˆŒ _toc_parts”)Œ _toc_name”huh1jUh³jvh´M hjRh²hubhŒ desc_content”“”)�”}”(hhh]”hý)�”}”(hŒ”Acquire a reference to a task. A task acquired by this kfunc which is not stored in a map as a kptr, must be released by calling bpf_task_release().”h]”hŒ”Acquire a reference to a task. A task acquired by this kfunc which is not stored in a map as a kptr, must be released by calling bpf_task_release().”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hj‘h²hubah}”(h]”h ]”h"]”h$]”h&]”uh1j�hjRh²hh³jvh´M ubeh}”(h]”h ]”(j+Œfunction”eh"]”h$]”h&]”Œdomain”j+Œobjtype”j¬Œdesctype”j¬Œnoindex”‰Œ noindexentry”‰Œnocontentsentry”‰uh1jPh²hhjh³Nh´NubhŒ container”“”)�”}”(hŒ\**Parameters** ``struct task_struct *p`` The task on which a reference is being acquired.”h]”(hý)�”}”(hŒ**Parameters**”h]”hŒstrong”“”)�”}”(hj¾h]”hŒ Parameters”…”�”}”(hjÂh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÀhj¼ubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hj¸ubhŒdefinition_list”“”)�”}”(hhh]”hŒdefinition_list_item”“”)�”}”(hŒJ``struct task_struct *p`` The task on which a reference is being acquired.”h]”(hŒterm”“”)�”}”(hŒ``struct task_struct *p``”h]”jª)�”}”(hjåh]”hŒstruct task_struct *p”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjãubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hjÝubhŒ definition”“”)�”}”(hhh]”hý)�”}”(hŒ0The task on which a reference is being acquired.”h]”hŒ0The task on which a reference is being acquired.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hjýubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjÝubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³júh´M hjØubah}”(h]”h ]”h"]”h$]”h&]”uh1jÖhj¸ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j¶hjh²hh³Nh´Nubj@)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(jLŒbpf_task_release (C function)”Œc.bpf_task_release”hNt”auh1j?hjh²hh³Nh´NubjQ)�”}”(hhh]”(jV)�”}”(hŒ9__bpf_kfunc void bpf_task_release (struct task_struct *p)”h]”j\)�”}”(hŒ8__bpf_kfunc void bpf_task_release(struct task_struct *p)”h]”(hŒ __bpf_kfunc”…”�”}”(hj=h²hh³Nh´Nubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjEh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj=h²hh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M ubhŒdesc_sig_keyword_type”“”)�”}”(hŒvoid”h]”hŒvoid”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”Œkt”ah"]”h$]”h&]”uh1jThj=h²hh³jSh´M ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj=h²hh³jSh´M ubjä)�”}”(hŒbpf_task_release”h]”jš)�”}”(hŒbpf_task_release”h]”hŒbpf_task_release”…”�”}”(hjwh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjsubah}”(h]”h ]”(jùjúeh"]”h$]”h&]”hÅhÆuh1jãhj=h²hh³jSh´M ubjÿ)�”}”(hŒ(struct task_struct *p)”h]”j)�”}”(hŒstruct task_struct *p”h]”(jx)�”}”(hj{h]”hŒstruct”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhj�ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj�ubh)�”}”(hhh]”jš)�”}”(hŒ task_struct”h]”hŒ task_struct”…”�”}”(hj±h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj®ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”j³Œmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¿)�”}”j²jysbŒc.bpf_task_release”†”asbuh1hhj�ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjÑh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj�ubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hjßh²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhj�ubjš)�”}”(hjßh]”hŒp”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj�ubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhj‹ubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jþhj=h²hh³jSh´M ubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆj�ˆuh1j[j‚jƒhj9h²hh³jSh´M ubah}”(h]”j4ah ]”(j‡jˆeh"]”h$]”h&]”jŒˆj�)jŽhuh1jUh³jSh´M hj6h²hubj�)�”}”(hhh]”hý)�”}”(hŒ)Release the reference acquired on a task.”h]”hŒ)Release the reference acquired on a task.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hjh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1j�hj6h²hh³jSh´M ubeh}”(h]”h ]”(j+Œfunction”eh"]”h$]”h&]”j°j+j±j-j²j-j³‰j´‰jµ‰uh1jPh²hhjh³Nh´Nubj·)�”}”(hŒ\**Parameters** ``struct task_struct *p`` The task on which a reference is being released.”h]”(hý)�”}”(hŒ**Parameters**”h]”jÁ)�”}”(hj7h]”hŒ Parameters”…”�”}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÀhj5ubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hj1ubj×)�”}”(hhh]”jÜ)�”}”(hŒJ``struct task_struct *p`` The task on which a reference is being released.”h]”(jâ)�”}”(hŒ``struct task_struct *p``”h]”jª)�”}”(hjVh]”hŒstruct task_struct *p”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjTubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hjPubjü)�”}”(hhh]”hý)�”}”(hŒ0The task on which a reference is being released.”h]”hŒ0The task on which a reference is being released.”…”�”}”(hjoh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:694: ./kernel/bpf/helpers.c”h´M hjlubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjPubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³jkh´M hjMubah}”(h]”h ]”h"]”h$]”h&]”uh1jÖhj1ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j¶hjh²hh³Nh´Nubhý)�”}”(hŒºThese kfuncs are useful when you want to acquire or release a reference to a ``struct task_struct *`` that was passed as e.g. a tracepoint arg, or a struct_ops callback arg. For example:”h]”(hŒMThese kfuncs are useful when you want to acquire or release a reference to a ”…”�”}”(hj—h²hh³Nh´Nubjª)�”}”(hŒ``struct task_struct *``”h]”hŒstruct task_struct *”…”�”}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj—ubhŒU that was passed as e.g. a tracepoint arg, or a struct_ops callback arg. For example:”…”�”}”(hj—h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M¹hjh²hubj¼)�”}”(hXˆ/** * A trivial example tracepoint program that shows how to * acquire and release a struct task_struct * pointer. */ SEC("tp_btf/task_newtask") int BPF_PROG(task_acquire_release_example, struct task_struct *task, u64 clone_flags) { struct task_struct *acquired; acquired = bpf_task_acquire(task); if (acquired) /* * In a typical program you'd do something like store * the task in a map, and the map will automatically * release it later. Here, we release it manually. */ bpf_task_release(acquired); return 0; }”h]”hXˆ/** * A trivial example tracepoint program that shows how to * acquire and release a struct task_struct * pointer. */ SEC("tp_btf/task_newtask") int BPF_PROG(task_acquire_release_example, struct task_struct *task, u64 clone_flags) { struct task_struct *acquired; acquired = bpf_task_acquire(task); if (acquired) /* * In a typical program you'd do something like store * the task in a map, and the map will automatically * release it later. Here, we release it manually. */ bpf_task_release(acquired); return 0; }”…”�”}”hj·sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´M½hjh²hubhý)�”}”(hŒÓReferences acquired on ``struct task_struct *`` objects are RCU protected. Therefore, when in an RCU read region, you can obtain a pointer to a task embedded in a map value without having to acquire a reference:”h]”(hŒReferences acquired on ”…”�”}”(hjÆh²hh³Nh´Nubjª)�”}”(hŒ``struct task_struct *``”h]”hŒstruct task_struct *”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÆubhŒ¤ objects are RCU protected. Therefore, when in an RCU read region, you can obtain a pointer to a task embedded in a map value without having to acquire a reference:”…”�”}”(hjÆh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MÔhjh²hubj¼)�”}”(hX¾#define private(name) SEC(".data." #name) __hidden __attribute__((aligned(8))) private(TASK) static struct task_struct *global; /** * A trivial example showing how to access a task stored * in a map using RCU. */ SEC("tp_btf/task_newtask") int BPF_PROG(task_rcu_read_example, struct task_struct *task, u64 clone_flags) { struct task_struct *local_copy; bpf_rcu_read_lock(); local_copy = global; if (local_copy) /* * We could also pass local_copy to kfuncs or helper functions here, * as we're guaranteed that local_copy will be valid until we exit * the RCU read region below. */ bpf_printk("Global task %s is valid", local_copy->comm); else bpf_printk("No global task found"); bpf_rcu_read_unlock(); /* At this point we can no longer reference local_copy. */ return 0; }”h]”hX¾#define private(name) SEC(".data." #name) __hidden __attribute__((aligned(8))) private(TASK) static struct task_struct *global; /** * A trivial example showing how to access a task stored * in a map using RCU. */ SEC("tp_btf/task_newtask") int BPF_PROG(task_rcu_read_example, struct task_struct *task, u64 clone_flags) { struct task_struct *local_copy; bpf_rcu_read_lock(); local_copy = global; if (local_copy) /* * We could also pass local_copy to kfuncs or helper functions here, * as we're guaranteed that local_copy will be valid until we exit * the RCU read region below. */ bpf_printk("Global task %s is valid", local_copy->comm); else bpf_printk("No global task found"); bpf_rcu_read_unlock(); /* At this point we can no longer reference local_copy. */ return 0; }”…”�”}”hjæsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´MØhjh²hubhŒ transition”“”)�”}”(hŒ----”h]”h}”(h]”h ]”h"]”h$]”h&]”uh1jõh³hÇh´Møhjh²hubhý)�”}”(hŒÒA BPF program can also look up a task from a pid. This can be useful if the caller doesn't have a trusted pointer to a ``struct task_struct *`` object that it can acquire a reference on with bpf_task_acquire().”h]”(hŒyA BPF program can also look up a task from a pid. This can be useful if the caller doesn’t have a trusted pointer to a ”…”�”}”(hjh²hh³Nh´Nubjª)�”}”(hŒ``struct task_struct *``”h]”hŒstruct task_struct *”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjubhŒC object that it can acquire a reference on with bpf_task_acquire().”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Múhjh²hubj@)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(jLŒbpf_task_from_pid (C function)”Œc.bpf_task_from_pid”hNt”auh1j?hjh²hh³Nh´NubjQ)�”}”(hhh]”(jV)�”}”(hŒ<__bpf_kfunc struct task_struct * bpf_task_from_pid (s32 pid)”h]”j\)�”}”(hŒ:__bpf_kfunc struct task_struct *bpf_task_from_pid(s32 pid)”h]”(hŒ __bpf_kfunc”…”�”}”(hj6h²hh³Nh´Nubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj>h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj6h²hh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:766: ./kernel/bpf/helpers.c”h´M¨ ubjx)�”}”(hj{h]”hŒstruct”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhj6h²hh³jLh´M¨ ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjZh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj6h²hh³jLh´M¨ ubh)�”}”(hhh]”jš)�”}”(hŒ task_struct”h]”hŒ task_struct”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjhubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”jmŒmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¿)�”}”j²Œbpf_task_from_pid”sbŒc.bpf_task_from_pid”†”asbuh1hhj6h²hh³jLh´M¨ ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj6h²hh³jLh´M¨ ubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hjšh²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhj6h²hh³jLh´M¨ ubjä)�”}”(hŒbpf_task_from_pid”h]”jš)�”}”(hj‰h]”hŒbpf_task_from_pid”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj§ubah}”(h]”h ]”(jùjúeh"]”h$]”h&]”hÅhÆuh1jãhj6h²hh³jLh´M¨ ubjÿ)�”}”(hŒ (s32 pid)”h]”j)�”}”(hŒs32 pid”h]”(h)�”}”(hhh]”jš)�”}”(hŒs32”h]”hŒs32”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjÆubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”jËŒmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j‡Œc.bpf_task_from_pid”†”asbuh1hhjÂubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjÂubjš)�”}”(hŒpid”h]”hŒpid”…”�”}”(hjõh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjÂubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhj¾ubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jþhj6h²hh³jLh´M¨ ubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆj�ˆuh1j[j‚jƒhj2h²hh³jLh´M¨ ubah}”(h]”j-ah ]”(j‡jˆeh"]”h$]”h&]”jŒˆj�)jŽhuh1jUh³jLh´M¨ hj/h²hubj�)�”}”(hhh]”hý)�”}”(hŒµFind a struct task_struct from its pid by looking it up in the root pid namespace idr. If a task is returned, it must either be stored in a map, or released with bpf_task_release().”h]”hŒµFind a struct task_struct from its pid by looking it up in the root pid namespace idr. If a task is returned, it must either be stored in a map, or released with bpf_task_release().”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:766: ./kernel/bpf/helpers.c”h´M¨ hjh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1j�hj/h²hh³jLh´M¨ ubeh}”(h]”h ]”(j+Œfunction”eh"]”h$]”h&]”j°j+j±j7j²j7j³‰j´‰jµ‰uh1jPh²hhjh³Nh´Nubj·)�”}”(hŒB**Parameters** ``s32 pid`` The pid of the task being looked up.”h]”(hý)�”}”(hŒ**Parameters**”h]”jÁ)�”}”(hjAh]”hŒ Parameters”…”�”}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÀhj?ubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:766: ./kernel/bpf/helpers.c”h´M¬ hj;ubj×)�”}”(hhh]”jÜ)�”}”(hŒ0``s32 pid`` The pid of the task being looked up.”h]”(jâ)�”}”(hŒ ``s32 pid``”h]”jª)�”}”(hj`h]”hŒs32 pid”…”�”}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj^ubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:766: ./kernel/bpf/helpers.c”h´M® hjZubjü)�”}”(hhh]”hý)�”}”(hŒ$The pid of the task being looked up.”h]”hŒ$The pid of the task being looked up.”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:766: ./kernel/bpf/helpers.c”h´M« hjvubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjZubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³juh´M® hjWubah}”(h]”h ]”h"]”h$]”h&]”uh1jÖhj;ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j¶hjh²hh³Nh´Nubhý)�”}”(hŒ$Here is an example of it being used:”h]”hŒ$Here is an example of it being used:”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Mhjh²hubj¼)�”}”(hX¤SEC("tp_btf/task_newtask") int BPF_PROG(task_get_pid_example, struct task_struct *task, u64 clone_flags) { struct task_struct *lookup; lookup = bpf_task_from_pid(task->pid); if (!lookup) /* A task should always be found, as %task is a tracepoint arg. */ return -ENOENT; if (lookup->pid != task->pid) { /* bpf_task_from_pid() looks up the task via its * globally-unique pid from the init_pid_ns. Thus, * the pid of the lookup task should always be the * same as the input task. */ bpf_task_release(lookup); return -EINVAL; } /* bpf_task_from_pid() returns an acquired reference, * so it must be dropped before returning from the * tracepoint handler. */ bpf_task_release(lookup); return 0; }”h]”hX¤SEC("tp_btf/task_newtask") int BPF_PROG(task_get_pid_example, struct task_struct *task, u64 clone_flags) { struct task_struct *lookup; lookup = bpf_task_from_pid(task->pid); if (!lookup) /* A task should always be found, as %task is a tracepoint arg. */ return -ENOENT; if (lookup->pid != task->pid) { /* bpf_task_from_pid() looks up the task via its * globally-unique pid from the init_pid_ns. Thus, * the pid of the lookup task should always be the * same as the input task. */ bpf_task_release(lookup); return -EINVAL; } /* bpf_task_from_pid() returns an acquired reference, * so it must be dropped before returning from the * tracepoint handler. */ bpf_task_release(lookup); return 0; }”…”�”}”hj¯sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´Mhjh²hubeh}”(h]”Œstruct-task-struct-kfuncs”ah ]”h"]”Œ4.1 struct task_struct * kfuncs”ah$]”h&]”uh1hÖhjïh²hh³hÇh´M±ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ4.2 struct cgroup * kfuncs”h]”hŒ4.2 struct cgroup * kfuncs”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÆh²hh³hÇh´M"ubhý)�”}”(hŒD``struct cgroup *`` objects also have acquire and release functions:”h]”(jª)�”}”(hŒ``struct cgroup *``”h]”hŒstruct cgroup *”…”�”}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj×ubhŒ1 objects also have acquire and release functions:”…”�”}”(hj×h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M$hjÆh²hubj@)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(jLŒbpf_cgroup_acquire (C function)”Œc.bpf_cgroup_acquire”hNt”auh1j?hjÆh²hh³Nh´NubjQ)�”}”(hhh]”(jV)�”}”(hŒD__bpf_kfunc struct cgroup * bpf_cgroup_acquire (struct cgroup *cgrp)”h]”j\)�”}”(hŒB__bpf_kfunc struct cgroup *bpf_cgroup_acquire(struct cgroup *cgrp)”h]”(hŒ __bpf_kfunc”…”�”}”(hjh²hh³Nh´Nubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjh²hh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M& ubjx)�”}”(hj{h]”hŒstruct”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhjh²hh³jh´M& ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj,h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjh²hh³jh´M& ubh)�”}”(hhh]”jš)�”}”(hŒcgroup”h]”hŒcgroup”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj:ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”j?Œmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¿)�”}”j²Œbpf_cgroup_acquire”sbŒc.bpf_cgroup_acquire”†”asbuh1hhjh²hh³jh´M& ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj^h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjh²hh³jh´M& ubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhjh²hh³jh´M& ubjä)�”}”(hŒbpf_cgroup_acquire”h]”jš)�”}”(hj[h]”hŒbpf_cgroup_acquire”…”�”}”(hj}h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjyubah}”(h]”h ]”(jùjúeh"]”h$]”h&]”hÅhÆuh1jãhjh²hh³jh´M& ubjÿ)�”}”(hŒ(struct cgroup *cgrp)”h]”j)�”}”(hŒstruct cgroup *cgrp”h]”(jx)�”}”(hj{h]”hŒstruct”…”�”}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhj”ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj”ubh)�”}”(hhh]”jš)�”}”(hŒcgroup”h]”hŒcgroup”…”�”}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj³ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”j¸Œmodname”NŒ classname”Nj¶j¹)�”}”j¼]”jYŒc.bpf_cgroup_acquire”†”asbuh1hhj”ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj”ubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hjâh²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhj”ubjš)�”}”(hŒcgrp”h]”hŒcgrp”…”�”}”(hjïh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj”ubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhj�ubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jþhjh²hh³jh´M& ubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆj�ˆuh1j[j‚jƒhjh²hh³jh´M& ubah}”(h]”jÿah ]”(j‡jˆeh"]”h$]”h&]”jŒˆj�)jŽhuh1jUh³jh´M& hjh²hubj�)�”}”(hhh]”hý)�”}”(hŒšAcquire a reference to a cgroup. A cgroup acquired by this kfunc which is not stored in a map as a kptr, must be released by calling bpf_cgroup_release().”h]”hŒšAcquire a reference to a cgroup. A cgroup acquired by this kfunc which is not stored in a map as a kptr, must be released by calling bpf_cgroup_release().”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M& hjh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1j�hjh²hh³jh´M& ubeh}”(h]”h ]”(j+Œfunction”eh"]”h$]”h&]”j°j+j±j1j²j1j³‰j´‰jµ‰uh1jPh²hhjÆh³Nh´Nubj·)�”}”(hŒ\**Parameters** ``struct cgroup *cgrp`` The cgroup on which a reference is being acquired.”h]”(hý)�”}”(hŒ**Parameters**”h]”jÁ)�”}”(hj;h]”hŒ Parameters”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÀhj9ubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M* hj5ubj×)�”}”(hhh]”jÜ)�”}”(hŒJ``struct cgroup *cgrp`` The cgroup on which a reference is being acquired.”h]”(jâ)�”}”(hŒ``struct cgroup *cgrp``”h]”jª)�”}”(hjZh]”hŒstruct cgroup *cgrp”…”�”}”(hj\h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjXubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M, hjTubjü)�”}”(hhh]”hý)�”}”(hŒ2The cgroup on which a reference is being acquired.”h]”hŒ2The cgroup on which a reference is being acquired.”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M) hjpubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjTubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³joh´M, hjQubah}”(h]”h ]”h"]”h$]”h&]”uh1jÖhj5ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j¶hjÆh²hh³Nh´Nubj@)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(jLŒbpf_cgroup_release (C function)”Œc.bpf_cgroup_release”hNt”auh1j?hjÆh²hh³Nh´NubjQ)�”}”(hhh]”(jV)�”}”(hŒ9__bpf_kfunc void bpf_cgroup_release (struct cgroup *cgrp)”h]”j\)�”}”(hŒ8__bpf_kfunc void bpf_cgroup_release(struct cgroup *cgrp)”h]”(hŒ __bpf_kfunc”…”�”}”(hj°h²hh³Nh´Nubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj¸h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj°h²hh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M1 ubjU)�”}”(hŒvoid”h]”hŒvoid”…”�”}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”jaah"]”h$]”h&]”uh1jThj°h²hh³jÆh´M1 ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj°h²hh³jÆh´M1 ubjä)�”}”(hŒbpf_cgroup_release”h]”jš)�”}”(hŒbpf_cgroup_release”h]”hŒbpf_cgroup_release”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjãubah}”(h]”h ]”(jùjúeh"]”h$]”h&]”hÅhÆuh1jãhj°h²hh³jÆh´M1 ubjÿ)�”}”(hŒ(struct cgroup *cgrp)”h]”j)�”}”(hŒstruct cgroup *cgrp”h]”(jx)�”}”(hj{h]”hŒstruct”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhjÿubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjÿubh)�”}”(hhh]”jš)�”}”(hŒcgroup”h]”hŒcgroup”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”j#Œmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¿)�”}”j²jésbŒc.bpf_cgroup_release”†”asbuh1hhjÿubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjAh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjÿubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hjOh²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhjÿubjš)�”}”(hŒcgrp”h]”hŒcgrp”…”�”}”(hj\h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjÿubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhjûubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jþhj°h²hh³jÆh´M1 ubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆj�ˆuh1j[j‚jƒhj¬h²hh³jÆh´M1 ubah}”(h]”j§ah ]”(j‡jˆeh"]”h$]”h&]”jŒˆj�)jŽhuh1jUh³jÆh´M1 hj©h²hubj�)�”}”(hhh]”hý)�”}”(hŒÏRelease the reference acquired on a cgroup. If this kfunc is invoked in an RCU read region, the cgroup is guaranteed to not be freed until the current grace period has ended, even if its refcount drops to 0.”h]”hŒÏRelease the reference acquired on a cgroup. If this kfunc is invoked in an RCU read region, the cgroup is guaranteed to not be freed until the current grace period has ended, even if its refcount drops to 0.”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M1 hjƒh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1j�hj©h²hh³jÆh´M1 ubeh}”(h]”h ]”(j+Œfunction”eh"]”h$]”h&]”j°j+j±jžj²jžj³‰j´‰jµ‰uh1jPh²hhjÆh³Nh´Nubj·)�”}”(hŒ\**Parameters** ``struct cgroup *cgrp`` The cgroup on which a reference is being released.”h]”(hý)�”}”(hŒ**Parameters**”h]”jÁ)�”}”(hj¨h]”hŒ Parameters”…”�”}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÀhj¦ubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M5 hj¢ubj×)�”}”(hhh]”jÜ)�”}”(hŒJ``struct cgroup *cgrp`` The cgroup on which a reference is being released.”h]”(jâ)�”}”(hŒ``struct cgroup *cgrp``”h]”jª)�”}”(hjÇh]”hŒstruct cgroup *cgrp”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÅubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M7 hjÁubjü)�”}”(hhh]”hý)�”}”(hŒ2The cgroup on which a reference is being released.”h]”hŒ2The cgroup on which a reference is being released.”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:806: ./kernel/bpf/helpers.c”h´M5 hjÝubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjÁubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³jÜh´M7 hj¾ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÖhj¢ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j¶hjÆh²hh³Nh´Nubhý)�”}”(hŒ’These kfuncs are used in exactly the same manner as bpf_task_acquire() and bpf_task_release() respectively, so we won't provide examples for them.”h]”hŒ”These kfuncs are used in exactly the same manner as bpf_task_acquire() and bpf_task_release() respectively, so we won’t provide examples for them.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M)hjÆh²hubjö)�”}”(hŒ----”h]”h}”(h]”h ]”h"]”h$]”h&]”uh1jõh³hÇh´M,hjÆh²hubhý)�”}”(hŒõOther kfuncs available for interacting with ``struct cgroup *`` objects are bpf_cgroup_ancestor() and bpf_cgroup_from_id(), allowing callers to access the ancestor of a cgroup and find a cgroup by its ID, respectively. Both return a cgroup kptr.”h]”(hŒ,Other kfuncs available for interacting with ”…”�”}”(hj h²hh³Nh´Nubjª)�”}”(hŒ``struct cgroup *``”h]”hŒstruct cgroup *”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj ubhŒ¶ objects are bpf_cgroup_ancestor() and bpf_cgroup_from_id(), allowing callers to access the ancestor of a cgroup and find a cgroup by its ID, respectively. Both return a cgroup kptr.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M.hjÆh²hubj@)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(jLŒ bpf_cgroup_ancestor (C function)”Œc.bpf_cgroup_ancestor”hNt”auh1j?hjÆh²hh³Nh´NubjQ)�”}”(hhh]”(jV)�”}”(hŒP__bpf_kfunc struct cgroup * bpf_cgroup_ancestor (struct cgroup *cgrp, int level)”h]”j\)�”}”(hŒN__bpf_kfunc struct cgroup *bpf_cgroup_ancestor(struct cgroup *cgrp, int level)”h]”(hŒ __bpf_kfunc”…”�”}”(hjUh²hh³Nh´Nubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjUh²hh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:819: ./kernel/bpf/helpers.c”h´MC ubjx)�”}”(hj{h]”hŒstruct”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhjUh²hh³jkh´MC ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjUh²hh³jkh´MC ubh)�”}”(hhh]”jš)�”}”(hŒcgroup”h]”hŒcgroup”…”�”}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj‡ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”jŒŒmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¿)�”}”j²Œbpf_cgroup_ancestor”sbŒc.bpf_cgroup_ancestor”†”asbuh1hhjUh²hh³jkh´MC ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjUh²hh³jkh´MC ubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhjUh²hh³jkh´MC ubjä)�”}”(hŒbpf_cgroup_ancestor”h]”jš)�”}”(hj¨h]”hŒbpf_cgroup_ancestor”…”�”}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjÆubah}”(h]”h ]”(jùjúeh"]”h$]”h&]”hÅhÆuh1jãhjUh²hh³jkh´MC ubjÿ)�”}”(hŒ (struct cgroup *cgrp, int level)”h]”(j)�”}”(hŒstruct cgroup *cgrp”h]”(jx)�”}”(hj{h]”hŒstruct”…”�”}”(hjåh²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhjáubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjáubh)�”}”(hhh]”jš)�”}”(hŒcgroup”h]”hŒcgroup”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”jŒmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¦Œc.bpf_cgroup_ancestor”†”asbuh1hhjáubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjáubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hj/h²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhjáubjš)�”}”(hŒcgrp”h]”hŒcgrp”…”�”}”(hj<h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjáubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhjÝubj)�”}”(hŒ int level”h]”(jU)�”}”(hŒint”h]”hŒint”…”�”}”(hjUh²hh³Nh´Nubah}”(h]”h ]”jaah"]”h$]”h&]”uh1jThjQubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjch²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjQubjš)�”}”(hŒlevel”h]”hŒlevel”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjQubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhjÝubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jþhjUh²hh³jkh´MC ubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆj�ˆuh1j[j‚jƒhjQh²hh³jkh´MC ubah}”(h]”jLah ]”(j‡jˆeh"]”h$]”h&]”jŒˆj�)jŽhuh1jUh³jkh´MC hjNh²hubj�)�”}”(hhh]”hý)�”}”(hŒ·Perform a lookup on an entry in a cgroup's ancestor array. A cgroup returned by this kfunc which is not subsequently stored in a map, must be released by calling bpf_cgroup_release().”h]”hŒ¹Perform a lookup on an entry in a cgroup’s ancestor array. A cgroup returned by this kfunc which is not subsequently stored in a map, must be released by calling bpf_cgroup_release().”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:819: ./kernel/bpf/helpers.c”h´MC hj˜h²hubah}”(h]”h ]”h"]”h$]”h&]”uh1j�hjNh²hh³jkh´MC ubeh}”(h]”h ]”(j+Œfunction”eh"]”h$]”h&]”j°j+j±j³j²j³j³‰j´‰jµ‰uh1jPh²hhjÆh³Nh´Nubj·)�”}”(hŒŒ**Parameters** ``struct cgroup *cgrp`` The cgroup for which we're performing a lookup. ``int level`` The level of ancestor to look up.”h]”(hý)�”}”(hŒ**Parameters**”h]”jÁ)�”}”(hj½h]”hŒ Parameters”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÀhj»ubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:819: ./kernel/bpf/helpers.c”h´MG hj·ubj×)�”}”(hhh]”(jÜ)�”}”(hŒH``struct cgroup *cgrp`` The cgroup for which we're performing a lookup. ”h]”(jâ)�”}”(hŒ``struct cgroup *cgrp``”h]”jª)�”}”(hjÜh]”hŒstruct cgroup *cgrp”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjÚubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:819: ./kernel/bpf/helpers.c”h´MF hjÖubjü)�”}”(hhh]”hý)�”}”(hŒ/The cgroup for which we're performing a lookup.”h]”hŒ1The cgroup for which we’re performing a lookup.”…”�”}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³jñh´MF hjòubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjÖubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³jñh´MF hjÓubjÜ)�”}”(hŒ/``int level`` The level of ancestor to look up.”h]”(jâ)�”}”(hŒ ``int level``”h]”jª)�”}”(hjh]”hŒ int level”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:819: ./kernel/bpf/helpers.c”h´MH hjubjü)�”}”(hhh]”hý)�”}”(hŒ!The level of ancestor to look up.”h]”hŒ!The level of ancestor to look up.”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:819: ./kernel/bpf/helpers.c”h´MG hj+ubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³j*h´MH hjÓubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÖhj·ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j¶hjÆh²hh³Nh´Nubj@)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(jLŒbpf_cgroup_from_id (C function)”Œc.bpf_cgroup_from_id”hNt”auh1j?hjÆh²hh³Nh´NubjQ)�”}”(hhh]”(jV)�”}”(hŒ9__bpf_kfunc struct cgroup * bpf_cgroup_from_id (u64 cgid)”h]”j\)�”}”(hŒ7__bpf_kfunc struct cgroup *bpf_cgroup_from_id(u64 cgid)”h]”(hŒ __bpf_kfunc”…”�”}”(hjkh²hh³Nh´Nubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjkh²hh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:822: ./kernel/bpf/helpers.c”h´MX ubjx)�”}”(hj{h]”hŒstruct”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”j„ah"]”h$]”h&]”uh1jwhjkh²hh³j�h´MX ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjkh²hh³j�h´MX ubh)�”}”(hhh]”jš)�”}”(hŒcgroup”h]”hŒcgroup”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj�ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”j¢Œmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¿)�”}”j²Œbpf_cgroup_from_id”sbŒc.bpf_cgroup_from_id”†”asbuh1hhjkh²hh³j�h´MX ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehjkh²hh³j�h´MX ubjÔ)�”}”(hj h]”hŒ*”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”jßah"]”h$]”h&]”uh1jÓhjkh²hh³j�h´MX ubjä)�”}”(hŒbpf_cgroup_from_id”h]”jš)�”}”(hj¾h]”hŒbpf_cgroup_from_id”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjÜubah}”(h]”h ]”(jùjúeh"]”h$]”h&]”hÅhÆuh1jãhjkh²hh³j�h´MX ubjÿ)�”}”(hŒ (u64 cgid)”h]”j)�”}”(hŒu64 cgid”h]”(h)�”}”(hhh]”jš)�”}”(hŒu64”h]”hŒu64”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hjûubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”j+Œreftype”j²Œ reftarget”jŒmodname”NŒ classname”Nj¶j¹)�”}”j¼]”j¼Œc.bpf_cgroup_from_id”†”asbuh1hhj÷ubjf)�”}”(hŒ ”h]”hŒ ”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”jrah"]”h$]”h&]”uh1jehj÷ubjš)�”}”(hŒcgid”h]”hŒcgid”…”�”}”(hj*h²hh³Nh´Nubah}”(h]”h ]”j¦ah"]”h$]”h&]”uh1j™hj÷ubeh}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆhÅhÆuh1jhjóubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jþhjkh²hh³j�h´MX ubeh}”(h]”h ]”h"]”h$]”h&]”hÅhÆj�ˆuh1j[j‚jƒhjgh²hh³j�h´MX ubah}”(h]”jbah ]”(j‡jˆeh"]”h$]”h&]”jŒˆj�)jŽhuh1jUh³j�h´MX hjdh²hubj�)�”}”(hhh]”hý)�”}”(hŒ—Find a cgroup from its ID. A cgroup returned by this kfunc which is not subsequently stored in a map, must be released by calling bpf_cgroup_release().”h]”hŒ—Find a cgroup from its ID. A cgroup returned by this kfunc which is not subsequently stored in a map, must be released by calling bpf_cgroup_release().”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:822: ./kernel/bpf/helpers.c”h´MX hjQh²hubah}”(h]”h ]”h"]”h$]”h&]”uh1j�hjdh²hh³j�h´MX ubeh}”(h]”h ]”(j+Œfunction”eh"]”h$]”h&]”j°j+j±jlj²jlj³‰j´‰jµ‰uh1jPh²hhjÆh³Nh´Nubj·)�”}”(hŒ)**Parameters** ``u64 cgid`` cgroup id.”h]”(hý)�”}”(hŒ**Parameters**”h]”jÁ)�”}”(hjvh]”hŒ Parameters”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÀhjtubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:822: ./kernel/bpf/helpers.c”h´M\ hjpubj×)�”}”(hhh]”jÜ)�”}”(hŒ``u64 cgid`` cgroup id.”h]”(jâ)�”}”(hŒ ``u64 cgid``”h]”jª)�”}”(hj•h]”hŒu64 cgid”…”�”}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j©hj“ubah}”(h]”h ]”h"]”h$]”h&]”uh1jáh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:822: ./kernel/bpf/helpers.c”h´M^ hj�ubjü)�”}”(hhh]”hý)�”}”(hŒ cgroup id.”h]”hŒ cgroup id.”…”�”}”(hj®h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³ŒP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:822: ./kernel/bpf/helpers.c”h´M[ hj«ubah}”(h•Ä]”h ]”h"]”h$]”h&]”uh1jûhj�ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³jªh´M^ hjŒubah}”(h]”h ]”h"]”h$]”h&]”uh1jÖhjpubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j¶hjÆh²hh³Nh´Nubhý)�”}”(hŒÚEventually, BPF should be updated to allow this to happen with a normal memory load in the program itself. This is currently not possible without more work in the verifier. bpf_cgroup_ancestor() can be used as follows:”h]”hŒÚEventually, BPF should be updated to allow this to happen with a normal memory load in the program itself. This is currently not possible without more work in the verifier. bpf_cgroup_ancestor() can be used as follows:”…”�”}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´M9hjÆh²hubj¼)�”}”(hX�/** * Simple tracepoint example that illustrates how a cgroup's * ancestor can be accessed using bpf_cgroup_ancestor(). */ SEC("tp_btf/cgroup_mkdir") int BPF_PROG(cgrp_ancestor_example, struct cgroup *cgrp, const char *path) { struct cgroup *parent; /* The parent cgroup resides at the level before the current cgroup's level. */ parent = bpf_cgroup_ancestor(cgrp, cgrp->level - 1); if (!parent) return -ENOENT; bpf_printk("Parent id is %d", parent->self.id); /* Return the parent cgroup that was acquired above. */ bpf_cgroup_release(parent); return 0; }”h]”hX�/** * Simple tracepoint example that illustrates how a cgroup's * ancestor can be accessed using bpf_cgroup_ancestor(). */ SEC("tp_btf/cgroup_mkdir") int BPF_PROG(cgrp_ancestor_example, struct cgroup *cgrp, const char *path) { struct cgroup *parent; /* The parent cgroup resides at the level before the current cgroup's level. */ parent = bpf_cgroup_ancestor(cgrp, cgrp->level - 1); if (!parent) return -ENOENT; bpf_printk("Parent id is %d", parent->self.id); /* Return the parent cgroup that was acquired above. */ bpf_cgroup_release(parent); return 0; }”…”�”}”hjäsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj)‰j*j+j,}”uh1j»h³hÇh´M=hjÆh²hubeh}”(h]”Œstruct-cgroup-kfuncs”ah ]”h"]”Œ4.2 struct cgroup * kfuncs”ah$]”h&]”uh1hÖhjïh²hh³hÇh´M"ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ4.3 struct cpumask * kfuncs”h]”hŒ4.3 struct cpumask * kfuncs”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjûh²hh³hÇh´MUubhý)�”}”(hŒ®BPF provides a set of kfuncs that can be used to query, allocate, mutate, and destroy struct cpumask * objects. Please refer to :ref:`cpumasks-header-label` for more details.”h]”(hŒ€BPF provides a set of kfuncs that can be used to query, allocate, mutate, and destroy struct cpumask * objects. Please refer to ”…”�”}”(hj h²hh³Nh´Nubh)�”}”(hŒ:ref:`cpumasks-header-label`”h]”j )�”}”(hjh]”hŒcpumasks-header-label”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”(jŒstd”Œstd-ref”eh"]”h$]”h&]”uh1j hjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”j#Œ refdomain”j"Œreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj)Œcpumasks-header-label”uh1hh³hÇh´MWhj ubhŒ for more details.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´MWhjûh²hubeh}”(h]”Œstruct-cpumask-kfuncs”ah ]”h"]”Œ4.3 struct cpumask * kfuncs”ah$]”h&]”uh1hÖhjïh²hh³hÇh´MUubeh}”(h]”Œ core-kfuncs”ah ]”h"]”Œ4. core kfuncs”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Mªubeh}”(h]”(Œbpf-kernel-functions-kfuncs”hÕeh ]”h"]”(Œbpf kernel functions (kfuncs)”Œkfuncs-header-label”eh$]”h&]”uh1hÖhhh²hh³hÇh´Kj¥}”jThÊsj§}”hÕhÊsubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hÛNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j|Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”(hÕ]”hÊajt]”jjaj± ]”j§ aj]”jø ajf]”j\auŒnameids”}”(jThÕjSjPj:j7jwjtjjÿjüjùj#j jfjcjÅjÂjjj‘jŽjjj¥j¢j„j�jzjwj¢jtj¡jžj[ jX j‚ j j© j¦ jÐ jÍ j÷ jô j j jE jB j· j´ j j± j j j° j­ j× jÔ j† jƒ jjjmjjljijêjfjéjæjájÞjKjHjÃjÀjøjõjCj@uŒ nametypes”}”(jTˆjS‰j:‰jw‰j‰jü‰j#‰jf‰jʼnj‰j‘‰j‰j¥‰j„‰jz‰j¢ˆj¡‰j[ ‰j‚ ‰j© ‰jÐ ‰j÷ ‰j ‰jE ‰j· ‰j ˆj ‰j° ‰j× ‰j† ‰j‰jmˆjl‰jêˆjé‰já‰jK‰jÉjø‰jC‰uh}”(hÕhØjPhØj7hëjtj=jÿjŽjùjj jÿjcj&jÂjijjÈjŽjjj”j¢jj�j¨jwj‡jtj}jžj}jX j©j j^ j¦ j… jÍ j¬ jô jÓ j jú jB j! j´ jH j± jº j jº j­ j jÔ j³ jƒ jÚ jj‰ jj jij jfjzjæjzjÞjjHjïjÀjjNjWj4j9j-j2jõjÆjÿjj§j¬jLjQjbjgj@jûuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”jŠKs…”R”Œparse_messages”]”Œtransform_messages”]”(hŒsystem_message”“”)�”}”(hhh]”hý)�”}”(hhh]”hŒ9Hyperlink target "kfuncs-header-label" is not referenced.”…”�”}”hjêsbah}”(h]”h ]”h"]”h$]”h&]”uh1hühjçubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”hÇŒline”Kuh1jåubjæ)�”}”(hhh]”hý)�”}”(hhh]”hŒ5Hyperlink target "bpf-kfunc-nodef" is not referenced.”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”uh1hühjubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”jÿŒsource”hÇŒline”M>uh1jåubjæ)�”}”(hhh]”hý)�”}”(hhh]”hŒ8Hyperlink target "kf-deprecated-flag" is not referenced.”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”uh1hühjubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”jÿŒsource”hÇŒline”M³uh1jåubjæ)�”}”(hhh]”hý)�”}”(hhh]”hŒ