From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Hou Tao <houtao@huaweicloud.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: Eduard Zingerman <eddyz87@gmail.com>,
John Fastabend <john.fastabend@gmail.com>,
Jiri Olsa <jolsa@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2] selftests/bpf: Skip callback tests if jit is disabled in test_verifier
Date: Fri, 12 Jan 2024 15:40:52 +0800 [thread overview]
Message-ID: <1930b1eb-afff-8509-e233-26c28e7622fd@loongson.cn> (raw)
In-Reply-To: <1e919c98-2fc4-bd03-df19-97c4e8a24649@huaweicloud.com>
On 01/12/2024 12:21 PM, Hou Tao wrote:
> Hi,
>
> On 1/12/2024 9:57 AM, Tiezhu Yang wrote:
>> If CONFIG_BPF_JIT_ALWAYS_ON is not set and bpf_jit_enable is 0, there
>> exist 6 failed tests.
...
>> +static bool is_jit_enabled(void)
>> +{
>> + const char *jit_sysctl = "/proc/sys/net/core/bpf_jit_enable";
>> + bool enabled = false;
>> + int sysctl_fd;
>> +
>> + sysctl_fd = open(jit_sysctl, 0, O_RDONLY);
>
> It should be open(jit_sysctl, O_RDONLY).
Yes, this function comes from test_progs.c, I think
it is better to move it to testing_helpers.c with
this change.
>> + if (sysctl_fd != -1) {
>> + char tmpc;
>> +
>> + if (read(sysctl_fd, &tmpc, sizeof(tmpc)) == 1)
>> + enabled = (tmpc != '0');
>> + close(sysctl_fd);
>> + }
>> +
>> + return enabled;
>> +}
>> +
>> static int null_terminated_insn_len(struct bpf_insn *seq, int max_len)
>> {
>> int i;
>> @@ -1662,6 +1691,16 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
>> goto close_fds;
>> }
>>
>> + if (!is_jit_enabled()) {
>
> Is it necessary to check whether jit is enabled or not each time ? Could
> we just check it only once just like unpriv_disabled does ?
Yes, it looks better, will modify the related code.
>> + for (i = 0; i < prog_len; i++, prog++) {
>
> Is it better to only check pseudo_func only when both fd_prog < 0 and
> saved_errno == EINVAL are true, so unnecessary check can be skipped ?
Yes, will do it like this:
if (fd_prog < 0 && saved_errno == EINVAL && jit_disabled)
Thanks,
Tiezhu
prev parent reply other threads:[~2024-01-12 7:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 1:57 Tiezhu Yang
2024-01-12 4:21 ` Hou Tao
2024-01-12 7:40 ` Tiezhu Yang [this message]
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=1930b1eb-afff-8509-e233-26c28e7622fd@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=houtao@huaweicloud.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®