[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190703205100.142904-1-sdf@google.com>
Date: Wed, 3 Jul 2019 13:51:00 -0700
From: Stanislav Fomichev <sdf@...gle.com>
To: netdev@...r.kernel.org, bpf@...r.kernel.org
Cc: davem@...emloft.net, ast@...nel.org, daniel@...earbox.net,
Stanislav Fomichev <sdf@...gle.com>
Subject: [PATCH bpf-next] selftests/bpf: make verifier loop tests arch independent
Take the first x bytes of pt_regs for scalability tests, there is
no real reason we need x86 specific rax.
Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
---
tools/testing/selftests/bpf/progs/loop1.c | 3 ++-
tools/testing/selftests/bpf/progs/loop2.c | 3 ++-
tools/testing/selftests/bpf/progs/loop3.c | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/loop1.c b/tools/testing/selftests/bpf/progs/loop1.c
index dea395af9ea9..d530c61d2517 100644
--- a/tools/testing/selftests/bpf/progs/loop1.c
+++ b/tools/testing/selftests/bpf/progs/loop1.c
@@ -14,11 +14,12 @@ SEC("raw_tracepoint/kfree_skb")
int nested_loops(volatile struct pt_regs* ctx)
{
int i, j, sum = 0, m;
+ volatile int *any_reg = (volatile int *)ctx;
for (j = 0; j < 300; j++)
for (i = 0; i < j; i++) {
if (j & 1)
- m = ctx->rax;
+ m = *any_reg;
else
m = j;
sum += i * m;
diff --git a/tools/testing/selftests/bpf/progs/loop2.c b/tools/testing/selftests/bpf/progs/loop2.c
index 0637bd8e8bcf..91bb89d901e3 100644
--- a/tools/testing/selftests/bpf/progs/loop2.c
+++ b/tools/testing/selftests/bpf/progs/loop2.c
@@ -14,9 +14,10 @@ SEC("raw_tracepoint/consume_skb")
int while_true(volatile struct pt_regs* ctx)
{
int i = 0;
+ volatile int *any_reg = (volatile int *)ctx;
while (true) {
- if (ctx->rax & 1)
+ if (*any_reg & 1)
i += 3;
else
i += 7;
diff --git a/tools/testing/selftests/bpf/progs/loop3.c b/tools/testing/selftests/bpf/progs/loop3.c
index 30a0f6cba080..3a7f12d7186c 100644
--- a/tools/testing/selftests/bpf/progs/loop3.c
+++ b/tools/testing/selftests/bpf/progs/loop3.c
@@ -14,9 +14,10 @@ SEC("raw_tracepoint/consume_skb")
int while_true(volatile struct pt_regs* ctx)
{
__u64 i = 0, sum = 0;
+ volatile __u64 *any_reg = (volatile __u64 *)ctx;
do {
i++;
- sum += ctx->rax;
+ sum += *any_reg;
} while (i < 0x100000000ULL);
return sum;
}
--
2.22.0.410.gd8fdbe21b5-goog
Powered by blists - more mailing lists