Lines Matching +full:cpu +full:- +full:map

1 .. SPDX-License-Identifier: GPL-2.0-only
3 .. Copyright (C) 2022-2023 Isovalent, Inc.
10 - ``BPF_MAP_TYPE_HASH`` was introduced in kernel version 3.19
11 - ``BPF_MAP_TYPE_PERCPU_HASH`` was introduced in version 4.6
12 - Both ``BPF_MAP_TYPE_LRU_HASH`` and ``BPF_MAP_TYPE_LRU_PERCPU_HASH``
16 purpose hash map storage. Both the key and the value can be structs,
20 to the max_entries limit that you specify. Hash maps use pre-allocation
22 used to disable pre-allocation when it is too memory expensive.
25 CPU. The per-cpu values are stored internally in an array.
32 shared across CPUs but it is possible to request a per CPU LRU list with
35 map type and the flags used to create the map.
40 **BPF_F_NO_COMMON_LRU** Per-CPU LRU, global map Per-CPU LRU, per-cpu map
41 **!BPF_F_NO_COMMON_LRU** Global LRU, global map Global LRU, per-cpu map
48 ----------
53 .. code-block:: c
55 long bpf_map_update_elem(struct bpf_map *map, const void *key, const void *value, u64 flags)
61 - ``BPF_ANY`` will create a new element or update an existing element
62 - ``BPF_NOEXIST`` will create a new element only if one did not already
64 - ``BPF_EXIST`` will update an existing element
72 .. code-block:: c
74 void *bpf_map_lookup_elem(struct bpf_map *map, const void *key)
83 .. code-block:: c
85 long bpf_map_delete_elem(struct bpf_map *map, const void *key)
91 Per CPU Hashes
92 --------------
96 automatically access the hash slot for the current CPU.
101 .. code-block:: c
103 void *bpf_map_lookup_percpu_elem(struct bpf_map *map, const void *key, u32 cpu)
106 value in the hash slot for a specific CPU. Returns value associated with
107 ``key`` on ``cpu`` , or ``NULL`` if no entry was found or ``cpu`` is
111 -----------
119 ---------
124 .. code-block:: c
132 current key. ``bpf_map_get_next_key()`` returns 0 on success, -ENOENT if
150 .. code-block:: c
174 .. code-block:: c
184 __sync_fetch_and_add(&value->packets, 1);
185 __sync_fetch_and_add(&value->bytes, bytes);
193 Userspace walking the map elements from the map declared above:
195 .. code-block:: c
224 aspects of the map implementations that are not considered stable ABI. The
228 --------------------------------------
231 of the map is reached. There are various steps that the update algorithm
235 - Attempt to use CPU-local state to batch operations
236 - Attempt to fetch free nodes from global lists
237 - Attempt to pull any node from a global list and remove it from the hashmap
238 - Attempt to pull any node from any CPU's list and remove it from the hashmap
244 .. kernel-figure:: map_lru_hash_update.dot
245 :alt: Diagram outlining the LRU eviction steps taken during map update.
247 LRU hash eviction during map update for ``BPF_MAP_TYPE_LRU_HASH`` and
250 Map updates start from the oval in the top right "begin ``bpf_map_update()``"
254 operations. This is intended as a visual hint for reasoning about how map
255 contention may impact update operations, though the map type and flags may
257 the table above. For instance, if the map is created with type
258 ``BPF_MAP_TYPE_LRU_PERCPU_HASH`` and flags ``BPF_F_NO_COMMON_LRU`` then all map
259 properties would be per-cpu.