lkml.org 
[lkml]   [2023]   [Mar]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[PATCH bpf-next 0/3] Enable RCU semantics for task kptrs
Date
In commit 22df776a9a86 ("tasks: Extract rcu_users out of union"), the
'refcount_t rcu_users' field was extracted out of a union with the
'struct rcu_head rcu' field. This allows us to use the field for
refcounting struct task_struct with RCU protection, as the RCU callback
no longer flips rcu_users to be nonzero after the callback is scheduled.

This patch set leverages this to do a few things:

1. Marks struct task_struct as RCU safe in the verifier, allowing
referenced kptr tasks stored in maps to be accessed in an RCU
read region without acquiring a reference (with just a NULL check).
2. Makes bpf_task_acquire() a KF_ACQUIRE | KF_RCU | KF_RET_NULL kfunc.
3. Removes bpf_task_kptr_get() and bpf_task_acquire_not_zero(), as
they're now redundant with the above two changes.
4. Updates selftests and documentation accordingly.

David Vernet (3):
bpf: Make struct task_struct an RCU-safe type
bpf: Remove now-defunct task kfuncs
bpf,docs: Update documentation to reflect new task kfuncs

Documentation/bpf/kfuncs.rst | 49 ++++++-
kernel/bpf/helpers.c | 78 +----------
kernel/bpf/verifier.c | 1 +
.../selftests/bpf/prog_tests/task_kfunc.c | 4 +-
.../selftests/bpf/progs/rcu_read_lock.c | 9 +-
.../selftests/bpf/progs/task_kfunc_common.h | 6 +-
.../selftests/bpf/progs/task_kfunc_failure.c | 126 ++++++++----------
.../selftests/bpf/progs/task_kfunc_success.c | 76 +++++++++--
8 files changed, 174 insertions(+), 175 deletions(-)

--
2.39.0

\
 
 \ /
  Last update: 2023-03-31 02:59    [W:0.073 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site