From: Shuah Khan <skhan@linuxfoundation.org>
To: Yuntao Wang <ytcoode@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>, Shuah Khan <shuah@kernel.org>,
Hengqi Chen <hengqi.chen@gmail.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix return value checks in perf_event_stackmap.c
Date: Thu, 7 Apr 2022 13:23:10 -0600 [thread overview]
Message-ID: <7ac36fbe-aa44-9311-320b-1e953c29a3c4@linuxfoundation.org> (raw)
In-Reply-To: <20220407153814.104914-1-ytcoode@gmail.com>
On 4/7/22 9:38 AM, Yuntao Wang wrote:
> The bpf_get_stackid() function may also return 0 on success.
Can you add couple of sentences to describe what this patch
does? bpf_get_stackid() may also return doesn't really say
anything about why this patch is needed.
>
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> ---
> tools/testing/selftests/bpf/progs/perf_event_stackmap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c
> index b3fcb5274ee0..f793280a3238 100644
> --- a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c
> +++ b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c
> @@ -35,10 +35,10 @@ int oncpu(void *ctx)
> long val;
>
> val = bpf_get_stackid(ctx, &stackmap, 0);
> - if (val > 0)
> + if (val >= 0)
> stackid_kernel = 2;
> val = bpf_get_stackid(ctx, &stackmap, BPF_F_USER_STACK);
> - if (val > 0)
> + if (val >= 0)
> stackid_user = 2;
>
> trace = bpf_map_lookup_elem(&stackdata_map, &key);
>
Linux 5.18-rc1 shows a couple of more bpf_get_stackid() in this function.
Removed in bpf-next - I assume.
The change is good. I would like to see it explained better in the
commit log.
With the commit log fixed to explain why this change is needed and
what happens if val equals to 0 condition isn't checked:
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
next prev parent reply other threads:[~2022-04-07 19:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 15:38 [PATCH bpf-next] selftests/bpf: Fix return value checks in perf_event_stackmap.c Yuntao Wang
2022-04-07 19:23 ` Shuah Khan [this message]
2022-04-08 4:14 ` [PATCH bpf-next v2] " Yuntao Wang
2022-04-08 21:09 ` patchwork-bot+netdevbpf
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=7ac36fbe-aa44-9311-320b-1e953c29a3c4@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=hengqi.chen@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
--cc=ytcoode@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox