|
29 | 29 | #include <trace/events/bpf_test_run.h> |
30 | 30 |
|
31 | 31 | struct bpf_test_timer { |
32 | | - enum { NO_PREEMPT, NO_MIGRATE } mode; |
33 | 32 | u32 i; |
34 | 33 | u64 time_start, time_spent; |
35 | 34 | }; |
36 | 35 |
|
37 | 36 | static void bpf_test_timer_enter(struct bpf_test_timer *t) |
38 | 37 | __acquires(rcu) |
39 | 38 | { |
40 | | - rcu_read_lock(); |
41 | | - if (t->mode == NO_PREEMPT) |
42 | | - preempt_disable(); |
43 | | - else |
44 | | - migrate_disable(); |
45 | | - |
| 39 | + rcu_read_lock_dont_migrate(); |
46 | 40 | t->time_start = ktime_get_ns(); |
47 | 41 | } |
48 | 42 |
|
49 | 43 | static void bpf_test_timer_leave(struct bpf_test_timer *t) |
50 | 44 | __releases(rcu) |
51 | 45 | { |
52 | 46 | t->time_start = 0; |
53 | | - |
54 | | - if (t->mode == NO_PREEMPT) |
55 | | - preempt_enable(); |
56 | | - else |
57 | | - migrate_enable(); |
58 | | - rcu_read_unlock(); |
| 47 | + rcu_read_unlock_migrate(); |
59 | 48 | } |
60 | 49 |
|
61 | 50 | static bool bpf_test_timer_continue(struct bpf_test_timer *t, int iterations, |
@@ -374,7 +363,7 @@ static int bpf_test_run_xdp_live(struct bpf_prog *prog, struct xdp_buff *ctx, |
374 | 363 |
|
375 | 364 | { |
376 | 365 | struct xdp_test_data xdp = { .batch_size = batch_size }; |
377 | | - struct bpf_test_timer t = { .mode = NO_MIGRATE }; |
| 366 | + struct bpf_test_timer t = {}; |
378 | 367 | int ret; |
379 | 368 |
|
380 | 369 | if (!repeat) |
@@ -404,7 +393,7 @@ static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, |
404 | 393 | struct bpf_prog_array_item item = {.prog = prog}; |
405 | 394 | struct bpf_run_ctx *old_ctx; |
406 | 395 | struct bpf_cg_run_ctx run_ctx; |
407 | | - struct bpf_test_timer t = { NO_MIGRATE }; |
| 396 | + struct bpf_test_timer t = {}; |
408 | 397 | enum bpf_cgroup_storage_type stype; |
409 | 398 | int ret; |
410 | 399 |
|
@@ -1377,7 +1366,7 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog *prog, |
1377 | 1366 | const union bpf_attr *kattr, |
1378 | 1367 | union bpf_attr __user *uattr) |
1379 | 1368 | { |
1380 | | - struct bpf_test_timer t = { NO_PREEMPT }; |
| 1369 | + struct bpf_test_timer t = {}; |
1381 | 1370 | u32 size = kattr->test.data_size_in; |
1382 | 1371 | struct bpf_flow_dissector ctx = {}; |
1383 | 1372 | u32 repeat = kattr->test.repeat; |
@@ -1445,7 +1434,7 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog *prog, |
1445 | 1434 | int bpf_prog_test_run_sk_lookup(struct bpf_prog *prog, const union bpf_attr *kattr, |
1446 | 1435 | union bpf_attr __user *uattr) |
1447 | 1436 | { |
1448 | | - struct bpf_test_timer t = { NO_PREEMPT }; |
| 1437 | + struct bpf_test_timer t = {}; |
1449 | 1438 | struct bpf_prog_array *progs = NULL; |
1450 | 1439 | struct bpf_sk_lookup_kern ctx = {}; |
1451 | 1440 | u32 repeat = kattr->test.repeat; |
|
0 commit comments