From: Yonghong Song <yonghong.song@linux.dev>
To: Leon Hwang <leon.hwang@linux.dev>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
toke@redhat.com, martin.lau@kernel.org, eddyz87@gmail.com,
wutengda@huaweicloud.com, kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf-next v2 2/2] selftests/bpf: Add testcase for updating attached freplace prog to prog_array map
Date: Fri, 26 Jul 2024 20:39:39 -0700 [thread overview]
Message-ID: <92454234-b3fe-4910-88c6-9369de1b392b@linux.dev> (raw)
In-Reply-To: <7a835744-055c-48e3-8592-c0208a7a63e0@linux.dev>
On 7/26/24 8:28 PM, Leon Hwang wrote:
>
> On 2024/7/27 03:38, Yonghong Song wrote:
>> On 7/26/24 8:39 AM, Leon Hwang wrote:
>>> Add a selftest to confirm the issue, which gets -EINVAL when update
>>> attached freplace prog to prog_array map, has been fixed.
>>>
>>> cd tools/testing/selftests/bpf; ./test_progs -t tailcalls
>>> 327/25 tailcalls/tailcall_freplace:OK
>>> 327 tailcalls:OK
>>> Summary: 1/25 PASSED, 0 SKIPPED, 0 FAILED
>>>
>>> Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
>> LGTM with some comments below.
>>
>> Acked-by: Yonghong Song <yonghong.song@linux.dev>
>>
>>> ---
>>> .../selftests/bpf/prog_tests/tailcalls.c | 65 ++++++++++++++++++-
>>> .../selftests/bpf/progs/tailcall_freplace.c | 25 +++++++
>>> .../testing/selftests/bpf/progs/tc_bpf2bpf.c | 21 ++++++
>>> 3 files changed, 110 insertions(+), 1 deletion(-)
>>> create mode 100644
>>> tools/testing/selftests/bpf/progs/tailcall_freplace.c
>>> create mode 100644 tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
>>>
> [...]
>
>>> diff --git a/tools/testing/selftests/bpf/progs/tailcall_freplace.c
>>> b/tools/testing/selftests/bpf/progs/tailcall_freplace.c
>>> new file mode 100644
>>> index 0000000000000..2966efc06ae8f
>>> --- /dev/null
>>> +++ b/tools/testing/selftests/bpf/progs/tailcall_freplace.c
>>> @@ -0,0 +1,25 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +
>>> +#include <linux/bpf.h>
>>> +#include <bpf/bpf_helpers.h>
>>> +
>>> +struct {
>>> + __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
>>> + __uint(max_entries, 1);
>>> + __uint(key_size, sizeof(__u32));
>>> + __uint(value_size, sizeof(__u32));
>>> +} jmp_table SEC(".maps");
>>> +
>>> +int count = 0;
>>> +
>>> +SEC("freplace")
>>> +int entry_freplace(struct __sk_buff *skb)
>>> +{
>>> + count++;
>>> +
>> remove empty line here.
>>> + bpf_tail_call_static(skb, &jmp_table, 0);
>>> +
>> remove empty line here.
>>> + return count;
>>> +}
>>> +
>>> +char __license[] SEC("license") = "GPL";
>>> diff --git a/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
>>> b/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
>>> new file mode 100644
>>> index 0000000000000..980bb810b481c
>>> --- /dev/null
>>> +++ b/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
>>> @@ -0,0 +1,21 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +
>>> +#include <linux/bpf.h>
>>> +#include <bpf/bpf_helpers.h>
>>> +
>>> +__noinline
>>> +int subprog(struct __sk_buff *skb)
>>> +{
>>> + volatile int ret = 1;
>>> +
>> remove empty line here.
> Should we remove this empty line?
>
> ./scripts/checkpatch.pl:
>
> WARNING: Missing a blank line after declarations
> #158: FILE: tools/testing/selftests/bpf/progs/tc_bpf2bpf.c:11:
> + int ret = 1;
> + __sink(ret);
sorry, we should keep blank line between 'int ret = 1' and '__sink(ret)'.
>
>>> + asm volatile (""::"r+"(ret));
>> remove above 'volatile' key word and replace asm volatile with __sink(ret).
>>> + return ret;
>>> +}
>>> +
>>> +SEC("tc")
>>> +int entry_tc(struct __sk_buff *skb)
>>> +{
>>> + return subprog(skb);
>>> +}
>>> +
>>> +char __license[] SEC("license") = "GPL";
next prev parent reply other threads:[~2024-07-27 3:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 15:39 [PATCH bpf-next v2 0/2] bpf: Fix updating attached freplace prog to prog_array map Leon Hwang
2024-07-26 15:39 ` [PATCH bpf-next v2 1/2] " Leon Hwang
2024-07-26 19:34 ` Yonghong Song
2024-07-26 15:39 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add testcase for " Leon Hwang
2024-07-26 19:38 ` Yonghong Song
2024-07-27 3:28 ` Leon Hwang
2024-07-27 3:39 ` Yonghong Song [this message]
2024-07-26 19:26 ` [PATCH bpf-next v2 0/2] bpf: Fix " Yonghong Song
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=92454234-b3fe-4910-88c6-9369de1b392b@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-patches-bot@fb.com \
--cc=leon.hwang@linux.dev \
--cc=martin.lau@kernel.org \
--cc=toke@redhat.com \
--cc=wutengda@huaweicloud.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