aboutsummaryrefslogtreecommitdiffstats
path: root/net/bpf/test_run.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bpf/test_run.c')
-rw-r--r--net/bpf/test_run.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index f4078830ea50..0c423b8cd75c 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -12,7 +12,7 @@
12#include <linux/sched/signal.h> 12#include <linux/sched/signal.h>
13 13
14static __always_inline u32 bpf_test_run_one(struct bpf_prog *prog, void *ctx, 14static __always_inline u32 bpf_test_run_one(struct bpf_prog *prog, void *ctx,
15 struct bpf_cgroup_storage *storage) 15 struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE])
16{ 16{
17 u32 ret; 17 u32 ret;
18 18
@@ -28,13 +28,20 @@ static __always_inline u32 bpf_test_run_one(struct bpf_prog *prog, void *ctx,
28 28
29static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *time) 29static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *time)
30{ 30{
31 struct bpf_cgroup_storage *storage = NULL; 31 struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = { 0 };
32 enum bpf_cgroup_storage_type stype;
32 u64 time_start, time_spent = 0; 33 u64 time_start, time_spent = 0;
33 u32 ret = 0, i; 34 u32 ret = 0, i;
34 35
35 storage = bpf_cgroup_storage_alloc(prog); 36 for_each_cgroup_storage_type(stype) {
36 if (IS_ERR(storage)) 37 storage[stype] = bpf_cgroup_storage_alloc(prog, stype);
37 return PTR_ERR(storage); 38 if (IS_ERR(storage[stype])) {
39 storage[stype] = NULL;
40 for_each_cgroup_storage_type(stype)
41 bpf_cgroup_storage_free(storage[stype]);
42 return -ENOMEM;
43 }
44 }
38 45
39 if (!repeat) 46 if (!repeat)
40 repeat = 1; 47 repeat = 1;
@@ -53,7 +60,8 @@ static u32 bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *time)
53 do_div(time_spent, repeat); 60 do_div(time_spent, repeat);
54 *time = time_spent > U32_MAX ? U32_MAX : (u32)time_spent; 61 *time = time_spent > U32_MAX ? U32_MAX : (u32)time_spent;
55 62
56 bpf_cgroup_storage_free(storage); 63 for_each_cgroup_storage_type(stype)
64 bpf_cgroup_storage_free(storage[stype]);
57 65
58 return ret; 66 return ret;
59} 67}