From: David Vernet <void@manifault.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, martin.lau@linux.dev, memxor@gmail.com,
yhs@fb.com, song@kernel.org, sdf@google.com,
john.fastabend@gmail.com, kpsingh@kernel.org, jolsa@kernel.org,
haoluo@google.com, tj@kernel.org, kernel-team@fb.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v7 3/3] bpf/selftests: Add selftests for new task kfuncs
Date: Fri, 18 Nov 2022 08:49:56 -0600 [thread overview]
Message-ID: <Y3eblFzToIh4hL8m@maniforge.lan> (raw)
In-Reply-To: <20221118022100.qqer2hzuaahcgrml@MacBook-Pro-5.local>
On Thu, Nov 17, 2022 at 06:21:00PM -0800, Alexei Starovoitov wrote:
[...]
> > +static inline int tasks_kfunc_map_insert(struct task_struct *p)
> > +{
> > + struct __tasks_kfunc_map_value local, *v;
> > + long status;
> > + struct task_struct *acquired, *old;
> > + s32 pid;
> > +
> > + status = bpf_probe_read_kernel(&pid, sizeof(pid), &p->pid);
> > + if (status)
> > + return status;
> > +
> > + local.task = NULL;
> > + status = bpf_map_update_elem(&__tasks_kfunc_map, &pid, &local, BPF_NOEXIST);
> > + if (status)
> > + return status;
> > +
> > + v = bpf_map_lookup_elem(&__tasks_kfunc_map, &pid);
> > + if (!v) {
> > + bpf_map_delete_elem(&__tasks_kfunc_map, &pid);
> > + return status;
>
> here it will return 0, but probably should be returning error?
Ah, yes this should be returning -ENOENT. Thanks for catching this.
[...]
> > +SEC("tp_btf/task_newtask")
> > +int BPF_PROG(task_kfunc_release_null, struct task_struct *task, u64 clone_flags)
> > +{
> > + struct __tasks_kfunc_map_value local, *v;
> > + long status;
> > + struct task_struct *acquired, *old;
> > + s32 pid;
> > +
> > + status = bpf_probe_read_kernel(&pid, sizeof(pid), &task->pid);
> > + if (status)
> > + return 0;
> > +
> > + local.task = NULL;
> > + status = bpf_map_update_elem(&__tasks_kfunc_map, &pid, &local, BPF_NOEXIST);
> > + if (status)
> > + return status;
> > +
> > + v = bpf_map_lookup_elem(&__tasks_kfunc_map, &pid);
> > + if (!v)
> > + return status;
>
> should be return error instead?
Yep, here as well.
I'll fix both of these in v8.
[...]
next prev parent reply other threads:[~2022-11-18 14:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 3:23 [PATCH bpf-next v7 0/3] Support storing struct task_struct objects as kptrs David Vernet
2022-11-17 3:24 ` [PATCH bpf-next v7 1/3] bpf: Allow trusted pointers to be passed to KF_TRUSTED_ARGS kfuncs David Vernet
2022-11-18 2:26 ` Alexei Starovoitov
2022-11-18 14:45 ` David Vernet
2022-11-18 16:45 ` David Vernet
2022-11-18 18:45 ` Alexei Starovoitov
2022-11-18 21:44 ` David Vernet
2022-11-19 4:13 ` Alexei Starovoitov
2022-11-19 5:14 ` David Vernet
2022-11-19 16:48 ` Alexei Starovoitov
2022-11-17 3:24 ` [PATCH bpf-next v7 2/3] bpf: Add kfuncs for storing struct task_struct * as a kptr David Vernet
2022-11-17 3:24 ` [PATCH bpf-next v7 3/3] bpf/selftests: Add selftests for new task kfuncs David Vernet
2022-11-18 2:21 ` Alexei Starovoitov
2022-11-18 14:49 ` David Vernet [this message]
2022-11-17 21:03 ` [PATCH bpf-next v7 0/3] Support storing struct task_struct objects as kptrs John Fastabend
2022-11-17 21:54 ` David Vernet
2022-11-17 22:36 ` John Fastabend
2022-11-18 1:41 ` David Vernet
2022-11-18 6:04 ` John Fastabend
2022-11-18 15:08 ` David Vernet
2022-11-18 18:31 ` Alexei Starovoitov
2022-11-19 6:09 ` John Fastabend
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y3eblFzToIh4hL8m@maniforge.lan \
--to=void@manifault.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=tj@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.