Re: [PATCH bpf-next v2] selftests/bpf: Skip callback tests if jit is disabled in test_verifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux