[<prev] [next>] [day] [month] [year] [list]
Message-ID: <2af1fd4d.566a.17c3708821e.Coremail.kernelpatch@126.com>
Date: Thu, 30 Sep 2021 22:07:56 +0800 (CST)
From: "Tiezhu Yang" <kernelpatch@....com>
To: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org
Cc: kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org,
johan.almbladh@...finetworks.com, lixuefeng@...ngson.cn,
netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH bpf-next v2] test_bpf: add module parameter test_type
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
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 the 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.
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.
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@...ngson.cn>
---
v2:
-- Fix typo in the commit message
-- Use my private email to send
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
Powered by blists - more mailing lists