Skip to content

bpf: support percpu ARRAY map

Ming Lei lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9bpf: prepare for moving map common stuff into one placekernel/bpf/Makefile kernel/bpf/bpf_map.h kernel/bpf/map.c+36 -10 replies
2/9bpf: array map: use pre-defined nop map functionkernel/bpf/arraymap.c+5 -141 reply
3/9bpf: introduce percpu verion of lookup/update in bpf_map_opsinclude/linux/bpf.h kernel/bpf/arraymap.c kernel/bpf/bpf_map.h +2 more+30 -00 replies
4/9bpf: add percpu version of lookup/update element helpersinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/core.c +2 more+68 -00 replies
5/9bpf: syscall: add percpu version of lookup/update eleminclude/uapi/linux/bpf.h kernel/bpf/syscall.c+41 -1014 replies
6/9bpf: arraymap: introduce BPF_MAP_TYPE_ARRAY_PERCPUinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/arraymap.c +2 more+135 -121 reply
7/9sample/bpf: introduces helpers for percpu array examplesamples/bpf/bpf_helpers.h samples/bpf/libbpf.c samples/bpf/libbpf.h+52 -00 replies
8/9sample/bpf: sockex1: user percpu array mapsamples/bpf/sockex1_kern.c samples/bpf/sockex1_user.c+20 -70 replies
9/9samples/bpf: test percpu array mapsamples/bpf/test_maps.c+110 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/9] bpf: support percpu ARRAY map

Hi,

In case of ARRAY map, the index of the array is used as key of the map, then inevitably the mapped element/value can be accessed from more than one CPU concurrently, so expensive atomic operations are often required in eBPF prog. And we can see these usages in tracex3, sockex1 and sockex3 in sample/bpf/ of kernel tree.

This patchset trys to introduce percpu ARRAY map to address the issue.

The 1st two patches prepares for supporting percpu map, and introduces one file to hold the map common functions.

The following 3 patches introdues percpu version of update/ lookup element in bpf_map_ops, bpf helpers and syscall, so that percpu value can be retrieved/updated from eBPF prog and syscall.

The 6th patch implements percpu array map.

The last 3 patches are changes in samples/bpf, and implements test for perpcu array and converts to percpu array in sockex1 exmaple.

 include/linux/bpf.h        |  10 ++++
 include/uapi/linux/bpf.h   |  10 ++++
 kernel/bpf/Makefile        |   2 +-
 kernel/bpf/arraymap.c      | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 kernel/bpf/bpf_map.h       |  15 ++++++
 kernel/bpf/core.c          |   2 +
 kernel/bpf/hashtab.c       |   4 ++
 kernel/bpf/helpers.c       |  53 +++++++++++++++++++++
 kernel/bpf/map.c           |  43 +++++++++++++++++
 kernel/bpf/syscall.c       |  48 +++++++++++++++----
 net/core/filter.c          |   4 ++
 samples/bpf/bpf_helpers.h  |   5 ++
 samples/bpf/libbpf.c       |  42 +++++++++++++++++
 samples/bpf/libbpf.h       |   5 ++
 samples/bpf/sockex1_kern.c |   7 +--
 samples/bpf/sockex1_user.c |  20 ++++++--
 samples/bpf/test_maps.c    | 110 +++++++++++++++++++++++++++++++++++++++++++
 17 files changed, 493 insertions(+), 40 deletions(-)

thanks,
Ming