Skip to content

Commit e6ca4f1

Browse files
committed
Merge branch 'bpf-lru'
Martin KaFai Lau says: ==================== bpf: LRU map This patch set adds LRU map implementation to the existing BPF map family. The first few patches introduce the basic BPF LRU list implementation. The later patches introduce the LRU versions of the existing BPF_MAP_TYPE_LRU_[PERCPU_]HASH maps by leveraging the BPF LRU list. v2: - Added a percpu LRU list option which can be specified as a map attribute. [Note: percpu LRU list has nothing to do with the map's value] - Removed the cpu variable from the struct bpf_lru_locallist since it is not needed. - Changed the __bpf_lru_node_move_out to __bpf_lru_node_move_to_free in patch 1 to prepare the percpu LRU list in patch 2. - Moved the test_lru_map under selftests - Refactored a few things in the test codes ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents bb598c1 + 5db58fa commit e6ca4f1

File tree

12 files changed

+2386
-50
lines changed

12 files changed

+2386
-50
lines changed

include/uapi/linux/bpf.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ 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,
89+
BPF_MAP_TYPE_LRU_PERCPU_HASH,
8890
};
8991

9092
enum bpf_prog_type {
@@ -106,6 +108,13 @@ enum bpf_prog_type {
106108
#define BPF_EXIST 2 /* update existing element */
107109

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

110119
union bpf_attr {
111120
struct { /* anonymous struct used by BPF_MAP_CREATE command */

kernel/bpf/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
obj-y := core.o
22

33
obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o
4-
obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o
4+
obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o
55
ifeq ($(CONFIG_PERF_EVENTS),y)
66
obj-$(CONFIG_BPF_SYSCALL) += stackmap.o
77
endif

0 commit comments

Comments
 (0)