Skip to content

Enable non-atomic allocations in local storage

Joanne Koong 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 Latest2 patches 0 repliesApplied 2/2
  2. v21 patch 4 repliesSuperseded
  3. v11 patch 11 repliesSuperseded

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Enable non-atomic allocations in local storageinclude/linux/bpf_local_storage.h kernel/bpf/bpf_inode_storage.c kernel/bpf/bpf_local_storage.c +3 more+84 -410 repliesApplied
2/2selftests/bpf: Test for associating multiple elements with the local storagetools/testing/selftests/bpf/progs/local_storage.c+19 -00 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchKP SinghMartin KaFai Lau
1/2A-b A-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/2] Enable non-atomic allocations in local storage

From: Joanne Koong <[email protected]>

Currently, local storage memory can only be allocated atomically (GFP_ATOMIC). This restriction is too strict for sleepable bpf programs.

In this patchset, sleepable programs can allocate memory in local storage using GFP_KERNEL, while non-sleepable programs always default to GFP_ATOMIC.

v3 <- v2:
* Add extra case to local_storage.c selftest to test associating multiple elements with the local storage, which triggers a GFP_KERNEL allocation in local_storage_update().
* Cast gfp_t to __s32 in verifier to fix the sparse warnings

v2 <- v1:
* Allocate the memory before/after the raw_spin_lock_irqsave, depending on the gfp flags
* Rename mem_flags to gfp_flags
* Reword the comment "*mem_flags* is set by the bpf verifier" to "*gfp_flags* is a hidden argument provided by the verifier"
* Add a sentence to the commit message about existing local storage selftests covering both the GFP_ATOMIC and GFP_KERNEL paths in bpf_local_storage_update.

Joanne Koong (2):
bpf: Enable non-atomic allocations in local storage selftests/bpf: Test for associating multiple elements with the local
storage

 include/linux/bpf_local_storage.h             |  7 ++-
 kernel/bpf/bpf_inode_storage.c                |  9 +--
 kernel/bpf/bpf_local_storage.c                | 58 ++++++++++++-------
 kernel/bpf/bpf_task_storage.c                 | 10 ++--
 kernel/bpf/verifier.c                         | 20 +++++++
 net/core/bpf_sk_storage.c                     | 21 ++++---
 .../selftests/bpf/progs/local_storage.c       | 19 ++++++
 7 files changed, 103 insertions(+), 41 deletions(-)
Signature · 1 line
2.30.2