Skip to contentSkip to conversation

test_bpf: add a schedule point

PATCH Applied Eric Dumazet 3 participants 7 messages Feb 26, 2018 – Feb 28, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test_bpf: add a schedule point

From: Eric Dumazet <[email protected]>

test_bpf() is taking 1.6 seconds nowadays, it is time to add a schedule point in it.

---
 lib/test_bpf.c |    2 ++

 1 file changed, 2 insertions(+)
lib/test_bpf.c +2 -0
index b4e22345963f339ffe05c974bc111ae7da9dc58f..e6f550608d7220f434b45828549d36820923a51d 100644
@@ -24,6 +24,7 @@
 #include <linux/if_vlan.h>
 #include <linux/random.h>
 #include <linux/highmem.h>
+#include <linux/sched.h>
 
 /* General test specific settings */
 #define MAX_SUBTESTS	3
@@ -6582,6 +6583,7 @@ static __init int test_bpf(void)
 		struct bpf_prog *fp;
 		int err;
 
+		cond_resched();
 		if (exclude_test(i))
 			continue;
 
#2 lore raw
Quoted 9 lines · Daniel Borkmann
Quoted 6 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

test_bpf() is taking 1.6 seconds nowadays, it is time to add a schedule point in it.

Applied to bpf tree, thanks Eric!

Thanks Daniel

Note that some BPF programs are quite expensive

[  173.447471] test_bpf: #264 BPF_MAXINSNS: Call heavy transformations jited:1 19248 18548 PASS jited:1 12519 PASS
[  173.509228] test_bpf: #269 BPF_MAXINSNS: ld_abs+get_processor_id jited:1 20896 PASS

So we can still consume ~200 ms per test, without cond_resched()

Maybe reducing MAX_TESTRUNS from 10000 to 1000 would be the next step ?

#3 lore raw
Quoted 15 lines · Eric Dumazet
Quoted 9 lines · Daniel Borkmann
Quoted 6 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

test_bpf() is taking 1.6 seconds nowadays, it is time to add a schedule point in it.

Applied to bpf tree, thanks Eric!

Thanks Daniel

Note that some BPF programs are quite expensive

Quoted 7 lines

[  173.447471] test_bpf: #264 BPF_MAXINSNS: Call heavy transformations jited:1 19248 18548 PASS jited:1 12519 PASS
[  173.509228] test_bpf: #269 BPF_MAXINSNS: ld_abs+get_processor_id jited:1 20896 PASS

So we can still consume ~200 ms per test, without cond_resched()

Maybe reducing MAX_TESTRUNS from 10000 to 1000 would be the next step ?

Yeah, that's totally fine with me, please feel free to send a patch. Another step on todo is to reduce the test cases from test_bpf and move them into the test_verifier's run-time testing where applicable. Would be nice if at some point we can get rid of test_bpf and have everything consolidated within test_verifier.

#4 lore raw

PATCH 1/1 test_bpf: reduce MAX_TESTRUNS

In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>

For tests that are using the maximal number of BPF instruction, each run takes 20 usec. Looping 10,000 times on them totals 200 ms, which is bad when the loop is not preemptible.

test_bpf: #264 BPF_MAXINSNS: Call heavy transformations jited:1 19248 18548 PASS
test_bpf: #269 BPF_MAXINSNS: ld_abs+get_processor_id jited:1 20896 PASS

Lets divide by ten the number of iterations, so that max latency is 20ms. We could use need_resched() to break the loop earlier if we believe 20 ms is too much.

---
 lib/test_bpf.c |    2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_bpf.c +1 -1
index b4e22345963f339ffe05c974bc111ae7da9dc58f..d8dc618b223bb5168b0c7e9d9f4316eef3fbfa34 100644
@@ -27,7 +27,7 @@
 
 /* General test specific settings */
 #define MAX_SUBTESTS	3
-#define MAX_TESTRUNS	10000
+#define MAX_TESTRUNS	1000
 #define MAX_DATA	128
 #define MAX_INSNS	512
 #define MAX_K		0xffffFFFF
#5 lore raw

Re: [PATCH net] test_bpf: reduce MAX_TESTRUNS

Quoted 10 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

For tests that are using the maximal number of BPF instruction, each run takes 20 usec. Looping 10,000 times on them totals 200 ms, which is bad when the loop is not preemptible.

test_bpf: #264 BPF_MAXINSNS: Call heavy transformations jited:1 19248 18548 PASS
test_bpf: #269 BPF_MAXINSNS: ld_abs+get_processor_id jited:1 20896 PASS

Quoted 5 lines

Lets divide by ten the number of iterations, so that max latency is 20ms. We could use need_resched() to break the loop earlier if we believe 20 ms is too much.

Applied to bpf tree, thanks Eric!

maintainer Acked-by on v1 1/1
#6 lore raw

Re: [PATCH net] test_bpf: reduce MAX_TESTRUNS

In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Wed, 28 Feb 2018 08:39:20 -0800

Quoted 10 lines

From: Eric Dumazet <[email protected]>

For tests that are using the maximal number of BPF instruction, each run takes 20 usec. Looping 10,000 times on them totals 200 ms, which is bad when the loop is not preemptible.

test_bpf: #264 BPF_MAXINSNS: Call heavy transformations jited:1 19248 18548 PASS
test_bpf: #269 BPF_MAXINSNS: ld_abs+get_processor_id jited:1 20896 PASS

Quoted 5 lines

Lets divide by ten the number of iterations, so that max latency is 20ms. We could use need_resched() to break the loop earlier if we believe 20 ms is too much.