Skip to content

bpf: Use bpf_mem_cache_alloc/free in bpf_local_storage

Martin KaFai Lau bpf 3 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest5 patches 8 repliesApplied 5/5
  2. v217 patches 1 replySuperseded
  3. v116 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- Only use bpf_mem_alloc for task and cgrp storage.
- sk and inode storage stay with kzalloc/kfree.
- Check NULL and add comments in bpf_mem_cache_raw_free() in patch 1.
- Added test and benchmark for task storage.

Patches in v3 All 5 applied

#Subject and filesSizeRepliesApplied
1/5bpf: Add a few bpf mem allocator functionsinclude/linux/bpf_mem_alloc.h kernel/bpf/memalloc.c+52 -90 repliesApplied
2/5bpf: Use bpf_mem_cache_alloc/free in bpf_local_storage_eleminclude/linux/bpf_local_storage.h kernel/bpf/bpf_cgrp_storage.c kernel/bpf/bpf_inode_storage.c +3 more+95 -140 repliesApplied
3/5bpf: Use bpf_mem_cache_alloc/free for bpf_local_storageinclude/linux/bpf_local_storage.h kernel/bpf/bpf_local_storage.c+116 -150 repliesApplied
4/5selftests/bpf: Test task storage when local_storage->smap is NULLtools/testing/selftests/bpf/prog_tests/test_local_storage.c tools/testing/selftests/bpf/progs/local_storage.c+46 -170 repliesApplied
5/5selftests/bpf: Add bench for task storage creationtools/testing/selftests/bpf/bench.c tools/testing/selftests/bpf/benchs/bench_local_storage_create.c tools/testing/selftests/bpf/progs/bench_local_storage_create.c+164 -148 repliesApplied

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH v3 bpf-next 0/5] bpf: Use bpf_mem_cache_alloc/free in bpf_local_storage

From: Martin KaFai Lau <[email protected]>

This set is a continuation of the effort in using
bpf_mem_cache_alloc/free in bpf_local_storage [1]

Major change is only using bpf_mem_alloc for task and cgrp storage while sk and inode stay with kzalloc/kfree. The details is in patch 2.

[1]: https://lore.kernel.org/bpf/[email protected]/

v3:
- Only use bpf_mem_alloc for task and cgrp storage.
- sk and inode storage stay with kzalloc/kfree.
- Check NULL and add comments in bpf_mem_cache_raw_free() in patch 1.
- Added test and benchmark for task storage.

v2:
- Added bpf_mem_cache_alloc_flags() and bpf_mem_cache_raw_free() to hide the internal data structure of the bpf allocator.
- Fixed a typo bug in bpf_selem_free()
- Simplified the test_local_storage test by directly using err returned from libbpf

Martin KaFai Lau (5):
bpf: Add a few bpf mem allocator functions
bpf: Use bpf_mem_cache_alloc/free in bpf_local_storage_elem
bpf: Use bpf_mem_cache_alloc/free for bpf_local_storage selftests/bpf: Test task storage when local_storage->smap is NULL selftests/bpf: Add bench for task storage creation

 include/linux/bpf_local_storage.h             |   7 +-
 include/linux/bpf_mem_alloc.h                 |   2 +
 kernel/bpf/bpf_cgrp_storage.c                 |   2 +-
 kernel/bpf/bpf_inode_storage.c                |   2 +-
 kernel/bpf/bpf_local_storage.c                | 223 ++++++++++++++++--
 kernel/bpf/bpf_task_storage.c                 |   2 +-
 kernel/bpf/memalloc.c                         |  59 ++++-
 net/core/bpf_sk_storage.c                     |   2 +-
 tools/testing/selftests/bpf/bench.c           |   2 +
 .../bpf/benchs/bench_local_storage_create.c   | 151 ++++++++++--
 .../bpf/prog_tests/test_local_storage.c       |   7 +-
 .../bpf/progs/bench_local_storage_create.c    |  25 ++
 .../selftests/bpf/progs/local_storage.c       |  56 +++--
 13 files changed, 472 insertions(+), 68 deletions(-)
Signature · 1 line
2.34.1