€•Ê�Œ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/map_hash”Œ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/map_hash”Œ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/map_hash”Œ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/map_hash”Œ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/map_hash”Œ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/map_hash”Œ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/map_hash”Œ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-only”h]”hŒ%SPDX-License-Identifier: GPL-2.0-only”…”�”}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ:/var/lib/git/docbuild/linux/Documentation/bpf/map_hash.rst”h´Kubh¶)�”}”(hŒ Copyright (C) 2022 Red Hat, Inc.”h]”hŒ Copyright (C) 2022 Red Hat, Inc.”…”�”}”hhÈsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1hµhhh²hh³hÇh´Kubh¶)�”}”(hŒ'Copyright (C) 2022-2023 Isovalent, Inc.”h]”hŒ'Copyright (C) 2022-2023 Isovalent, Inc.”…”�”}”hhÖsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1hµhhh²hh³hÇh´KubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒ/BPF_MAP_TYPE_HASH, with PERCPU and LRU Variants”h]”hŒ/BPF_MAP_TYPE_HASH, with PERCPU and LRU Variants”…”�”}”(hhëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhhæh²hh³hÇh´KubhŒnote”“”)�”}”(hŒâ- ``BPF_MAP_TYPE_HASH`` was introduced in kernel version 3.19 - ``BPF_MAP_TYPE_PERCPU_HASH`` was introduced in version 4.6 - Both ``BPF_MAP_TYPE_LRU_HASH`` and ``BPF_MAP_TYPE_LRU_PERCPU_HASH`` were introduced in version 4.10”h]”hŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒ;``BPF_MAP_TYPE_HASH`` was introduced in kernel version 3.19”h]”hŒ paragraph”“”)�”}”(hjh]”(hŒliteral”“”)�”}”(hŒ``BPF_MAP_TYPE_HASH``”h]”hŒBPF_MAP_TYPE_HASH”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubhŒ& was introduced in kernel version 3.19”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒ:``BPF_MAP_TYPE_PERCPU_HASH`` was introduced in version 4.6”h]”j )�”}”(hj1h]”(j)�”}”(hŒ``BPF_MAP_TYPE_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_PERCPU_HASH”…”�”}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj3ubhŒ was introduced in version 4.6”…”�”}”(hj3h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K hj/ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒcBoth ``BPF_MAP_TYPE_LRU_HASH`` and ``BPF_MAP_TYPE_LRU_PERCPU_HASH`` were introduced in version 4.10”h]”j )�”}”(hŒcBoth ``BPF_MAP_TYPE_LRU_HASH`` and ``BPF_MAP_TYPE_LRU_PERCPU_HASH`` were introduced in version 4.10”h]”(hŒBoth ”…”�”}”(hjXh²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_LRU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_HASH”…”�”}”(hj`h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjXubhŒ and ”…”�”}”(hjXh²hh³Nh´Nubj)�”}”(hŒ ``BPF_MAP_TYPE_LRU_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_PERCPU_HASH”…”�”}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjXubhŒ were introduced in version 4.10”…”�”}”(hjXh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K hjTubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1hÿh³hÇh´K hhûubah}”(h]”h ]”h"]”h$]”h&]”uh1hùhhæh²hh³Nh´Nubj )�”}”(hŒ³``BPF_MAP_TYPE_HASH`` and ``BPF_MAP_TYPE_PERCPU_HASH`` provide general purpose hash map storage. Both the key and the value can be structs, allowing for composite keys and values.”h]”(j)�”}”(hŒ``BPF_MAP_TYPE_HASH``”h]”hŒBPF_MAP_TYPE_HASH”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjžubhŒ and ”…”�”}”(hjžh²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_PERCPU_HASH”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjžubhŒ} provide general purpose hash map storage. Both the key and the value can be structs, allowing for composite keys and values.”…”�”}”(hjžh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Khhæh²hubj )�”}”(hXThe kernel is responsible for allocating and freeing key/value pairs, up to the max_entries limit that you specify. Hash maps use pre-allocation of hash table elements by default. The ``BPF_F_NO_PREALLOC`` flag can be used to disable pre-allocation when it is too memory expensive.”h]”(hŒ¸The kernel is responsible for allocating and freeing key/value pairs, up to the max_entries limit that you specify. Hash maps use pre-allocation of hash table elements by default. The ”…”�”}”(hjÌh²hh³Nh´Nubj)�”}”(hŒ``BPF_F_NO_PREALLOC``”h]”hŒBPF_F_NO_PREALLOC”…”�”}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÌubhŒL flag can be used to disable pre-allocation when it is too memory expensive.”…”�”}”(hjÌh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Khhæh²hubj )�”}”(hŒz``BPF_MAP_TYPE_PERCPU_HASH`` provides a separate value slot per CPU. The per-cpu values are stored internally in an array.”h]”(j)�”}”(hŒ``BPF_MAP_TYPE_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_PERCPU_HASH”…”�”}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjìubhŒ^ provides a separate value slot per CPU. The per-cpu values are stored internally in an array.”…”�”}”(hjìh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Khhæh²hubj )�”}”(hXbThe ``BPF_MAP_TYPE_LRU_HASH`` and ``BPF_MAP_TYPE_LRU_PERCPU_HASH`` variants add LRU semantics to their respective hash tables. An LRU hash will automatically evict the least recently used entries when the hash table reaches capacity. An LRU hash maintains an internal LRU list that is used to select elements for eviction. This internal LRU list is shared across CPUs but it is possible to request a per CPU LRU list with the ``BPF_F_NO_COMMON_LRU`` flag when calling ``bpf_map_create``. The following table outlines the properties of LRU maps depending on the a map type and the flags used to create the map.”h]”(hŒThe ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_LRU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_HASH”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ and ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ ``BPF_MAP_TYPE_LRU_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_PERCPU_HASH”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhXh variants add LRU semantics to their respective hash tables. An LRU hash will automatically evict the least recently used entries when the hash table reaches capacity. An LRU hash maintains an internal LRU list that is used to select elements for eviction. This internal LRU list is shared across CPUs but it is possible to request a per CPU LRU list with the ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``BPF_F_NO_COMMON_LRU``”h]”hŒBPF_F_NO_COMMON_LRU”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ flag when calling ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``bpf_map_create``”h]”hŒbpf_map_create”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ|. The following table outlines the properties of LRU maps depending on the a map type and the flags used to create the map.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Khhæh²hubhŒtable”“”)�”}”(hhh]”hŒtgroup”“”)�”}”(hhh]”(hŒcolspec”“”)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1jhhjeubji)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1jhhjeubji)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K uh1jhhjeubhŒthead”“”)�”}”(hhh]”hŒrow”“”)�”}”(hhh]”(hŒentry”“”)�”}”(hhh]”j )�”}”(hŒFlag”h]”hŒFlag”…”�”}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K&hj”ubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hj�ubj“)�”}”(hhh]”j )�”}”(hŒ``BPF_MAP_TYPE_LRU_HASH``”h]”j)�”}”(hj°h]”hŒBPF_MAP_TYPE_LRU_HASH”…”�”}”(hj²h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj®ubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K&hj«ubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hj�ubj“)�”}”(hhh]”j )�”}”(hŒ ``BPF_MAP_TYPE_LRU_PERCPU_HASH``”h]”j)�”}”(hjÐh]”hŒBPF_MAP_TYPE_LRU_PERCPU_HASH”…”�”}”(hjÒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÎubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K&hjËubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hj�ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j�hjŠubah}”(h]”h ]”h"]”h$]”h&]”uh1jˆhjeubhŒtbody”“”)�”}”(hhh]”(jŽ)�”}”(hhh]”(j“)�”}”(hhh]”j )�”}”(hŒ**BPF_F_NO_COMMON_LRU**”h]”hŒstrong”“”)�”}”(hjh]”hŒBPF_F_NO_COMMON_LRU”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K(hjÿubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hjüubj“)�”}”(hhh]”j )�”}”(hŒPer-CPU LRU, global map”h]”hŒPer-CPU LRU, global map”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K(hj!ubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hjüubj“)�”}”(hhh]”j )�”}”(hŒPer-CPU LRU, per-cpu map”h]”hŒPer-CPU LRU, per-cpu map”…”�”}”(hj;h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K(hj8ubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hjüubeh}”(h]”h ]”h"]”h$]”h&]”uh1j�hjùubjŽ)�”}”(hhh]”(j“)�”}”(hhh]”j )�”}”(hŒ**!BPF_F_NO_COMMON_LRU**”h]”j)�”}”(hj]h]”hŒ!BPF_F_NO_COMMON_LRU”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj[ubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K)hjXubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hjUubj“)�”}”(hhh]”j )�”}”(hŒGlobal LRU, global map”h]”hŒGlobal LRU, global map”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K)hjxubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hjUubj“)�”}”(hhh]”j )�”}”(hŒGlobal LRU, per-cpu map”h]”hŒGlobal LRU, per-cpu map”…”�”}”(hj’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K)hj�ubah}”(h]”h ]”h"]”h$]”h&]”uh1j’hjUubeh}”(h]”h ]”h"]”h$]”h&]”uh1j�hjùubeh}”(h]”h ]”h"]”h$]”h&]”uh1j÷hjeubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1jchj`ubah}”(h]”h ]”h"]”h$]”h&]”uh1j^hhæh²hh³hÇh´Nubhå)�”}”(hhh]”(hê)�”}”(hŒUsage”h]”hŒUsage”…”�”}”(hjÂh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhj¿h²hh³hÇh´K-ubhå)�”}”(hhh]”(hê)�”}”(hŒ Kernel BPF”h]”hŒ Kernel BPF”…”�”}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjÐh²hh³hÇh´K0ubhå)�”}”(hhh]”(hê)�”}”(hŒbpf_map_update_elem()”h]”hŒbpf_map_update_elem()”…”�”}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjáh²hh³hÇh´K3ubhŒ literal_block”“”)�”}”(hŒ\long bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags)”h]”hŒ\long bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags)”…”�”}”hjôsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒforce”‰Œlanguage”Œc”Œhighlight_args”}”uh1jòh³hÇh´K5hjáh²hubj )�”}”(hŒÈHash entries can be added or updated using the ``bpf_map_update_elem()`` helper. This helper replaces existing elements atomically. The ``flags`` parameter can be used to control the update behaviour:”h]”(hŒ/Hash entries can be added or updated using the ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``bpf_map_update_elem()``”h]”hŒbpf_map_update_elem()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ@ helper. This helper replaces existing elements atomically. The ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ ``flags``”h]”hŒflags”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ7 parameter can be used to control the update behaviour:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K9hjáh²hubj)�”}”(hhh]”(j)�”}”(hŒC``BPF_ANY`` will create a new element or update an existing element”h]”j )�”}”(hj>h]”(j)�”}”(hŒ ``BPF_ANY``”h]”hŒBPF_ANY”…”�”}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj@ubhŒ8 will create a new element or update an existing element”…”�”}”(hj@h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K=hj<ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj9h²hh³hÇh´Nubj)�”}”(hŒK``BPF_NOEXIST`` will create a new element only if one did not already exist”h]”j )�”}”(hŒK``BPF_NOEXIST`` will create a new element only if one did not already exist”h]”(j)�”}”(hŒ``BPF_NOEXIST``”h]”hŒ BPF_NOEXIST”…”�”}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjeubhŒ< will create a new element only if one did not already exist”…”�”}”(hjeh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K>hjaubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj9h²hh³hÇh´Nubj)�”}”(hŒ.``BPF_EXIST`` will update an existing element ”h]”j )�”}”(hŒ-``BPF_EXIST`` will update an existing element”h]”(j)�”}”(hŒ ``BPF_EXIST``”h]”hŒ BPF_EXIST”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj‹ubhŒ will update an existing element”…”�”}”(hj‹h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K@hj‡ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj9h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j–j—uh1hÿh³hÇh´K=hjáh²hubj )�”}”(hŒU``bpf_map_update_elem()`` returns 0 on success, or negative error in case of failure.”h]”(j)�”}”(hŒ``bpf_map_update_elem()``”h]”hŒbpf_map_update_elem()”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj³ubhŒ< returns 0 on success, or negative error in case of failure.”…”�”}”(hj³h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´KBhjáh²hubeh}”(h]”Œbpf-map-update-elem”ah ]”h"]”Œbpf_map_update_elem()”ah$]”h&]”uh1hähjÐh²hh³hÇh´K3ubhå)�”}”(hhh]”(hê)�”}”(hŒbpf_map_lookup_elem()”h]”hŒbpf_map_lookup_elem()”…”�”}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhj×h²hh³hÇh´KFubjó)�”}”(hŒ?void *bpf_map_lookup_elem(struct bpf_map *map, const void *key)”h]”hŒ?void *bpf_map_lookup_elem(struct bpf_map *map, const void *key)”…”�”}”hjèsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj‰jjj}”uh1jòh³hÇh´KHhj×h²hubj )�”}”(hŒ°Hash entries can be retrieved using the ``bpf_map_lookup_elem()`` helper. This helper returns a pointer to the value associated with ``key``, or ``NULL`` if no entry was found.”h]”(hŒ(Hash entries can be retrieved using the ”…”�”}”(hj÷h²hh³Nh´Nubj)�”}”(hŒ``bpf_map_lookup_elem()``”h]”hŒbpf_map_lookup_elem()”…”�”}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj÷ubhŒD helper. This helper returns a pointer to the value associated with ”…”�”}”(hj÷h²hh³Nh´Nubj)�”}”(hŒ``key``”h]”hŒkey”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj÷ubhŒ, or ”…”�”}”(hj÷h²hh³Nh´Nubj)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj÷ubhŒ if no entry was found.”…”�”}”(hj÷h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´KLhj×h²hubeh}”(h]”Œbpf-map-lookup-elem”ah ]”h"]”Œbpf_map_lookup_elem()”ah$]”h&]”uh1hähjÐh²hh³hÇh´KFubhå)�”}”(hhh]”(hê)�”}”(hŒbpf_map_delete_elem()”h]”hŒbpf_map_delete_elem()”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjCh²hh³hÇh´KQubjó)�”}”(hŒ>long bpf_map_delete_elem(struct bpf_map *map, const void *key)”h]”hŒ>long bpf_map_delete_elem(struct bpf_map *map, const void *key)”…”�”}”hjTsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj‰jjj}”uh1jòh³hÇh´KShjCh²hubj )�”}”(hŒ“Hash entries can be deleted using the ``bpf_map_delete_elem()`` helper. This helper will return 0 on success, or negative error in case of failure.”h]”(hŒ&Hash entries can be deleted using the ”…”�”}”(hjch²hh³Nh´Nubj)�”}”(hŒ``bpf_map_delete_elem()``”h]”hŒbpf_map_delete_elem()”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjcubhŒT helper. This helper will return 0 on success, or negative error in case of failure.”…”�”}”(hjch²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´KWhjCh²hubeh}”(h]”Œbpf-map-delete-elem”ah ]”h"]”Œbpf_map_delete_elem()”ah$]”h&]”uh1hähjÐh²hh³hÇh´KQubeh}”(h]”Œ kernel-bpf”ah ]”h"]”Œ kernel bpf”ah$]”h&]”uh1hähj¿h²hh³hÇh´K0ubhå)�”}”(hhh]”(hê)�”}”(hŒPer CPU Hashes”h]”hŒPer CPU Hashes”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhj“h²hh³hÇh´K\ubj )�”}”(hŒÁFor ``BPF_MAP_TYPE_PERCPU_HASH`` and ``BPF_MAP_TYPE_LRU_PERCPU_HASH`` the ``bpf_map_update_elem()`` and ``bpf_map_lookup_elem()`` helpers automatically access the hash slot for the current CPU.”h]”(hŒFor ”…”�”}”(hj¤h²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_PERCPU_HASH”…”�”}”(hj¬h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¤ubhŒ and ”…”�”}”(hj¤h²hh³Nh´Nubj)�”}”(hŒ ``BPF_MAP_TYPE_LRU_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_PERCPU_HASH”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¤ubhŒ the ”…”�”}”(hj¤h²hh³Nh´Nubj)�”}”(hŒ``bpf_map_update_elem()``”h]”hŒbpf_map_update_elem()”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¤ubhŒ and ”…”�”}”hj¤sbj)�”}”(hŒ``bpf_map_lookup_elem()``”h]”hŒbpf_map_lookup_elem()”…”�”}”(hjâh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¤ubhŒ@ helpers automatically access the hash slot for the current CPU.”…”�”}”(hj¤h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K^hj“h²hubhå)�”}”(hhh]”(hê)�”}”(hŒbpf_map_lookup_percpu_elem()”h]”hŒbpf_map_lookup_percpu_elem()”…”�”}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjúh²hh³hÇh´Kcubjó)�”}”(hŒOvoid *bpf_map_lookup_percpu_elem(struct bpf_map *map, const void *key, u32 cpu)”h]”hŒOvoid *bpf_map_lookup_percpu_elem(struct bpf_map *map, const void *key, u32 cpu)”…”�”}”hj sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj‰jjj}”uh1jòh³hÇh´Kehjúh²hubj )�”}”(hŒÜThe ``bpf_map_lookup_percpu_elem()`` helper can be used to lookup the value in the hash slot for a specific CPU. Returns value associated with ``key`` on ``cpu`` , or ``NULL`` if no entry was found or ``cpu`` is invalid.”h]”(hŒThe ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ ``bpf_map_lookup_percpu_elem()``”h]”hŒbpf_map_lookup_percpu_elem()”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒk helper can be used to lookup the value in the hash slot for a specific CPU. Returns value associated with ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``key``”h]”hŒkey”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ on ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``cpu``”h]”hŒcpu”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ , or ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ if no entry was found or ”…”�”}”(hjh²hh³Nh´Nubj)�”}”(hŒ``cpu``”h]”hŒcpu”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒ is invalid.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kihjúh²hubeh}”(h]”Œbpf-map-lookup-percpu-elem”ah ]”h"]”Œbpf_map_lookup_percpu_elem()”ah$]”h&]”uh1hähj“h²hh³hÇh´Kcubeh}”(h]”Œper-cpu-hashes”ah ]”h"]”Œper cpu hashes”ah$]”h&]”uh1hähj¿h²hh³hÇh´K\ubhå)�”}”(hhh]”(hê)�”}”(hŒ Concurrency”h]”hŒ Concurrency”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhj’h²hh³hÇh´Koubj )�”}”(hXValues stored in ``BPF_MAP_TYPE_HASH`` can be accessed concurrently by programs running on different CPUs. Since Kernel version 5.1, the BPF infrastructure provides ``struct bpf_spin_lock`` to synchronise access. See ``tools/testing/selftests/bpf/progs/test_spin_lock.c``.”h]”(hŒValues stored in ”…”�”}”(hj£h²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_HASH``”h]”hŒBPF_MAP_TYPE_HASH”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj£ubhŒ€ can be accessed concurrently by programs running on different CPUs. Since Kernel version 5.1, the BPF infrastructure provides ”…”�”}”(hj£h²hh³Nh´Nubj)�”}”(hŒ``struct bpf_spin_lock``”h]”hŒstruct bpf_spin_lock”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj£ubhŒ to synchronise access. See ”…”�”}”(hj£h²hh³Nh´Nubj)�”}”(hŒ6``tools/testing/selftests/bpf/progs/test_spin_lock.c``”h]”hŒ2tools/testing/selftests/bpf/progs/test_spin_lock.c”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj£ubhŒ.”…”�”}”(hj£h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kqhj’h²hubeh}”(h]”Œ concurrency”ah ]”h"]”Œ concurrency”ah$]”h&]”uh1hähj¿h²hh³hÇh´Koubhå)�”}”(hhh]”(hê)�”}”(hŒ Userspace”h]”hŒ Userspace”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjïh²hh³hÇh´Kwubhå)�”}”(hhh]”(hê)�”}”(hŒbpf_map_get_next_key()”h]”hŒbpf_map_get_next_key()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjh²hh³hÇh´Kzubjó)�”}”(hŒEint bpf_map_get_next_key(int fd, const void *cur_key, void *next_key)”h]”hŒEint bpf_map_get_next_key(int fd, const void *cur_key, void *next_key)”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj‰jjj}”uh1jòh³hÇh´K|hjh²hubj )�”}”(hX©In userspace, it is possible to iterate through the keys of a hash using libbpf's ``bpf_map_get_next_key()`` function. The first key can be fetched by calling ``bpf_map_get_next_key()`` with ``cur_key`` set to ``NULL``. Subsequent calls will fetch the next key that follows the current key. ``bpf_map_get_next_key()`` returns 0 on success, -ENOENT if cur_key is the last key in the hash, or negative error in case of failure.”h]”(hŒTIn userspace, it is possible to iterate through the keys of a hash using libbpf’s ”…”�”}”(hj h²hh³Nh´Nubj)�”}”(hŒ``bpf_map_get_next_key()``”h]”hŒbpf_map_get_next_key()”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubhŒ3 function. The first key can be fetched by calling ”…”�”}”(hj h²hh³Nh´Nubj)�”}”(hŒ``bpf_map_get_next_key()``”h]”hŒbpf_map_get_next_key()”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubhŒ with ”…”�”}”(hj h²hh³Nh´Nubj)�”}”(hŒ ``cur_key``”h]”hŒcur_key”…”�”}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubhŒ set to ”…”�”}”(hj h²hh³Nh´Nubj)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubhŒI. Subsequent calls will fetch the next key that follows the current key. ”…”�”}”(hj h²hh³Nh´Nubj)�”}”(hŒ``bpf_map_get_next_key()``”h]”hŒbpf_map_get_next_key()”…”�”}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubhŒl returns 0 on success, -ENOENT if cur_key is the last key in the hash, or negative error in case of failure.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K€hjh²hubj )�”}”(hX Note that if ``cur_key`` gets deleted then ``bpf_map_get_next_key()`` will instead return the *first* key in the hash table which is undesirable. It is recommended to use batched lookup if there is going to be key deletion intermixed with ``bpf_map_get_next_key()``.”h]”(hŒ Note that if ”…”�”}”(hjˆh²hh³Nh´Nubj)�”}”(hŒ ``cur_key``”h]”hŒcur_key”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjˆubhŒ gets deleted then ”…”�”}”(hjˆh²hh³Nh´Nubj)�”}”(hŒ``bpf_map_get_next_key()``”h]”hŒbpf_map_get_next_key()”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjˆubhŒ will instead return the ”…”�”}”(hjˆh²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ*first*”h]”hŒfirst”…”�”}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j´hjˆubhŒŠ key in the hash table which is undesirable. It is recommended to use batched lookup if there is going to be key deletion intermixed with ”…”�”}”(hjˆh²hh³Nh´Nubj)�”}”(hŒ``bpf_map_get_next_key()``”h]”hŒbpf_map_get_next_key()”…”�”}”(hjÈh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjˆubhŒ.”…”�”}”(hjˆh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kˆhjh²hubeh}”(h]”Œbpf-map-get-next-key”ah ]”h"]”Œbpf_map_get_next_key()”ah$]”h&]”uh1hähjïh²hh³hÇh´Kzubeh}”(h]”Œ userspace”ah ]”h"]”Œ userspace”ah$]”h&]”uh1hähj¿h²hh³hÇh´Kwubeh}”(h]”Œusage”ah ]”h"]”Œusage”ah$]”h&]”uh1hähhæh²hh³hÇh´K-ubhå)�”}”(hhh]”(hê)�”}”(hŒExamples”h]”hŒExamples”…”�”}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjøh²hh³hÇh´KŽubj )�”}”(hŒ‚Please see the ``tools/testing/selftests/bpf`` directory for functional examples. The code snippets below demonstrates API usage.”h]”(hŒPlease see the ”…”�”}”(hj h²hh³Nh´Nubj)�”}”(hŒ``tools/testing/selftests/bpf``”h]”hŒtools/testing/selftests/bpf”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubhŒT directory for functional examples. The code snippets below demonstrates API usage.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K�hjøh²hubj )�”}”(hŒSThis example shows how to declare an LRU Hash with a struct key and a struct value.”h]”hŒSThis example shows how to declare an LRU Hash with a struct key and a struct value.”…”�”}”(hj)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K“hjøh²hubjó)�”}”(hXG#include #include struct key { __u32 srcip; }; struct value { __u64 packets; __u64 bytes; }; struct { __uint(type, BPF_MAP_TYPE_LRU_HASH); __uint(max_entries, 32); __type(key, struct key); __type(value, struct value); } packet_stats SEC(".maps");”h]”hXG#include #include struct key { __u32 srcip; }; struct value { __u64 packets; __u64 bytes; }; struct { __uint(type, BPF_MAP_TYPE_LRU_HASH); __uint(max_entries, 32); __type(key, struct key); __type(value, struct value); } packet_stats SEC(".maps");”…”�”}”hj7sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj‰jjj}”uh1jòh³hÇh´K–hjøh²hubj )�”}”(hŒQThis example shows how to create or update hash values using atomic instructions:”h]”hŒQThis example shows how to create or update hash values using atomic instructions:”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´K«hjøh²hubjó)�”}”(hXîstatic void update_stats(__u32 srcip, int bytes) { struct key key = { .srcip = srcip, }; struct value *value = bpf_map_lookup_elem(&packet_stats, &key); if (value) { __sync_fetch_and_add(&value->packets, 1); __sync_fetch_and_add(&value->bytes, bytes); } else { struct value newval = { 1, bytes }; bpf_map_update_elem(&packet_stats, &key, &newval, BPF_NOEXIST); } }”h]”hXîstatic void update_stats(__u32 srcip, int bytes) { struct key key = { .srcip = srcip, }; struct value *value = bpf_map_lookup_elem(&packet_stats, &key); if (value) { __sync_fetch_and_add(&value->packets, 1); __sync_fetch_and_add(&value->bytes, bytes); } else { struct value newval = { 1, bytes }; bpf_map_update_elem(&packet_stats, &key, &newval, BPF_NOEXIST); } }”…”�”}”hjTsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj‰jjj}”uh1jòh³hÇh´K®hjøh²hubj )�”}”(hŒ?Userspace walking the map elements from the map declared above:”h]”hŒ?Userspace walking the map elements from the map declared above:”…”�”}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´KÁhjøh²hubjó)�”}”(hXú#include #include static void walk_hash_elements(int map_fd) { struct key *cur_key = NULL; struct key next_key; struct value value; int err; for (;;) { err = bpf_map_get_next_key(map_fd, cur_key, &next_key); if (err) break; bpf_map_lookup_elem(map_fd, &next_key, &value); // Use key and value here cur_key = &next_key; } }”h]”hXú#include #include static void walk_hash_elements(int map_fd) { struct key *cur_key = NULL; struct key next_key; struct value value; int err; for (;;) { err = bpf_map_get_next_key(map_fd, cur_key, &next_key); if (err) break; bpf_map_lookup_elem(map_fd, &next_key, &value); // Use key and value here cur_key = &next_key; } }”…”�”}”hjqsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj‰jjj}”uh1jòh³hÇh´KÃhjøh²hubeh}”(h]”Œexamples”ah ]”h"]”Œexamples”ah$]”h&]”uh1hähhæh²hh³hÇh´KŽubhå)�”}”(hhh]”(hê)�”}”(hŒ Internals”h]”hŒ Internals”…”�”}”(hj‹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1héhjˆh²hh³hÇh´KÝubj )�”}”(hŒßThis section of the document is targeted at Linux developers and describes aspects of the map implementations that are not considered stable ABI. The following details are subject to change in future versions of the kernel.”h]”hŒßThis section of the document is targeted at Linux developers and describes aspects of the map implementations that are not considered stable ABI. The following details are subject to change in future versions of the kernel.”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kßhjˆh²hubhå)�”}”(hhh]”(hê)�”}”(hŒ&``BPF_MAP_TYPE_LRU_HASH`` and variants”h]”(j)�”}”(hŒ``BPF_MAP_TYPE_LRU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_HASH”…”�”}”(hj®h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjªubhŒ and variants”…”�”}”(hjªh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1héhj§h²hh³hÇh´Käubj )�”}”(hXUpdating elements in LRU maps may trigger eviction behaviour when the capacity of the map is reached. There are various steps that the update algorithm attempts in order to enforce the LRU property which have increasing impacts on other CPUs involved in the following operation attempts:”h]”hXUpdating elements in LRU maps may trigger eviction behaviour when the capacity of the map is reached. There are various steps that the update algorithm attempts in order to enforce the LRU property which have increasing impacts on other CPUs involved in the following operation attempts:”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kæhj§h²hubj)�”}”(hhh]”(j)�”}”(hŒ2Attempt to use CPU-local state to batch operations”h]”j )�”}”(hjÙh]”hŒ2Attempt to use CPU-local state to batch operations”…”�”}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Këhj×ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÔh²hh³hÇh´Nubj)�”}”(hŒ=Attempt to fetch ``target_free`` free nodes from global lists”h]”j )�”}”(hjðh]”(hŒAttempt to fetch ”…”�”}”(hjòh²hh³Nh´Nubj)�”}”(hŒ``target_free``”h]”hŒ target_free”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjòubhŒ free nodes from global lists”…”�”}”(hjòh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kìhjîubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÔh²hh³hÇh´Nubj)�”}”(hŒJAttempt to pull any node from a global list and remove it from the hashmap”h]”j )�”}”(hj h]”hŒJAttempt to pull any node from a global list and remove it from the hashmap”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kíhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÔh²hh³hÇh´Nubj)�”}”(hŒLAttempt to pull any node from any CPU's list and remove it from the hashmap ”h]”j )�”}”(hŒKAttempt to pull any node from any CPU's list and remove it from the hashmap”h]”hŒMAttempt to pull any node from any CPU’s list and remove it from the hashmap”…”�”}”(hj2 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kîhj. ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÔh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j–j—uh1hÿh³hÇh´Këhj§h²hubj )�”}”(hXˆThe number of nodes to borrow from the global list in a batch, ``target_free``, depends on the size of the map. Larger batch size reduces lock contention, but may also exhaust the global structure. The value is computed at map init to avoid exhaustion, by limiting aggregate reservation by all CPUs to half the map size. With a minimum of a single element and maximum budget of 128 at a time.”h]”(hŒ?The number of nodes to borrow from the global list in a batch, ”…”�”}”(hjL h²hh³Nh´Nubj)�”}”(hŒ``target_free``”h]”hŒ target_free”…”�”}”(hjT h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjL ubhX:, depends on the size of the map. Larger batch size reduces lock contention, but may also exhaust the global structure. The value is computed at map init to avoid exhaustion, by limiting aggregate reservation by all CPUs to half the map size. With a minimum of a single element and maximum budget of 128 at a time.”…”�”}”(hjL h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Kðhj§h²hubj )�”}”(hŒ³This algorithm is described visually in the following diagram. See the description in commit 3a08c2fd7634 ("bpf: LRU List") for a full explanation of the corresponding operations:”h]”hŒ·This algorithm is described visually in the following diagram. See the description in commit 3a08c2fd7634 (“bpf: LRU Listâ€�) for a full explanation of the corresponding operations:”…”�”}”(hjl h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Köhj§h²hubŒkfigure”Œ kernel_figure”“”)�”}”(hhh]”hŒfigure”“”)�”}”(hhh]”(hŒimage”“”)�”}”(hX.. kernel-figure:: map_lru_hash_update.dot :alt: Diagram outlining the LRU eviction steps taken during map update. LRU hash eviction during map update for ``BPF_MAP_TYPE_LRU_HASH`` and variants. See the dot file source for kernel function name code references. ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œalt”ŒADiagram outlining the LRU eviction steps taken during map update.”Œuri”Œbpf/map_lru_hash_update.dot”Œ candidates”}”Œ*”j” suh1j… hj‚ h³hÇh´KubhŒcaption”“”)�”}”(hŒ‘LRU hash eviction during map update for ``BPF_MAP_TYPE_LRU_HASH`` and variants. See the dot file source for kernel function name code references.”h]”(hŒ(LRU hash eviction during map update for ”…”�”}”(hjš h²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_LRU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_HASH”…”�”}”(hj¢ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjš ubhŒP and variants. See the dot file source for kernel function name code references.”…”�”}”(hjš h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j˜ h³hÇh´Kýhj‚ ubeh}”(h]”Œid1”ah ]”h"]”h$]”h&]”uh1j€ hj} ubah}”(h]”h ]”h"]”h$]”h&]”uh1j{ hj§h²hh³hÇh´Nubj )�”}”(hXÀMap updates start from the oval in the top right "begin ``bpf_map_update()``" and progress through the graph towards the bottom where the result may be either a successful update or a failure with various error codes. The key in the top right provides indicators for which locks may be involved in specific operations. This is intended as a visual hint for reasoning about how map contention may impact update operations, though the map type and flags may impact the actual contention on those locks, based on the logic described in the table above. For instance, if the map is created with type ``BPF_MAP_TYPE_LRU_PERCPU_HASH`` and flags ``BPF_F_NO_COMMON_LRU`` then all map properties would be per-cpu.”h]”(hŒ:Map updates start from the oval in the top right “begin ”…”�”}”(hjÇ h²hh³Nh´Nubj)�”}”(hŒ``bpf_map_update()``”h]”hŒbpf_map_update()”…”�”}”(hjÏ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÇ ubhX â€� and progress through the graph towards the bottom where the result may be either a successful update or a failure with various error codes. The key in the top right provides indicators for which locks may be involved in specific operations. This is intended as a visual hint for reasoning about how map contention may impact update operations, though the map type and flags may impact the actual contention on those locks, based on the logic described in the table above. For instance, if the map is created with type ”…”�”}”(hjÇ h²hh³Nh´Nubj)�”}”(hŒ ``BPF_MAP_TYPE_LRU_PERCPU_HASH``”h]”hŒBPF_MAP_TYPE_LRU_PERCPU_HASH”…”�”}”(hjá h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÇ ubhŒ and flags ”…”�”}”(hjÇ h²hh³Nh´Nubj)�”}”(hŒ``BPF_F_NO_COMMON_LRU``”h]”hŒBPF_F_NO_COMMON_LRU”…”�”}”(hjó h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÇ ubhŒ* then all map properties would be per-cpu.”…”�”}”(hjÇ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j h³hÇh´Mhj§h²hubeh}”(h]”Œ"bpf-map-type-lru-hash-and-variants”ah ]”h"]”Œ"bpf_map_type_lru_hash and variants”ah$]”h&]”uh1hähjˆh²hh³hÇh´Käubeh}”(h]”Œ internals”ah ]”h"]”Œ internals”ah$]”h&]”uh1hähhæh²hh³hÇh´KÝubeh}”(h]”Œ.bpf-map-type-hash-with-percpu-and-lru-variants”ah ]”h"]”Œ/bpf_map_type_hash, with percpu and lru variants”ah$]”h&]”uh1hähhh²hh³hÇh´Kubeh}”(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”j’Œ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”jE Œ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”}”Œnameids”}”(j j jõjòj�j�jÔjÑj@j=jˆj…j�jŒj‡j„jìjéjíjêjåjâj…j‚j j j j uŒ nametypes”}”(j ‰jõ‰j�‰jÔ‰j@‰jˆ‰j�‰j‡‰jì‰jí‰jå‰j…‰j ‰j ‰uh}”(j hæjòj¿j�jÐjÑjáj=j×j…jCjŒj“j„jújéj’jêjïjâjj‚jøj jˆj j§j¼ 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”“”}”jS Ks…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.