Esphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget/translations/zh_CN/bpf/kfuncsmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/zh_TW/bpf/kfuncsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/it_IT/bpf/kfuncsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/ja_JP/bpf/kfuncsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/ko_KR/bpf/kfuncsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/sp_SP/bpf/kfuncsmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhh8/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs.rsthKubhtarget)}(h.. _kfuncs-header-label:h]h}(h]h ]h"]h$]h&]refidkfuncs-header-labeluh1hhKhhhhhhubhsection)}(hhh](htitle)}(hBPF Kernel Functions (kfuncs)h]hBPF Kernel Functions (kfuncs)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h1. Introductionh]h1. Introduction}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh paragraph)}(hXBPF 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 }(hhhhhNhNubh)}(h':ref:`BPF_kfunc_lifecycle_expectations`h]hinline)}(hhh]h BPF_kfunc_lifecycle_expectations}(hhhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1hhhubah}(h]h ]h"]h$]h&]refdoc bpf/kfuncs refdomainjreftyperef refexplicitrefwarn reftarget bpf_kfunc_lifecycle_expectationsuh1hhhhK hhubh for more information.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK hhhhubeh}(h] introductionah ]h"]1. introductionah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(h2. Defining a kfunch]h2. Defining a kfunc}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj)hhhhhKubh)}(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.}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj)hhubh)}(hiIf you are not creating a BPF wrapper for existing kernel function, skip ahead to :ref:`BPF_kfunc_nodef`.h](hRIf you are not creating a BPF wrapper for existing kernel function, skip ahead to }(hjHhhhNhNubh)}(h:ref:`BPF_kfunc_nodef`h]h)}(hjRh]hBPF_kfunc_nodef}(hjThhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1hhjPubah}(h]h ]h"]h$]h&]refdocj refdomainj^reftyperef refexplicitrefwarnjbpf_kfunc_nodefuh1hhhhKhjHubh.}(hjHhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj)hhubh)}(hhh](h)}(h2.1 Creating a wrapper kfunch]h2.1 Creating a wrapper kfunc}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjzhhhhhKubh)}(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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjzhhubh)}(hAn example is given below::h]hAn example is given below:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjzhhubh 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();}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhK'hjzhhubh)}(hA 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](hA 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 }(hjhhhNhNubh)}(h:ref:`BPF_kfunc_nodef`h]h)}(hjh]hBPF_kfunc_nodef}(hjhhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjbpf_kfunc_nodefuh1hhhhK1hjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK1hjzhhubeh}(h]creating-a-wrapper-kfuncah ]h"]2.1 creating a wrapper kfuncah$]h&]uh1hhj)hhhhhKubh)}(hhh](h)}(h2.2 Annotating kfunc parametersh]h2.2 Annotating kfunc parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK6ubh)}(hX2Similar to BPF helpers, there is sometime need for additional context required by the verifier to make the usage of kernel functions safer and more useful. Hence, we can annotate a parameter by suffixing the name of the argument of the kfunc with a __tag, where tag may be one of the supported annotations.h]hX2Similar to BPF helpers, there is sometime need for additional context required by the verifier to make the usage of kernel functions safer and more useful. Hence, we can annotate a parameter by suffixing the name of the argument of the kfunc with a __tag, where tag may be one of the supported annotations.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hjhhubeh}(h]annotating-kfunc-parametersah ]h"]2.2 annotating kfunc parametersah$]h&]uh1hhj)hhhhhK6ubh)}(hhh](h)}(h2.2.1 __sz Annotationh]h2.2.1 __sz Annotation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK>ubh)}(hlThis annotation is used to indicate a memory and size pair in the argument list. An example is given below::h]hkThis annotation is used to indicate a memory and size pair in the argument list. An example is given below:}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hjhhubj)}(h<__bpf_kfunc void bpf_memzero(void *mem, int mem__sz) { ... }h]h<__bpf_kfunc void bpf_memzero(void *mem, int mem__sz) { ... }}hj7sbah}(h]h ]h"]h$]h&]hhuh1jhhhKChjhhubh)}(hHere, the verifier will treat first argument as a PTR_TO_MEM, and second argument as its size. By default, without __sz annotation, the size of the type of the pointer is used. Without __sz annotation, a kfunc cannot accept a void pointer.h]hHere, the verifier will treat first argument as a PTR_TO_MEM, and second argument as its size. By default, without __sz annotation, the size of the type of the pointer is used. Without __sz annotation, a kfunc cannot accept a void pointer.}(hjEhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKHhjhhubeh}(h] sz-annotationah ]h"]2.2.1 __sz annotationah$]h&]uh1hhj)hhhhhK>ubh)}(hhh](h)}(h2.2.2 __k Annotationh]h2.2.2 __k Annotation}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj[hhhhhKNubh)}(hXThis annotation is only understood for scalar arguments, where it indicates that the verifier must check the scalar argument to be a known constant, which does not indicate a size parameter, and the value of the constant is relevant to the safety of the program.h]hXThis annotation is only understood for scalar arguments, where it indicates that the verifier must check the scalar argument to be a known constant, which does not indicate a size parameter, and the value of the constant is relevant to the safety of the program.}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKPhj[hhubh)}(hAn example is given below::h]hAn example is given below:}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKUhj[hhubj)}(h@__bpf_kfunc void *bpf_obj_new(u32 local_type_id__k, ...) { ... }h]h@__bpf_kfunc void *bpf_obj_new(u32 local_type_id__k, ...) { ... }}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKWhj[hhubh)}(hX#Here, bpf_obj_new uses local_type_id argument to find out the size of that type ID in program's BTF and return a sized pointer to it. Each type ID will have a distinct size, hence it is crucial to treat each such call as distinct when values don't match during verifier state pruning checks.h]hX'Here, bpf_obj_new uses local_type_id argument to find out the size of that type ID in program’s BTF and return a sized pointer to it. Each type ID will have a distinct size, hence it is crucial to treat each such call as distinct when values don’t match during verifier state pruning checks.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hj[hhubh)}(hHence, whenever a constant scalar argument is accepted by a kfunc which is not a size parameter, and the value of the constant matters for program safety, __k suffix should be used.h]hHence, whenever a constant scalar argument is accepted by a kfunc which is not a size parameter, and the value of the constant matters for program safety, __k suffix should be used.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahj[hhubeh}(h] k-annotationah ]h"]2.2.2 __k annotationah$]h&]uh1hhj)hhhhhKNubh)}(hhh](h)}(h2.2.3 __uninit Annotationh]h2.2.3 __uninit Annotation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKfubh)}(hWThis annotation is used to indicate that the argument will be treated as uninitialized.h]hWThis annotation is used to indicate that the argument will be treated as uninitialized.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhjhhubh)}(hAn example is given below::h]hAn example is given below:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhjhhubj)}(hU__bpf_kfunc int bpf_dynptr_from_skb(..., struct bpf_dynptr_kern *ptr__uninit) { ... }h]hU__bpf_kfunc int bpf_dynptr_from_skb(..., struct bpf_dynptr_kern *ptr__uninit) { ... }}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKmhjhhubh)}(hHere, the dynptr will be treated as an uninitialized dynptr. Without this annotation, the verifier will reject the program if the dynptr passed in is not initialized.h]hHere, the dynptr will be treated as an uninitialized dynptr. Without this annotation, the verifier will reject the program if the dynptr passed in is not initialized.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKrhjhhubeh}(h]uninit-annotationah ]h"]2.2.3 __uninit annotationah$]h&]uh1hhj)hhhhhKfubh)}(hhh](h)}(h2.2.4 __opt Annotationh]h2.2.4 __opt Annotation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhKwubh)}(hX;This annotation is used to indicate that the buffer associated with an __sz or __szk argument may be null. If the function is passed a nullptr in place of the buffer, the verifier will not check that length is appropriate for the buffer. The kfunc is responsible for checking if this buffer is null before using it.h]hX;This annotation is used to indicate that the buffer associated with an __sz or __szk argument may be null. If the function is passed a nullptr in place of the buffer, the verifier will not check that length is appropriate for the buffer. The kfunc is responsible for checking if this buffer is null before using it.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhj hhubh)}(hAn example is given below::h]hAn example is given below:}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK~hj hhubj)}(hS__bpf_kfunc void *bpf_dynptr_slice(..., void *buffer__opt, u32 buffer__szk) { ... }h]hS__bpf_kfunc void *bpf_dynptr_slice(..., void *buffer__opt, u32 buffer__szk) { ... }}hj8sbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj hhubh)}(hX Here, the buffer may be null. If buffer is not null, it at least of size buffer_szk. Either way, the returned buffer is either NULL, or of size buffer_szk. Without this annotation, the verifier will reject the program if a null pointer is passed in with a nonzero size.h]hX Here, the buffer may be null. If buffer is not null, it at least of size buffer_szk. Either way, the returned buffer is either NULL, or of size buffer_szk. Without this annotation, the verifier will reject the program if a null pointer is passed in with a nonzero size.}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubeh}(h]opt-annotationah ]h"]2.2.4 __opt annotationah$]h&]uh1hhj)hhhhhKwubh)}(hhh](h)}(h2.2.5 __str Annotationh]h2.2.5 __str Annotation}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj\hhhhhKubh)}(hKThis annotation is used to indicate that the argument is a constant string.h]hKThis annotation is used to indicate that the argument is a constant string.}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj\hhubh)}(hAn example is given below::h]hAn example is given below:}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj\hhubj)}(hG__bpf_kfunc bpf_get_file_xattr(..., const char *name__str, ...) { ... }h]hG__bpf_kfunc bpf_get_file_xattr(..., const char *name__str, ...) { ... }}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj\hhubh)}(h9In this case, ``bpf_get_file_xattr()`` can be called as::h](hIn this case, }(hjhhhNhNubhliteral)}(h``bpf_get_file_xattr()``h]hbpf_get_file_xattr()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh can be called as:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj\hhubj)}(h+bpf_get_file_xattr(..., "xattr_name", ...);h]h+bpf_get_file_xattr(..., "xattr_name", ...);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj\hhubh)}(hOr::h]hOr:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj\hhubj)}(hconst char name[] = "xattr_name"; /* This need to be global */ int BPF_PROG(...) { ... bpf_get_file_xattr(..., name, ...); ... }h]hconst char name[] = "xattr_name"; /* This need to be global */ int BPF_PROG(...) { ... bpf_get_file_xattr(..., name, ...); ... }}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj\hhubeh}(h]str-annotationah ]h"]2.2.5 __str annotationah$]h&]uh1hhj)hhhhhKubh)}(hhh](h)}(h2.2.6 __prog Annotationh]h2.2.6 __prog Annotation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hThis annotation is used to indicate that the argument needs to be fixed up to the bpf_prog_aux of the caller BPF program. Any value passed into this argument is ignored, and rewritten by the verifier.h]hThis annotation is used to indicate that the argument needs to be fixed up to the bpf_prog_aux of the caller BPF program. Any value passed into this argument is ignored, and rewritten by the verifier.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hAn example is given below::h]hAn example is given below:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hXP__bpf_kfunc int bpf_wq_set_callback_impl(struct bpf_wq *wq, int (callback_fn)(void *map, int *key, void *value), unsigned int flags, void *aux__prog) { struct bpf_prog_aux *aux = aux__prog; ... }h]hXP__bpf_kfunc int bpf_wq_set_callback_impl(struct bpf_wq *wq, int (callback_fn)(void *map, int *key, void *value), unsigned int flags, void *aux__prog) { struct bpf_prog_aux *aux = aux__prog; ... }}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubh)}(h.. _BPF_kfunc_nodef:h]h}(h]h ]h"]h$]h&]hbpf-kfunc-nodefuh1hhKhjhhhhubeh}(h]prog-annotationah ]h"]2.2.6 __prog annotationah$]h&]uh1hhj)hhhhhKubh)}(hhh](h)}(h%2.3 Using an existing kernel functionh]h%2.3 Using an existing kernel function}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj9hhhhhKubh)}(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.}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj9hhubeh}(h](!using-an-existing-kernel-functionj0eh ]h"](%2.3 using an existing kernel functionbpf_kfunc_nodefeh$]h&]uh1hhj)hhhhhKexpect_referenced_by_name}j^j&sexpect_referenced_by_id}j0j&subh)}(hhh](h)}(h2.4 Annotating kfuncsh]h2.4 Annotating kfuncs}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjehhhhhKubh)}(hIn 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]hIn 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:}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjehhubj)}(hBTF_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]hBTF_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)}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjehhubh)}(hThis set encodes the BTF ID of each kfunc listed above, and encodes the flags along with it. Ofcourse, it is also allowed to specify no flags.h]hThis set encodes the BTF ID of each kfunc listed above, and encodes the flags along with it. Ofcourse, it is also allowed to specify no flags.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjehhubh)}(hX0kfunc definitions should also always be annotated with the ``__bpf_kfunc`` macro. This prevents issues such as the compiler inlining the kfunc if it's a static kernel function, 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 }(hjhhhNhNubj)}(h``__bpf_kfunc``h]h __bpf_kfunc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhX macro. This prevents issues such as the compiler inlining the kfunc if it’s a static kernel function, 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:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjehhubj)}(hA__bpf_kfunc struct task_struct *bpf_get_task_pid(s32 pid) { ... }h]hA__bpf_kfunc struct task_struct *bpf_get_task_pid(s32 pid) { ... }}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjehhubeh}(h]annotating-kfuncsah ]h"]2.4 annotating kfuncsah$]h&]uh1hhj)hhhhhKubh)}(hhh](h)}(h2.4.1 KF_ACQUIRE flagh]h2.4.1 KF_ACQUIRE flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXThe 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]hXThe 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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]kf-acquire-flagah ]h"]2.4.1 kf_acquire flagah$]h&]uh1hhj)hhhhhKubh)}(hhh](h)}(h2.4.2 KF_RET_NULL flagh]h2.4.2 KF_RET_NULL flag}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]kf-ret-null-flagah ]h"]2.4.2 kf_ret_null flagah$]h&]uh1hhj)hhhhhKubh)}(hhh](h)}(h2.4.3 KF_RELEASE flagh]h2.4.3 KF_RELEASE flag}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj$hhhhhKubh)}(hXpThe 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. KF_RELEASE kfuncs automatically receive the protection afforded by the KF_TRUSTED_ARGS flag described below.h]hXpThe 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. KF_RELEASE kfuncs automatically receive the protection afforded by the KF_TRUSTED_ARGS flag described below.}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$hhubeh}(h]kf-release-flagah ]h"]2.4.3 kf_release flagah$]h&]uh1hhj)hhhhhKubh)}(hhh](h)}(h2.4.4 KF_TRUSTED_ARGS flagh]h2.4.4 KF_TRUSTED_ARGS flag}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjKhhhhhKubh)}(hXKThe KF_TRUSTED_ARGS flag is used for kfuncs taking pointer arguments. It indicates that the all pointer arguments are valid, and that all pointers to BTF objects have been passed in their unmodified form (that is, at a zero offset, and without having been obtained from walking another pointer, with one exception described below).h]hXKThe KF_TRUSTED_ARGS flag is used for kfuncs taking pointer arguments. It indicates that the all pointer arguments are valid, and that all pointers to BTF objects have been passed in their unmodified form (that is, at a zero offset, and without having been obtained from walking another pointer, with one exception described below).}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjKhhubh)}(hOThere are two types of pointers to kernel objects which are considered "valid":h]hSThere are two types of pointers to kernel objects which are considered “valid”:}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjKhhubhenumerated_list)}(hhh](h list_item)}(hIPointers which are passed as tracepoint or struct_ops callback arguments.h]h)}(hjh]hIPointers which are passed as tracepoint or struct_ops callback arguments.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j}hjzhhhhhNubj~)}(h6Pointers which were returned from a KF_ACQUIRE kfunc. h]h)}(h5Pointers which were returned from a KF_ACQUIRE kfunc.h]h5Pointers which were returned from a KF_ACQUIRE kfunc.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j}hjzhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jxhjKhhhhhMubh)}(hPointers to non-BTF objects (e.g. scalar pointers) may also be passed to KF_TRUSTED_ARGS kfuncs, and may have a non-zero offset.h]hPointers to non-BTF objects (e.g. scalar pointers) may also be passed to KF_TRUSTED_ARGS kfuncs, and may have a non-zero offset.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjKhhubh)}(htThe definition of "valid" pointers is subject to change at any time, and has absolutely no ABI stability guarantees.h]hxThe definition of “valid” pointers is subject to change at any time, and has absolutely no ABI stability guarantees.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjKhhubh)}(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:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjKhhubh bullet_list)}(hhh](j~)}(h``BTF_TYPE_SAFE_TRUSTED``h]h)}(hjh]j)}(hjh]hBTF_TYPE_SAFE_TRUSTED}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j}hjhhhhhNubj~)}(h``BTF_TYPE_SAFE_RCU``h]h)}(hj h]j)}(hj h]hBTF_TYPE_SAFE_RCU}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j}hjhhhhhNubj~)}(h``BTF_TYPE_SAFE_RCU_OR_NULL`` h]h)}(h``BTF_TYPE_SAFE_RCU_OR_NULL``h]j)}(hj.h]hBTF_TYPE_SAFE_RCU_OR_NULL}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj,ubah}(h]h ]h"]h$]h&]uh1hhhhMhj(ubah}(h]h ]h"]h$]h&]uh1j}hjhhhhhNubeh}(h]h ]h"]h$]h&]bullet*uh1jhhhMhjKhhubh)}(h For example,h]h For example,}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjKhhubj)}(hBBTF_TYPE_SAFE_TRUSTED(struct socket) { struct sock *sk; };h]hBBTF_TYPE_SAFE_TRUSTED(struct socket) { struct sock *sk; };}hj_sbah}(h]h ]h"]h$]h&]hhforcelanguagechighlight_args}uh1jhhhMhjKhhubh)}(horh]hor}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjKhhubj)}(hBTF_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]hBTF_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; };}hjsbah}(h]h ]h"]h$]h&]hhjmjnjojp}uh1jhhhMhjKhhubh)}(hIn other words, you must:h]hIn other words, you must:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM(hjKhhubjy)}(hhh](j~)}(h 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.}(hjV hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjE hhubh)}(hXLike 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]hXLike 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.}(hjd hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjE hhubh)}(h'There are several implications of this:h]h'There are several implications of this:}(hjr hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjE hhubjy)}(hhh](j~)}(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 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j}hj hhhhhNubj~)}(hXUnlike 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 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hXUnlike 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]hXUnlike 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 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1j}hj hhhhhNubj~)}(hXA 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)}(hXA 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]hXA 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 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j}hj hhhhhNubeh}(h]h ]h"]h$]h&]j loweralphajhj)uh1jxhjE hhhhhMubh)}(hhh](h)}(h3.1 kfunc deprecationh]h3.1 kfunc deprecation}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hXAs 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]hXAs 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 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hXIt'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](hIt’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 }(hj hhhNhNubh)}(h:ref:`KF_deprecated_flag`h]h)}(hj h]hKF_deprecated_flag}(hj hhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]refdocj refdomainj reftyperef refexplicitrefwarnjkf_deprecated_flaguh1hhhhMhj ubh, 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:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubjy)}(hhh](j~)}(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.}(hj9 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj5 ubah}(h]h ]h"]h$]h&]uh1j}hj2 hhhhhNubj~)}(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.qh](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 }(hjQ hhhNhNubh)}(h.:ref:`above`h]h)}(hj[ h]habove}(hj] hhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1hhjY ubah}(h]h ]h"]h$]h&]refdocj refdomainjg reftyperef refexplicitrefwarnj bpf_kfunc_lifecycle_expectationsuh1hhhhM hjQ ubhx, circumstances may sometimes dictate that the kfunc be removed before the full intended deprecation period has elapsed.}(hjQ hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hjM ubah}(h]h ]h"]h$]h&]uh1j}hj2 hhhhhNubj~)}(hAfter the deprecation period the kfunc will be removed. At this point, BPF programs calling the kfunc will be rejected by the verifier. h]h)}(hAfter the deprecation period the kfunc will be removed. At this point, BPF programs calling the kfunc will be rejected by the verifier.h]hAfter the deprecation period the kfunc will be removed. At this point, BPF programs calling the kfunc will be rejected by the verifier.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j}hj2 hhhhhNubeh}(h]h ]h"]h$]h&]jjjhjjuh1jxhj hhhhhMubeh}(h]kfunc-deprecationah ]h"]3.1 kfunc deprecationah$]h&]uh1hhjE hhhhhMubeh}(h](kfunc-lifecycle-expectationsj4 eh ]h"](3. kfunc lifecycle expectations bpf_kfunc_lifecycle_expectationseh$]h&]uh1hhhhhhhhMja}j j* sjc}j4 j* subh)}(hhh](h)}(h4. Core kfuncsh]h4. Core kfuncs}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hThe 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]hThe 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.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hhh](h)}(h4.1 struct task_struct * kfuncsh]h4.1 struct task_struct * kfuncs}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM 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 }(hj hhhNhNubj)}(h``struct task_struct *``h]hstruct task_struct *}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh objects to be used as kptrs:}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM"hj hhubhindex)}(hhh]h}(h]h ]h"]h$]h&]entries](singlebpf_task_acquire (C function)c.bpf_task_acquirehNtauh1j hj hhhNhNubhdesc)}(hhh](hdesc_signature)}(hI__bpf_kfunc struct task_struct * bpf_task_acquire (struct task_struct *p)h]hdesc_signature_line)}(hG__bpf_kfunc struct task_struct *bpf_task_acquire(struct task_struct *p)h](h __bpf_kfunc}(hj( hhhNhNubhdesc_sig_space)}(h h]h }(hj2 hhhNhNubah}(h]h ]wah"]h$]h&]uh1j0 hj( hhhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM ubhdesc_sig_keyword)}(hstructh]hstruct}(hjD hhhNhNubah}(h]h ]kah"]h$]h&]uh1jB hj( hhhjA hM ubj1 )}(h h]h }(hjS hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj( hhhjA hM ubh)}(hhh]h desc_sig_name)}(h task_structh]h task_struct}(hjf hhhNhNubah}(h]h ]nah"]h$]h&]uh1jd hja ubah}(h]h ]h"]h$]h&] refdomainjoreftype identifier reftargetjh modnameN classnameN c:parent_keysphinx.domains.c LookupKey)}data]j ASTIdentifier)}j} bpf_task_acquiresbc.bpf_task_acquireasbuh1hhj( hhhjA hM ubj1 )}(h h]h }(hj hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj( hhhjA hM ubhdesc_sig_punctuation)}(hjPh]h*}(hj hhhNhNubah}(h]h ]pah"]h$]h&]uh1j hj( hhhjA hM ubh desc_name)}(hbpf_task_acquireh]je )}(hj h]hbpf_task_acquire}(hj hhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hj ubah}(h]h ](sig-namedescnameeh"]h$]h&]hhuh1j hj( hhhjA hM ubhdesc_parameterlist)}(h(struct task_struct *p)h]hdesc_parameter)}(hstruct task_struct *ph](jC )}(hjF h]hstruct}(hj hhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hj ubj1 )}(h h]h }(hj hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj ubh)}(hhh]je )}(h task_structh]h task_struct}(hj hhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hj ubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetj modnameN classnameNj j )}j ]j c.bpf_task_acquireasbuh1hhj ubj1 )}(h h]h }(hj hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj ubj )}(hjPh]h*}(hj hhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hj ubje )}(hj h]hp}(hj, hhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hj ubeh}(h]h ]h"]h$]h&]noemphhhuh1j hj ubah}(h]h ]h"]h$]h&]hhuh1j hj( hhhjA hM ubeh}(h]h ]h"]h$]h&]hh add_permalinkuh1j& sphinx_line_type declaratorhj" hhhjA hM ubah}(h]j ah ](sig sig-objecteh"]h$]h&] is_multiline _toc_parts) _toc_namehuh1j hjA hM hj hhubh desc_content)}(hhh]h)}(hAcquire 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]hAcquire 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_ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hj\ hhubah}(h]h ]h"]h$]h&]uh1jZ hj hhhjA hM ubeh}(h]h ](jofunctioneh"]h$]h&]domainjoobjtypejw desctypejw noindex noindexentrynocontentsentryuh1j hhhj hNhNubh container)}(h\**Parameters** ``struct task_struct *p`` The task on which a reference is being acquired.h](h)}(h**Parameters**h]hstrong)}(hj h]h Parameters}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j hj ubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hj ubhdefinition_list)}(hhh]hdefinition_list_item)}(hJ``struct task_struct *p`` The task on which a reference is being acquired.h](hterm)}(h``struct task_struct *p``h]j)}(hj h]hstruct task_struct *p}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hj ubh definition)}(hhh]h)}(h0The task on which a reference is being acquired.h]h0The task on which a reference is being acquired.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hj ubah}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ]h"]h$]h&]uh1j hj hM hj ubah}(h]h ]h"]h$]h&]uh1j hj ubeh}(h]h ] kernelindentah"]h$]h&]uh1j hj hhhNhNubj )}(hhh]h}(h]h ]h"]h$]h&]entries](j bpf_task_release (C function)c.bpf_task_releasehNtauh1j hj hhhNhNubj )}(hhh](j! )}(h9__bpf_kfunc void bpf_task_release (struct task_struct *p)h]j' )}(h8__bpf_kfunc void bpf_task_release(struct task_struct *p)h](h __bpf_kfunc}(hjhhhNhNubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM ubhdesc_sig_keyword_type)}(hvoidh]hvoid}(hj!hhhNhNubah}(h]h ]ktah"]h$]h&]uh1jhjhhhjhM ubj1 )}(h h]h }(hj0hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhjhM ubj )}(hbpf_task_releaseh]je )}(hbpf_task_releaseh]hbpf_task_release}(hjBhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hj>ubah}(h]h ](j j eh"]h$]h&]hhuh1j hjhhhjhM ubj )}(h(struct task_struct *p)h]j )}(hstruct task_struct *ph](jC )}(hjF h]hstruct}(hj^hhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hjZubj1 )}(h h]h }(hjkhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjZubh)}(hhh]je )}(h task_structh]h task_struct}(hj|hhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjyubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetj~modnameN classnameNj j )}j ]j )}j} jDsbc.bpf_task_releaseasbuh1hhjZubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjZubj )}(hjPh]h*}(hjhhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hjZubje )}(hj h]hp}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjZubeh}(h]h ]h"]h$]h&]noemphhhuh1j hjVubah}(h]h ]h"]h$]h&]hhuh1j hjhhhjhM ubeh}(h]h ]h"]h$]h&]hhjL uh1j& jM jN hjhhhjhM ubah}(h]j ah ](jR jS eh"]h$]h&]jW jX )jY huh1j hjhM hjhhubj[ )}(hhh]h)}(h)Release the reference acquired on a task.h]h)Release the reference acquired on a task.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hjhhubah}(h]h ]h"]h$]h&]uh1jZ hjhhhjhM ubeh}(h]h ](jofunctioneh"]h$]h&]j{ joj| jj} jj~ j j uh1j hhhj hNhNubj )}(h\**Parameters** ``struct task_struct *p`` The task on which a reference is being released.h](h)}(h**Parameters**h]j )}(hjh]h Parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hjubj )}(hhh]j )}(hJ``struct task_struct *p`` The task on which a reference is being released.h](j )}(h``struct task_struct *p``h]j)}(hj!h]hstruct task_struct *p}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hjubj )}(hhh]h)}(h0The task on which a reference is being released.h]h0The task on which a reference is being released.}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:549: ./kernel/bpf/helpers.chM hj7ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1j hj6hM hjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ] kernelindentah"]h$]h&]uh1j hj hhhNhNubh)}(hThese 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](hMThese kfuncs are useful when you want to acquire or release a reference to a }(hjbhhhNhNubj)}(h``struct task_struct *``h]hstruct task_struct *}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjbubhU that was passed as e.g. a tracepoint arg, or a struct_ops callback arg. For example:}(hjbhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM(hj hhubj)}(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; }}hjsbah}(h]h ]h"]h$]h&]hhjmjnjojp}uh1jhhhM,hj hhubh)}(hReferences 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](hReferences acquired on }(hjhhhNhNubj)}(h``struct task_struct *``h]hstruct task_struct *}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh 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:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMChj hhubj)}(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; }}hjsbah}(h]h ]h"]h$]h&]hhjmjnjojp}uh1jhhhMGhj hhubh transition)}(h----h]h}(h]h ]h"]h$]h&]uh1jhhhMghj hhubh)}(hA 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](hyA 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 }(hjhhhNhNubj)}(h``struct task_struct *``h]hstruct task_struct *}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhC object that it can acquire a reference on with bpf_task_acquire().}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMihj hhubj )}(hhh]h}(h]h ]h"]h$]h&]entries](j bpf_task_from_pid (C function)c.bpf_task_from_pidhNtauh1j hj hhhNhNubj )}(hhh](j! )}(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}(hjhhhNhNubj1 )}(h h]h }(hj hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:621: ./kernel/bpf/helpers.chM> ubjC )}(hjF h]hstruct}(hjhhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hjhhhjhM> ubj1 )}(h h]h }(hj%hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhjhM> ubh)}(hhh]je )}(h task_structh]h task_struct}(hj6hhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hj3ubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetj8modnameN classnameNj j )}j ]j )}j} bpf_task_from_pidsbc.bpf_task_from_pidasbuh1hhjhhhjhM> ubj1 )}(h h]h }(hjWhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhjhM> ubj )}(hjPh]h*}(hjehhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hjhhhjhM> ubj )}(hbpf_task_from_pidh]je )}(hjTh]hbpf_task_from_pid}(hjvhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjrubah}(h]h ](j j eh"]h$]h&]hhuh1j hjhhhjhM> ubj )}(h (s32 pid)h]j )}(hs32 pidh](h)}(hhh]je )}(hs32h]hs32}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetjmodnameN classnameNj j )}j ]jRc.bpf_task_from_pidasbuh1hhjubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjubje )}(hpidh]hpid}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubeh}(h]h ]h"]h$]h&]noemphhhuh1j hjubah}(h]h ]h"]h$]h&]hhuh1j hjhhhjhM> ubeh}(h]h ]h"]h$]h&]hhjL uh1j& jM jN hjhhhjhM> ubah}(h]jah ](jR jS eh"]h$]h&]jW jX )jY huh1j hjhM> hjhhubj[ )}(hhh]h)}(hFind 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]hFind 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().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:621: ./kernel/bpf/helpers.chM> hjhhubah}(h]h ]h"]h$]h&]uh1jZ hjhhhjhM> ubeh}(h]h ](jofunctioneh"]h$]h&]j{ joj| jj} jj~ j j uh1j hhhj hNhNubj )}(hB**Parameters** ``s32 pid`` The pid of the task being looked up.h](h)}(h**Parameters**h]j )}(hj h]h Parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hj ubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:621: ./kernel/bpf/helpers.chMB hjubj )}(hhh]j )}(h0``s32 pid`` The pid of the task being looked up.h](j )}(h ``s32 pid``h]j)}(hj+h]hs32 pid}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj)ubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:621: ./kernel/bpf/helpers.chMD hj%ubj )}(hhh]h)}(h$The pid of the task being looked up.h]h$The pid of the task being looked up.}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:621: ./kernel/bpf/helpers.chMA hjAubah}(h]h ]h"]h$]h&]uh1j hj%ubeh}(h]h ]h"]h$]h&]uh1j hj@hMD hj"ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ] kernelindentah"]h$]h&]uh1j hj hhhNhNubh)}(h$Here is an example of it being used:h]h$Here is an example of it being used:}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMphj hhubj)}(hXSEC("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]hXSEC("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; }}hjzsbah}(h]h ]h"]h$]h&]hhjmjnjojp}uh1jhhhMrhj hhubeh}(h]struct-task-struct-kfuncsah ]h"]4.1 struct task_struct * kfuncsah$]h&]uh1hhj hhhhhM ubh)}(hhh](h)}(h4.2 struct cgroup * kfuncsh]h4.2 struct cgroup * kfuncs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hD``struct cgroup *`` objects also have acquire and release functions:h](j)}(h``struct cgroup *``h]hstruct cgroup *}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh1 objects also have acquire and release functions:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj )}(hhh]h}(h]h ]h"]h$]h&]entries](j bpf_cgroup_acquire (C function)c.bpf_cgroup_acquirehNtauh1j hjhhhNhNubj )}(hhh](j! )}(hD__bpf_kfunc struct cgroup * bpf_cgroup_acquire (struct cgroup *cgrp)h]j' )}(hB__bpf_kfunc struct cgroup *bpf_cgroup_acquire(struct cgroup *cgrp)h](h __bpf_kfunc}(hjhhhNhNubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM ubjC )}(hjF h]hstruct}(hjhhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hjhhhjhM ubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhjhM ubh)}(hhh]je )}(hcgrouph]hcgroup}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetj modnameN classnameNj j )}j ]j )}j} bpf_cgroup_acquiresbc.bpf_cgroup_acquireasbuh1hhjhhhjhM ubj1 )}(h h]h }(hj)hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjhhhjhM ubj )}(hjPh]h*}(hj7hhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hjhhhjhM ubj )}(hbpf_cgroup_acquireh]je )}(hj&h]hbpf_cgroup_acquire}(hjHhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjDubah}(h]h ](j j eh"]h$]h&]hhuh1j hjhhhjhM ubj )}(h(struct cgroup *cgrp)h]j )}(hstruct cgroup *cgrph](jC )}(hjF h]hstruct}(hjchhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hj_ubj1 )}(h h]h }(hjphhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj_ubh)}(hhh]je )}(hcgrouph]hcgroup}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hj~ubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetjmodnameN classnameNj j )}j ]j$c.bpf_cgroup_acquireasbuh1hhj_ubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj_ubj )}(hjPh]h*}(hjhhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hj_ubje )}(hcgrph]hcgrp}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hj_ubeh}(h]h ]h"]h$]h&]noemphhhuh1j hj[ubah}(h]h ]h"]h$]h&]hhuh1j hjhhhjhM ubeh}(h]h ]h"]h$]h&]hhjL uh1j& jM jN hjhhhjhM ubah}(h]jah ](jR jS eh"]h$]h&]jW jX )jY huh1j hjhM hjhhubj[ )}(hhh]h)}(hAcquire 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]hAcquire 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().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hjhhubah}(h]h ]h"]h$]h&]uh1jZ hjhhhjhM ubeh}(h]h ](jofunctioneh"]h$]h&]j{ joj| jj} jj~ j j uh1j hhhjhNhNubj )}(h\**Parameters** ``struct cgroup *cgrp`` The cgroup on which a reference is being acquired.h](h)}(h**Parameters**h]j )}(hjh]h Parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hjubj )}(hhh]j )}(hJ``struct cgroup *cgrp`` The cgroup on which a reference is being acquired.h](j )}(h``struct cgroup *cgrp``h]j)}(hj%h]hstruct cgroup *cgrp}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj#ubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hjubj )}(hhh]h)}(h2The cgroup on which a reference is being acquired.h]h2The cgroup on which a reference is being acquired.}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hj;ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1j hj:hM hjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ] kernelindentah"]h$]h&]uh1j hjhhhNhNubj )}(hhh]h}(h]h ]h"]h$]h&]entries](j bpf_cgroup_release (C function)c.bpf_cgroup_releasehNtauh1j hjhhhNhNubj )}(hhh](j! )}(h9__bpf_kfunc void bpf_cgroup_release (struct cgroup *cgrp)h]j' )}(h8__bpf_kfunc void bpf_cgroup_release(struct cgroup *cgrp)h](h __bpf_kfunc}(hj{hhhNhNubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj{hhhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM ubj )}(hvoidh]hvoid}(hjhhhNhNubah}(h]h ]j,ah"]h$]h&]uh1jhj{hhhjhM ubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj{hhhjhM ubj )}(hbpf_cgroup_releaseh]je )}(hbpf_cgroup_releaseh]hbpf_cgroup_release}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ](j j eh"]h$]h&]hhuh1j hj{hhhjhM ubj )}(h(struct cgroup *cgrp)h]j )}(hstruct cgroup *cgrph](jC )}(hjF h]hstruct}(hjhhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hjubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjubh)}(hhh]je )}(hcgrouph]hcgroup}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetjmodnameN classnameNj j )}j ]j )}j} jsbc.bpf_cgroup_releaseasbuh1hhjubj1 )}(h h]h }(hj hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjubj )}(hjPh]h*}(hjhhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hjubje )}(hcgrph]hcgrp}(hj'hhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubeh}(h]h ]h"]h$]h&]noemphhhuh1j hjubah}(h]h ]h"]h$]h&]hhuh1j hj{hhhjhM ubeh}(h]h ]h"]h$]h&]hhjL uh1j& jM jN hjwhhhjhM ubah}(h]jrah ](jR jS eh"]h$]h&]jW jX )jY huh1j hjhM hjthhubj[ )}(hhh]h)}(hRelease 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]hRelease 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.}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hjNhhubah}(h]h ]h"]h$]h&]uh1jZ hjthhhjhM ubeh}(h]h ](jofunctioneh"]h$]h&]j{ joj| jij} jij~ j j uh1j hhhjhNhNubj )}(h\**Parameters** ``struct cgroup *cgrp`` The cgroup on which a reference is being released.h](h)}(h**Parameters**h]j )}(hjsh]h Parameters}(hjuhhhNhNubah}(h]h ]h"]h$]h&]uh1j hjqubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hjmubj )}(hhh]j )}(hJ``struct cgroup *cgrp`` The cgroup on which a reference is being released.h](j )}(h``struct cgroup *cgrp``h]j)}(hjh]hstruct cgroup *cgrp}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hjubj )}(hhh]h)}(h2The cgroup on which a reference is being released.h]h2The cgroup on which a reference is being released.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:661: ./kernel/bpf/helpers.chM hjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1j hjhM hjubah}(h]h ]h"]h$]h&]uh1j hjmubeh}(h]h ] kernelindentah"]h$]h&]uh1j hjhhhNhNubh)}(hThese 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]hThese 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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h----h]h}(h]h ]h"]h$]h&]uh1jhhhMhjhhubh)}(hOther 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 }(hjhhhNhNubj)}(h``struct cgroup *``h]hstruct cgroup *}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh 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.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj )}(hhh]h}(h]h ]h"]h$]h&]entries](j bpf_cgroup_ancestor (C function)c.bpf_cgroup_ancestorhNtauh1j hjhhhNhNubj )}(hhh](j! )}(hP__bpf_kfunc struct cgroup * bpf_cgroup_ancestor (struct cgroup *cgrp, int level)h]j' )}(hN__bpf_kfunc struct cgroup *bpf_cgroup_ancestor(struct cgroup *cgrp, int level)h](h __bpf_kfunc}(hj hhhNhNubj1 )}(h h]h }(hj(hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj hhhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:674: ./kernel/bpf/helpers.chM ubjC )}(hjF h]hstruct}(hj7hhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hj hhhj6hM ubj1 )}(h h]h }(hjDhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj hhhj6hM ubh)}(hhh]je )}(hcgrouph]hcgroup}(hjUhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjRubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetjWmodnameN classnameNj j )}j ]j )}j} bpf_cgroup_ancestorsbc.bpf_cgroup_ancestorasbuh1hhj hhhj6hM ubj1 )}(h h]h }(hjvhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj hhhj6hM ubj )}(hjPh]h*}(hjhhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hj hhhj6hM ubj )}(hbpf_cgroup_ancestorh]je )}(hjsh]hbpf_cgroup_ancestor}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ](j j eh"]h$]h&]hhuh1j hj hhhj6hM ubj )}(h (struct cgroup *cgrp, int level)h](j )}(hstruct cgroup *cgrph](jC )}(hjF h]hstruct}(hjhhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hjubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjubh)}(hhh]je )}(hcgrouph]hcgroup}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetjmodnameN classnameNj j )}j ]jqc.bpf_cgroup_ancestorasbuh1hhjubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjubj )}(hjPh]h*}(hjhhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hjubje )}(hcgrph]hcgrp}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubeh}(h]h ]h"]h$]h&]noemphhhuh1j hjubj )}(h int levelh](j )}(hinth]hint}(hj hhhNhNubah}(h]h ]j,ah"]h$]h&]uh1jhjubj1 )}(h h]h }(hj.hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjubje )}(hlevelh]hlevel}(hj<hhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubeh}(h]h ]h"]h$]h&]noemphhhuh1j hjubeh}(h]h ]h"]h$]h&]hhuh1j hj hhhj6hM ubeh}(h]h ]h"]h$]h&]hhjL uh1j& jM jN hjhhhj6hM ubah}(h]jah ](jR jS eh"]h$]h&]jW jX )jY huh1j hj6hM hjhhubj[ )}(hhh]h)}(hPerform 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]hPerform 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().}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:674: ./kernel/bpf/helpers.chM hjchhubah}(h]h ]h"]h$]h&]uh1jZ hjhhhj6hM ubeh}(h]h ](jofunctioneh"]h$]h&]j{ joj| j~j} j~j~ j j uh1j hhhjhNhNubj )}(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 )}(hjh]h Parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:674: ./kernel/bpf/helpers.chM hjubj )}(hhh](j )}(hH``struct cgroup *cgrp`` The cgroup for which we're performing a lookup. h](j )}(h``struct cgroup *cgrp``h]j)}(hjh]hstruct cgroup *cgrp}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:674: ./kernel/bpf/helpers.chM hjubj )}(hhh]h)}(h/The cgroup for which we're performing a lookup.h]h1The cgroup for which we’re performing a lookup.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhM hjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1j hjhM hjubj )}(h/``int level`` The level of ancestor to look up.h](j )}(h ``int level``h]j)}(hjh]h int level}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:674: ./kernel/bpf/helpers.chM hjubj )}(hhh]h)}(h!The level of ancestor to look up.h]h!The level of ancestor to look up.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:674: ./kernel/bpf/helpers.chM hjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1j hjhM hjubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ] kernelindentah"]h$]h&]uh1j hjhhhNhNubj )}(hhh]h}(h]h ]h"]h$]h&]entries](j bpf_cgroup_from_id (C function)c.bpf_cgroup_from_idhNtauh1j hjhhhNhNubj )}(hhh](j! )}(h9__bpf_kfunc struct cgroup * bpf_cgroup_from_id (u64 cgid)h]j' )}(h7__bpf_kfunc struct cgroup *bpf_cgroup_from_id(u64 cgid)h](h __bpf_kfunc}(hj6hhhNhNubj1 )}(h h]h }(hj>hhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj6hhhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:677: ./kernel/bpf/helpers.chM ubjC )}(hjF h]hstruct}(hjMhhhNhNubah}(h]h ]jO ah"]h$]h&]uh1jB hj6hhhjLhM ubj1 )}(h h]h }(hjZhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj6hhhjLhM ubh)}(hhh]je )}(hcgrouph]hcgroup}(hjkhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjhubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetjmmodnameN classnameNj j )}j ]j )}j} bpf_cgroup_from_idsbc.bpf_cgroup_from_idasbuh1hhj6hhhjLhM ubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hj6hhhjLhM ubj )}(hjPh]h*}(hjhhhNhNubah}(h]h ]j ah"]h$]h&]uh1j hj6hhhjLhM ubj )}(hbpf_cgroup_from_idh]je )}(hjh]hbpf_cgroup_from_id}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ](j j eh"]h$]h&]hhuh1j hj6hhhjLhM ubj )}(h (u64 cgid)h]j )}(hu64 cgidh](h)}(hhh]je )}(hu64h]hu64}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubah}(h]h ]h"]h$]h&] refdomainjoreftypej} reftargetjmodnameN classnameNj j )}j ]jc.bpf_cgroup_from_idasbuh1hhjubj1 )}(h h]h }(hjhhhNhNubah}(h]h ]j= ah"]h$]h&]uh1j0 hjubje )}(hcgidh]hcgid}(hjhhhNhNubah}(h]h ]jq ah"]h$]h&]uh1jd hjubeh}(h]h ]h"]h$]h&]noemphhhuh1j hjubah}(h]h ]h"]h$]h&]hhuh1j hj6hhhjLhM ubeh}(h]h ]h"]h$]h&]hhjL uh1j& jM jN hj2hhhjLhM ubah}(h]j-ah ](jR jS eh"]h$]h&]jW jX )jY huh1j hjLhM hj/hhubj[ )}(hhh]h)}(hFind 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]hFind 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().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:677: ./kernel/bpf/helpers.chM hjhhubah}(h]h ]h"]h$]h&]uh1jZ hj/hhhjLhM ubeh}(h]h ](jofunctioneh"]h$]h&]j{ joj| j7j} j7j~ j j uh1j hhhjhNhNubj )}(h)**Parameters** ``u64 cgid`` cgroup id.h](h)}(h**Parameters**h]j )}(hjAh]h Parameters}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1j hj?ubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:677: ./kernel/bpf/helpers.chM hj;ubj )}(hhh]j )}(h``u64 cgid`` cgroup id.h](j )}(h ``u64 cgid``h]j)}(hj`h]hu64 cgid}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj^ubah}(h]h ]h"]h$]h&]uh1j hP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:677: ./kernel/bpf/helpers.chM hjZubj )}(hhh]h)}(h cgroup id.h]h cgroup id.}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhP/var/lib/git/docbuild/linux/Documentation/bpf/kfuncs:677: ./kernel/bpf/helpers.chM hjvubah}(h]h ]h"]h$]h&]uh1j hjZubeh}(h]h ]h"]h$]h&]uh1j hjuhM hjWubah}(h]h ]h"]h$]h&]uh1j hj;ubeh}(h]h ] kernelindentah"]h$]h&]uh1j hjhhhNhNubh)}(hEventually, 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]hEventually, 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:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(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; }}hjsbah}(h]h ]h"]h$]h&]hhjmjnjojp}uh1jhhhMhjhhubeh}(h]struct-cgroup-kfuncsah ]h"]4.2 struct cgroup * kfuncsah$]h&]uh1hhj hhhhhMubh)}(hhh](h)}(h4.3 struct cpumask * kfuncsh]h4.3 struct cpumask * kfuncs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hBPF 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](hBPF provides a set of kfuncs that can be used to query, allocate, mutate, and destroy struct cpumask * objects. Please refer to }(hjhhhNhNubh)}(h:ref:`cpumasks-header-label`h]h)}(hjh]hcpumasks-header-label}(hjhhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjcpumasks-header-labeluh1hhhhMhjubh for more details.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]struct-cpumask-kfuncsah ]h"]4.3 struct cpumask * kfuncsah$]h&]uh1hhj hhhhhMubeh}(h] core-kfuncsah ]h"]4. core kfuncsah$]h&]uh1hhhhhhhhMubeh}(h](bpf-kernel-functions-kfuncsheh ]h"](bpf kernel functions (kfuncs)kfuncs-header-labeleh$]h&]uh1hhhhhhhhKja}jhsjc}hhsubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjGerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}(h]haj0]j&aj!]jaj4 ]j* aunameids}(jhjjj&j#jB j? jjjjjXjUjjjjjYjVjjj6j3j^j0j]jZjjjjj!jjHjEj@j=jgjdjjjjj'j$jj!jj}jjj: j7 j j4 j j j j jjjjjjjj u nametypes}(jjj&jB jjjXjjjYjj6j^j]jjj!jHj@jgjjj'jjjj: j j j jjjjuh}(hhjhj#hj? j)jjzjjjUjjj[jjjVj jj\j3jj0j9jZj9jjejjjjjEj$j=jKjdjCjjjjjj$jj!j*j}j*jjj7 jj4 jE j jE j j jj jj j j" j jjjjjjjjrjwjjj-j2j ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}jUKsRparse_messages]transform_messages](hsystem_message)}(hhh]h)}(hhh]h9Hyperlink target "kfuncs-header-label" is not referenced.}hjsbah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKuh1jubj)}(hhh]h)}(hhh]h5Hyperlink target "bpf-kfunc-nodef" is not referenced.}hjsbah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineKuh1jubj)}(hhh]h)}(hhh]h8Hyperlink target "kf-deprecated-flag" is not referenced.}hjsbah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineMcuh1jubj)}(hhh]h)}(hhh]hFHyperlink target "bpf-kfunc-lifecycle-expectations" is not referenced.}hjsbah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypejsourcehlineMuh1jube transformerN include_log] decorationNhhub.