From: "Tiezhu Yang" <kernelpatch@126.com>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org
Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
john.fastabend@gmail.com, kpsingh@kernel.org,
johan.almbladh@anyfinetworks.com, lixuefeng@loongson.cn,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH bpf-next v2] test_bpf: add module parameter test_type
Date: Thu, 30 Sep 2021 22:07:56 +0800 (CST) [thread overview]
Message-ID: <2af1fd4d.566a.17c3708821e.Coremail.kernelpatch@126.com> (raw)
From: Tiezhu Yang <yangtiezhu@loongson.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@loongson.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
reply other threads:[~2021-09-30 14:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2af1fd4d.566a.17c3708821e.Coremail.kernelpatch@126.com \
--to=kernelpatch@126.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=johan.almbladh@anyfinetworks.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.