Skip to content

Commit 69ff403

Browse files
Hou TaoAlexei Starovoitov
authored andcommitted
selftests/bpf: Remove tests for zeroed-array kptr
bpf_mem_alloc() doesn't support zero-sized allocation, so removing these tests from test_bpf_ma test. After the removal, there will no definition for bin_data_8, so remove 8 from data_sizes array and adjust the index of data_btf_ids array in all test cases accordingly. Signed-off-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 7ac5c53 commit 69ff403

File tree

1 file changed

+49
-51
lines changed

1 file changed

+49
-51
lines changed

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

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct generic_map_value {
1717

1818
char _license[] SEC("license") = "GPL";
1919

20-
const unsigned int data_sizes[] = {8, 16, 32, 64, 96, 128, 192, 256, 512, 1024, 2048, 4096};
20+
const unsigned int data_sizes[] = {16, 32, 64, 96, 128, 192, 256, 512, 1024, 2048, 4096};
2121
const volatile unsigned int data_btf_ids[ARRAY_SIZE(data_sizes)] = {};
2222

2323
int err = 0;
@@ -166,7 +166,7 @@ static __always_inline void batch_percpu_free(struct bpf_map *map, unsigned int
166166
batch_percpu_free((struct bpf_map *)(&array_percpu_##size), batch, idx); \
167167
} while (0)
168168

169-
DEFINE_ARRAY_WITH_KPTR(8);
169+
/* kptr doesn't support bin_data_8 which is a zero-sized array */
170170
DEFINE_ARRAY_WITH_KPTR(16);
171171
DEFINE_ARRAY_WITH_KPTR(32);
172172
DEFINE_ARRAY_WITH_KPTR(64);
@@ -198,21 +198,20 @@ int test_batch_alloc_free(void *ctx)
198198
if ((u32)bpf_get_current_pid_tgid() != pid)
199199
return 0;
200200

201-
/* Alloc 128 8-bytes objects in batch to trigger refilling,
202-
* then free 128 8-bytes objects in batch to trigger freeing.
201+
/* Alloc 128 16-bytes objects in batch to trigger refilling,
202+
* then free 128 16-bytes objects in batch to trigger freeing.
203203
*/
204-
CALL_BATCH_ALLOC_FREE(8, 128, 0);
205-
CALL_BATCH_ALLOC_FREE(16, 128, 1);
206-
CALL_BATCH_ALLOC_FREE(32, 128, 2);
207-
CALL_BATCH_ALLOC_FREE(64, 128, 3);
208-
CALL_BATCH_ALLOC_FREE(96, 128, 4);
209-
CALL_BATCH_ALLOC_FREE(128, 128, 5);
210-
CALL_BATCH_ALLOC_FREE(192, 128, 6);
211-
CALL_BATCH_ALLOC_FREE(256, 128, 7);
212-
CALL_BATCH_ALLOC_FREE(512, 64, 8);
213-
CALL_BATCH_ALLOC_FREE(1024, 32, 9);
214-
CALL_BATCH_ALLOC_FREE(2048, 16, 10);
215-
CALL_BATCH_ALLOC_FREE(4096, 8, 11);
204+
CALL_BATCH_ALLOC_FREE(16, 128, 0);
205+
CALL_BATCH_ALLOC_FREE(32, 128, 1);
206+
CALL_BATCH_ALLOC_FREE(64, 128, 2);
207+
CALL_BATCH_ALLOC_FREE(96, 128, 3);
208+
CALL_BATCH_ALLOC_FREE(128, 128, 4);
209+
CALL_BATCH_ALLOC_FREE(192, 128, 5);
210+
CALL_BATCH_ALLOC_FREE(256, 128, 6);
211+
CALL_BATCH_ALLOC_FREE(512, 64, 7);
212+
CALL_BATCH_ALLOC_FREE(1024, 32, 8);
213+
CALL_BATCH_ALLOC_FREE(2048, 16, 9);
214+
CALL_BATCH_ALLOC_FREE(4096, 8, 10);
216215

217216
return 0;
218217
}
@@ -223,21 +222,20 @@ int test_free_through_map_free(void *ctx)
223222
if ((u32)bpf_get_current_pid_tgid() != pid)
224223
return 0;
225224

226-
/* Alloc 128 8-bytes objects in batch to trigger refilling,
225+
/* Alloc 128 16-bytes objects in batch to trigger refilling,
227226
* then free these objects through map free.
228227
*/
229-
CALL_BATCH_ALLOC(8, 128, 0);
230-
CALL_BATCH_ALLOC(16, 128, 1);
231-
CALL_BATCH_ALLOC(32, 128, 2);
232-
CALL_BATCH_ALLOC(64, 128, 3);
233-
CALL_BATCH_ALLOC(96, 128, 4);
234-
CALL_BATCH_ALLOC(128, 128, 5);
235-
CALL_BATCH_ALLOC(192, 128, 6);
236-
CALL_BATCH_ALLOC(256, 128, 7);
237-
CALL_BATCH_ALLOC(512, 64, 8);
238-
CALL_BATCH_ALLOC(1024, 32, 9);
239-
CALL_BATCH_ALLOC(2048, 16, 10);
240-
CALL_BATCH_ALLOC(4096, 8, 11);
228+
CALL_BATCH_ALLOC(16, 128, 0);
229+
CALL_BATCH_ALLOC(32, 128, 1);
230+
CALL_BATCH_ALLOC(64, 128, 2);
231+
CALL_BATCH_ALLOC(96, 128, 3);
232+
CALL_BATCH_ALLOC(128, 128, 4);
233+
CALL_BATCH_ALLOC(192, 128, 5);
234+
CALL_BATCH_ALLOC(256, 128, 6);
235+
CALL_BATCH_ALLOC(512, 64, 7);
236+
CALL_BATCH_ALLOC(1024, 32, 8);
237+
CALL_BATCH_ALLOC(2048, 16, 9);
238+
CALL_BATCH_ALLOC(4096, 8, 10);
241239

242240
return 0;
243241
}
@@ -251,17 +249,17 @@ int test_batch_percpu_alloc_free(void *ctx)
251249
/* Alloc 128 16-bytes per-cpu objects in batch to trigger refilling,
252250
* then free 128 16-bytes per-cpu objects in batch to trigger freeing.
253251
*/
254-
CALL_BATCH_PERCPU_ALLOC_FREE(16, 128, 1);
255-
CALL_BATCH_PERCPU_ALLOC_FREE(32, 128, 2);
256-
CALL_BATCH_PERCPU_ALLOC_FREE(64, 128, 3);
257-
CALL_BATCH_PERCPU_ALLOC_FREE(96, 128, 4);
258-
CALL_BATCH_PERCPU_ALLOC_FREE(128, 128, 5);
259-
CALL_BATCH_PERCPU_ALLOC_FREE(192, 128, 6);
260-
CALL_BATCH_PERCPU_ALLOC_FREE(256, 128, 7);
261-
CALL_BATCH_PERCPU_ALLOC_FREE(512, 64, 8);
262-
CALL_BATCH_PERCPU_ALLOC_FREE(1024, 32, 9);
263-
CALL_BATCH_PERCPU_ALLOC_FREE(2048, 16, 10);
264-
CALL_BATCH_PERCPU_ALLOC_FREE(4096, 8, 11);
252+
CALL_BATCH_PERCPU_ALLOC_FREE(16, 128, 0);
253+
CALL_BATCH_PERCPU_ALLOC_FREE(32, 128, 1);
254+
CALL_BATCH_PERCPU_ALLOC_FREE(64, 128, 2);
255+
CALL_BATCH_PERCPU_ALLOC_FREE(96, 128, 3);
256+
CALL_BATCH_PERCPU_ALLOC_FREE(128, 128, 4);
257+
CALL_BATCH_PERCPU_ALLOC_FREE(192, 128, 5);
258+
CALL_BATCH_PERCPU_ALLOC_FREE(256, 128, 6);
259+
CALL_BATCH_PERCPU_ALLOC_FREE(512, 64, 7);
260+
CALL_BATCH_PERCPU_ALLOC_FREE(1024, 32, 8);
261+
CALL_BATCH_PERCPU_ALLOC_FREE(2048, 16, 9);
262+
CALL_BATCH_PERCPU_ALLOC_FREE(4096, 8, 10);
265263

266264
return 0;
267265
}
@@ -275,17 +273,17 @@ int test_percpu_free_through_map_free(void *ctx)
275273
/* Alloc 128 16-bytes per-cpu objects in batch to trigger refilling,
276274
* then free these object through map free.
277275
*/
278-
CALL_BATCH_PERCPU_ALLOC(16, 128, 1);
279-
CALL_BATCH_PERCPU_ALLOC(32, 128, 2);
280-
CALL_BATCH_PERCPU_ALLOC(64, 128, 3);
281-
CALL_BATCH_PERCPU_ALLOC(96, 128, 4);
282-
CALL_BATCH_PERCPU_ALLOC(128, 128, 5);
283-
CALL_BATCH_PERCPU_ALLOC(192, 128, 6);
284-
CALL_BATCH_PERCPU_ALLOC(256, 128, 7);
285-
CALL_BATCH_PERCPU_ALLOC(512, 64, 8);
286-
CALL_BATCH_PERCPU_ALLOC(1024, 32, 9);
287-
CALL_BATCH_PERCPU_ALLOC(2048, 16, 10);
288-
CALL_BATCH_PERCPU_ALLOC(4096, 8, 11);
276+
CALL_BATCH_PERCPU_ALLOC(16, 128, 0);
277+
CALL_BATCH_PERCPU_ALLOC(32, 128, 1);
278+
CALL_BATCH_PERCPU_ALLOC(64, 128, 2);
279+
CALL_BATCH_PERCPU_ALLOC(96, 128, 3);
280+
CALL_BATCH_PERCPU_ALLOC(128, 128, 4);
281+
CALL_BATCH_PERCPU_ALLOC(192, 128, 5);
282+
CALL_BATCH_PERCPU_ALLOC(256, 128, 6);
283+
CALL_BATCH_PERCPU_ALLOC(512, 64, 7);
284+
CALL_BATCH_PERCPU_ALLOC(1024, 32, 8);
285+
CALL_BATCH_PERCPU_ALLOC(2048, 16, 9);
286+
CALL_BATCH_PERCPU_ALLOC(4096, 8, 10);
289287

290288
return 0;
291289
}

0 commit comments

Comments
 (0)