Re: [PATCH bpf-next] test_bpf: add module parameter test_type
From: Johan Almbladh <johan.almbladh@anyfinetworks.com>
Date: 2021-10-01 13:53:31
Also in:
bpf, lkml
Hi Tiezhu, Your v2 is base64-encoded. Please use plain-text for patch submissions. On Thu, Sep 30, 2021 at 1:01 PM Tiezhu Yang [off-list ref] wrote:
After commit 9298e63eafea ("bpf/tests: Add exhaustive tests of ALU
operand magnitudes"), when modprobe test_bpf.ko with jit on mips64,
there exists segment fault due to fhe following reason:
test_bpf: #616 ALU64_MOV_X: all register value magnitudes jited:1
Break instruction in kernel code[#1]
It seems that the related jit implementations of some test cases
in test_bpf() have problems. At this moment, I do not care about
the segment fault while I just want to verify the test cases of
tail calls.Don't put too much effort into the current MIPS64 JIT. I have been working on a significant upgrade of the MIPS JIT, which adds MIPS32 support and full eBPF ISA support, among other things. All the new JIT tests in test_bpf.ko I submitted are essentially a side effect of that work. I am currently testing the new JIT on different setups, and I hope to be able to submit the patch set next week. A side note, as you seem to work at Loongson. It would be great if you could verify the CPU errata workarounds I implemented for Loongson-2F and 3, once I get the patch set out for review.
Based on the above background and motivation, add the following module parameter test_type to the test_bpf.ko: test_type=<string>: only the specified type will be run, the string can be "test_bpf", "test_tail_calls" or "test_skb_segment". This is useful to only test the corresponding test type when specify the valid test_type string.
I agree that it is good to be able to choose a particular test suite to run. There are also the test_id and test_range parameters. If we add a test suite selector, it would be nice if the test range/id selection applied to that test suite, instead of being ignored for all suites except test_bpf.
quoted hunk
Any invalid test type will result in -EINVAL being returned and no tests being run. If the test_type is not specified or specified as empty string, it does not change the current logic, all of the test cases will be run. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> --- lib/test_bpf.c | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-)diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 21ea1ab..9428fec 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c@@ -11866,6 +11866,9 @@ module_param(test_id, int, 0); static int test_range[2] = { 0, ARRAY_SIZE(tests) - 1 }; module_param_array(test_range, int, NULL, 0); +static char test_type[32]; +module_param_string(test_type, test_type, sizeof(test_type), 0); + static __init int find_test_index(const char *test_name) { int i;@@ -12518,24 +12521,39 @@ static int __init test_bpf_init(void) struct bpf_array *progs = NULL; int ret; - ret = prepare_bpf_tests(); - if (ret < 0) - return ret; + if (strlen(test_type) && + strcmp(test_type, "test_bpf") && + strcmp(test_type, "test_tail_calls") && + strcmp(test_type, "test_skb_segment")) { + pr_err("test_bpf: invalid test_type '%s' specified.\n", test_type); + return -EINVAL; + } + + if (!strlen(test_type) || !strcmp(test_type, "test_bpf")) { + ret = prepare_bpf_tests(); + if (ret < 0) + return ret; + + ret = test_bpf(); + destroy_bpf_tests(); + if (ret) + return ret; + } - ret = test_bpf(); - destroy_bpf_tests(); - if (ret) - return ret; + if (!strlen(test_type) || !strcmp(test_type, "test_tail_calls")) { + ret = prepare_tail_call_tests(&progs); + if (ret) + return ret; + ret = test_tail_calls(progs); + destroy_tail_call_tests(progs); + if (ret) + return ret; + } - ret = prepare_tail_call_tests(&progs); - if (ret) - return ret; - ret = test_tail_calls(progs); - destroy_tail_call_tests(progs); - if (ret) - return ret; + if (!strlen(test_type) || !strcmp(test_type, "test_skb_segment")) + return test_skb_segment(); - return test_skb_segment(); + return 0; } static void __exit test_bpf_exit(void) --2.1.0