[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1930b1eb-afff-8509-e233-26c28e7622fd@loongson.cn>
Date: Fri, 12 Jan 2024 15:40:52 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Hou Tao <houtao@...weicloud.com>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>
Cc: Eduard Zingerman <eddyz87@...il.com>,
John Fastabend <john.fastabend@...il.com>, Jiri Olsa <jolsa@...nel.org>,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v2] selftests/bpf: Skip callback tests if jit is
disabled in test_verifier
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
Powered by blists - more mailing lists