BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/2] Enable non-atomic allocations in local storage
@ 2022-03-18  4:55 Joanne Koong
  2022-03-18  4:55 ` [PATCH bpf-next v3 1/2] bpf: " Joanne Koong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joanne Koong @ 2022-03-18  4:55 UTC (permalink / raw)
  To: bpf
  Cc: kafai, kpsingh, memxor, ast, daniel, andrii, tj, davemarchevsky,
	Joanne Koong

From: Joanne Koong <joannelkoong@gmail.com>

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-21  2:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-18  4:55 [PATCH bpf-next v3 0/2] Enable non-atomic allocations in local storage Joanne Koong
2022-03-18  4:55 ` [PATCH bpf-next v3 1/2] bpf: " Joanne Koong
2022-03-18  4:55 ` [PATCH bpf-next v3 2/2] selftests/bpf: Test for associating multiple elements with the " Joanne Koong
2022-03-21  2:00 ` [PATCH bpf-next v3 0/2] Enable non-atomic allocations in " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox