[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7ac36fbe-aa44-9311-320b-1e953c29a3c4@linuxfoundation.org>
Date: Thu, 7 Apr 2022 13:23:10 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Yuntao Wang <ytcoode@...il.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>
Cc: Martin KaFai Lau <kafai@...com>, Song Liu <songliubraving@...com>,
Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Shuah Khan <shuah@...nel.org>,
Hengqi Chen <hengqi.chen@...il.com>, netdev@...r.kernel.org,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org,
Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix return value checks in
perf_event_stackmap.c
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@...il.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@...uxfoundation.org>
thanks,
-- Shuah
Powered by blists - more mailing lists