Message ID | 20210223012014.2087583-1-songliubraving@fb.com |
---|---|
Headers | show |
Series | bpf: enable task local storage for tracing programs | expand |
On Mon, Feb 22, 2021 at 5:24 PM Song Liu <songliubraving@fb.com> wrote: > > Update the Makefile to prefer using $(O)/mvlinux, $(KBUILD_OUTPUT)/vmlinux > (for selftests) or ../../../vmlinux. These two files should have latest > definitions for vmlinux.h. > > Signed-off-by: Song Liu <songliubraving@fb.com> > --- Acked-by: Andrii Nakryiko <andrii@kernel.org> > tools/bpf/runqslower/Makefile | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile > index 9d9fb6209be1b..c96ba90c6f018 100644 > --- a/tools/bpf/runqslower/Makefile > +++ b/tools/bpf/runqslower/Makefile > @@ -16,7 +16,10 @@ CFLAGS := -g -Wall > > # Try to detect best kernel BTF source > KERNEL_REL := $(shell uname -r) > -VMLINUX_BTF_PATHS := /sys/kernel/btf/vmlinux /boot/vmlinux-$(KERNEL_REL) > +VMLINUX_BTF_PATHS := $(if $(O),$(O)/vmlinux) \ > + $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ > + ../../../vmlinux /sys/kernel/btf/vmlinux \ > + /boot/vmlinux-$(KERNEL_REL) > VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \ > $(wildcard $(VMLINUX_BTF_PATHS)))) > > -- > 2.24.1 >
On Mon, Feb 22, 2021 at 05:20:09PM -0800, Song Liu wrote: [ ... ] > diff --git a/kernel/bpf/bpf_task_storage.c b/kernel/bpf/bpf_task_storage.c > index e0da0258b732d..2034019966d44 100644 > --- a/kernel/bpf/bpf_task_storage.c > +++ b/kernel/bpf/bpf_task_storage.c > @@ -15,7 +15,6 @@ > #include <linux/bpf_local_storage.h> > #include <linux/filter.h> > #include <uapi/linux/btf.h> > -#include <linux/bpf_lsm.h> > #include <linux/btf_ids.h> > #include <linux/fdtable.h> > > @@ -24,12 +23,8 @@ DEFINE_BPF_STORAGE_CACHE(task_cache); > static struct bpf_local_storage __rcu **task_storage_ptr(void *owner) > { > struct task_struct *task = owner; > - struct bpf_storage_blob *bsb; > > - bsb = bpf_task(task); > - if (!bsb) > - return NULL; task_storage_ptr() no longer returns NULL. All "!task_storage_ptr(task)" checks should be removed also. e.g. In bpf_task_storage_get and bpf_pid_task_storage_update_elem. > - return &bsb->storage; > + return &task->bpf_storage; > } >
> On Feb 23, 2021, at 11:23 AM, Martin Lau <kafai@fb.com> wrote: > > On Mon, Feb 22, 2021 at 05:20:09PM -0800, Song Liu wrote: > [ ... ] > >> diff --git a/kernel/bpf/bpf_task_storage.c b/kernel/bpf/bpf_task_storage.c >> index e0da0258b732d..2034019966d44 100644 >> --- a/kernel/bpf/bpf_task_storage.c >> +++ b/kernel/bpf/bpf_task_storage.c >> @@ -15,7 +15,6 @@ >> #include <linux/bpf_local_storage.h> >> #include <linux/filter.h> >> #include <uapi/linux/btf.h> >> -#include <linux/bpf_lsm.h> >> #include <linux/btf_ids.h> >> #include <linux/fdtable.h> >> >> @@ -24,12 +23,8 @@ DEFINE_BPF_STORAGE_CACHE(task_cache); >> static struct bpf_local_storage __rcu **task_storage_ptr(void *owner) >> { >> struct task_struct *task = owner; >> - struct bpf_storage_blob *bsb; >> >> - bsb = bpf_task(task); >> - if (!bsb) >> - return NULL; > task_storage_ptr() no longer returns NULL. All "!task_storage_ptr(task)" > checks should be removed also. e.g. In bpf_task_storage_get > and bpf_pid_task_storage_update_elem. Good catch! Fixed it in v5. Thanks, Song > >> - return &bsb->storage; >> + return &task->bpf_storage; >> } >>
On Mon, Feb 22, 2021 at 05:20:13PM -0800, Song Liu wrote:
> Update the Makefile to prefer using $(O)/mvlinux, $(KBUILD_OUTPUT)/vmlinux
s/mvlinux/vmlinux/