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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Joanne Koong <joannelkoong@xxxxxxxxx>

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(-)

-- 
2.30.2





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux