Skip to content

Commit adc8c45

Browse files
Yonghong SongAlexei Starovoitov
authored andcommitted
selftests/bpf: Add a selftest with > 512-byte percpu allocation size
Add a selftest to capture the verification failure when the allocation size is greater than 512. Acked-by: Hou Tao <[email protected]> Signed-off-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 21f5a80 commit adc8c45

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tools/testing/selftests/bpf/progs/percpu_alloc_fail.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ struct val_with_rb_root_t {
1717
struct bpf_spin_lock lock;
1818
};
1919

20+
struct val_600b_t {
21+
char b[600];
22+
};
23+
2024
struct elem {
2125
long sum;
2226
struct val_t __percpu_kptr *pc;
@@ -161,4 +165,18 @@ int BPF_PROG(test_array_map_7)
161165
return 0;
162166
}
163167

168+
SEC("?fentry.s/bpf_fentry_test1")
169+
__failure __msg("bpf_percpu_obj_new type size (600) is greater than 512")
170+
int BPF_PROG(test_array_map_8)
171+
{
172+
struct val_600b_t __percpu_kptr *p;
173+
174+
p = bpf_percpu_obj_new(struct val_600b_t);
175+
if (!p)
176+
return 0;
177+
178+
bpf_percpu_obj_drop(p);
179+
return 0;
180+
}
181+
164182
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)