Skip to content

Commit 29ba732

Browse files
iamkafaidavem330
authored andcommitted
bpf: Add BPF_MAP_TYPE_LRU_HASH
Provide a LRU version of the existing BPF_MAP_TYPE_HASH. Signed-off-by: Martin KaFai Lau <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fd91de7 commit 29ba732

File tree

2 files changed

+260
-14
lines changed

2 files changed

+260
-14
lines changed

include/uapi/linux/bpf.h

+8
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ enum bpf_map_type {
8585
BPF_MAP_TYPE_PERCPU_ARRAY,
8686
BPF_MAP_TYPE_STACK_TRACE,
8787
BPF_MAP_TYPE_CGROUP_ARRAY,
88+
BPF_MAP_TYPE_LRU_HASH,
8889
};
8990

9091
enum bpf_prog_type {
@@ -106,6 +107,13 @@ enum bpf_prog_type {
106107
#define BPF_EXIST 2 /* update existing element */
107108

108109
#define BPF_F_NO_PREALLOC (1U << 0)
110+
/* Instead of having one common LRU list in the
111+
* BPF_MAP_TYPE_LRU_HASH map, use a percpu LRU list
112+
* which can scale and perform better.
113+
* Note, the LRU nodes (including free nodes) cannot be moved
114+
* across different LRU lists.
115+
*/
116+
#define BPF_F_NO_COMMON_LRU (1U << 1)
109117

110118
union bpf_attr {
111119
struct { /* anonymous struct used by BPF_MAP_CREATE command */

0 commit comments

Comments
 (0)