mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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 <houtao1@huawei.com> Link: https://lore.kernel.org/r/20231216131052.27621-3-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
7ac5c53e00
commit
69ff403d87
1 changed files with 49 additions and 51 deletions
|
@ -17,7 +17,7 @@ struct generic_map_value {
|
|||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
||||
const unsigned int data_sizes[] = {8, 16, 32, 64, 96, 128, 192, 256, 512, 1024, 2048, 4096};
|
||||
const unsigned int data_sizes[] = {16, 32, 64, 96, 128, 192, 256, 512, 1024, 2048, 4096};
|
||||
const volatile unsigned int data_btf_ids[ARRAY_SIZE(data_sizes)] = {};
|
||||
|
||||
int err = 0;
|
||||
|
@ -166,7 +166,7 @@ static __always_inline void batch_percpu_free(struct bpf_map *map, unsigned int
|
|||
batch_percpu_free((struct bpf_map *)(&array_percpu_##size), batch, idx); \
|
||||
} while (0)
|
||||
|
||||
DEFINE_ARRAY_WITH_KPTR(8);
|
||||
/* kptr doesn't support bin_data_8 which is a zero-sized array */
|
||||
DEFINE_ARRAY_WITH_KPTR(16);
|
||||
DEFINE_ARRAY_WITH_KPTR(32);
|
||||
DEFINE_ARRAY_WITH_KPTR(64);
|
||||
|
@ -198,21 +198,20 @@ int test_batch_alloc_free(void *ctx)
|
|||
if ((u32)bpf_get_current_pid_tgid() != pid)
|
||||
return 0;
|
||||
|
||||
/* Alloc 128 8-bytes objects in batch to trigger refilling,
|
||||
* then free 128 8-bytes objects in batch to trigger freeing.
|
||||
/* Alloc 128 16-bytes objects in batch to trigger refilling,
|
||||
* then free 128 16-bytes objects in batch to trigger freeing.
|
||||
*/
|
||||
CALL_BATCH_ALLOC_FREE(8, 128, 0);
|
||||
CALL_BATCH_ALLOC_FREE(16, 128, 1);
|
||||
CALL_BATCH_ALLOC_FREE(32, 128, 2);
|
||||
CALL_BATCH_ALLOC_FREE(64, 128, 3);
|
||||
CALL_BATCH_ALLOC_FREE(96, 128, 4);
|
||||
CALL_BATCH_ALLOC_FREE(128, 128, 5);
|
||||
CALL_BATCH_ALLOC_FREE(192, 128, 6);
|
||||
CALL_BATCH_ALLOC_FREE(256, 128, 7);
|
||||
CALL_BATCH_ALLOC_FREE(512, 64, 8);
|
||||
CALL_BATCH_ALLOC_FREE(1024, 32, 9);
|
||||
CALL_BATCH_ALLOC_FREE(2048, 16, 10);
|
||||
CALL_BATCH_ALLOC_FREE(4096, 8, 11);
|
||||
CALL_BATCH_ALLOC_FREE(16, 128, 0);
|
||||
CALL_BATCH_ALLOC_FREE(32, 128, 1);
|
||||
CALL_BATCH_ALLOC_FREE(64, 128, 2);
|
||||
CALL_BATCH_ALLOC_FREE(96, 128, 3);
|
||||
CALL_BATCH_ALLOC_FREE(128, 128, 4);
|
||||
CALL_BATCH_ALLOC_FREE(192, 128, 5);
|
||||
CALL_BATCH_ALLOC_FREE(256, 128, 6);
|
||||
CALL_BATCH_ALLOC_FREE(512, 64, 7);
|
||||
CALL_BATCH_ALLOC_FREE(1024, 32, 8);
|
||||
CALL_BATCH_ALLOC_FREE(2048, 16, 9);
|
||||
CALL_BATCH_ALLOC_FREE(4096, 8, 10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -223,21 +222,20 @@ int test_free_through_map_free(void *ctx)
|
|||
if ((u32)bpf_get_current_pid_tgid() != pid)
|
||||
return 0;
|
||||
|
||||
/* Alloc 128 8-bytes objects in batch to trigger refilling,
|
||||
/* Alloc 128 16-bytes objects in batch to trigger refilling,
|
||||
* then free these objects through map free.
|
||||
*/
|
||||
CALL_BATCH_ALLOC(8, 128, 0);
|
||||
CALL_BATCH_ALLOC(16, 128, 1);
|
||||
CALL_BATCH_ALLOC(32, 128, 2);
|
||||
CALL_BATCH_ALLOC(64, 128, 3);
|
||||
CALL_BATCH_ALLOC(96, 128, 4);
|
||||
CALL_BATCH_ALLOC(128, 128, 5);
|
||||
CALL_BATCH_ALLOC(192, 128, 6);
|
||||
CALL_BATCH_ALLOC(256, 128, 7);
|
||||
CALL_BATCH_ALLOC(512, 64, 8);
|
||||
CALL_BATCH_ALLOC(1024, 32, 9);
|
||||
CALL_BATCH_ALLOC(2048, 16, 10);
|
||||
CALL_BATCH_ALLOC(4096, 8, 11);
|
||||
CALL_BATCH_ALLOC(16, 128, 0);
|
||||
CALL_BATCH_ALLOC(32, 128, 1);
|
||||
CALL_BATCH_ALLOC(64, 128, 2);
|
||||
CALL_BATCH_ALLOC(96, 128, 3);
|
||||
CALL_BATCH_ALLOC(128, 128, 4);
|
||||
CALL_BATCH_ALLOC(192, 128, 5);
|
||||
CALL_BATCH_ALLOC(256, 128, 6);
|
||||
CALL_BATCH_ALLOC(512, 64, 7);
|
||||
CALL_BATCH_ALLOC(1024, 32, 8);
|
||||
CALL_BATCH_ALLOC(2048, 16, 9);
|
||||
CALL_BATCH_ALLOC(4096, 8, 10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -251,17 +249,17 @@ int test_batch_percpu_alloc_free(void *ctx)
|
|||
/* Alloc 128 16-bytes per-cpu objects in batch to trigger refilling,
|
||||
* then free 128 16-bytes per-cpu objects in batch to trigger freeing.
|
||||
*/
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(16, 128, 1);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(32, 128, 2);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(64, 128, 3);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(96, 128, 4);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(128, 128, 5);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(192, 128, 6);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(256, 128, 7);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(512, 64, 8);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(1024, 32, 9);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(2048, 16, 10);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(4096, 8, 11);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(16, 128, 0);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(32, 128, 1);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(64, 128, 2);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(96, 128, 3);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(128, 128, 4);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(192, 128, 5);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(256, 128, 6);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(512, 64, 7);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(1024, 32, 8);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(2048, 16, 9);
|
||||
CALL_BATCH_PERCPU_ALLOC_FREE(4096, 8, 10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -275,17 +273,17 @@ int test_percpu_free_through_map_free(void *ctx)
|
|||
/* Alloc 128 16-bytes per-cpu objects in batch to trigger refilling,
|
||||
* then free these object through map free.
|
||||
*/
|
||||
CALL_BATCH_PERCPU_ALLOC(16, 128, 1);
|
||||
CALL_BATCH_PERCPU_ALLOC(32, 128, 2);
|
||||
CALL_BATCH_PERCPU_ALLOC(64, 128, 3);
|
||||
CALL_BATCH_PERCPU_ALLOC(96, 128, 4);
|
||||
CALL_BATCH_PERCPU_ALLOC(128, 128, 5);
|
||||
CALL_BATCH_PERCPU_ALLOC(192, 128, 6);
|
||||
CALL_BATCH_PERCPU_ALLOC(256, 128, 7);
|
||||
CALL_BATCH_PERCPU_ALLOC(512, 64, 8);
|
||||
CALL_BATCH_PERCPU_ALLOC(1024, 32, 9);
|
||||
CALL_BATCH_PERCPU_ALLOC(2048, 16, 10);
|
||||
CALL_BATCH_PERCPU_ALLOC(4096, 8, 11);
|
||||
CALL_BATCH_PERCPU_ALLOC(16, 128, 0);
|
||||
CALL_BATCH_PERCPU_ALLOC(32, 128, 1);
|
||||
CALL_BATCH_PERCPU_ALLOC(64, 128, 2);
|
||||
CALL_BATCH_PERCPU_ALLOC(96, 128, 3);
|
||||
CALL_BATCH_PERCPU_ALLOC(128, 128, 4);
|
||||
CALL_BATCH_PERCPU_ALLOC(192, 128, 5);
|
||||
CALL_BATCH_PERCPU_ALLOC(256, 128, 6);
|
||||
CALL_BATCH_PERCPU_ALLOC(512, 64, 7);
|
||||
CALL_BATCH_PERCPU_ALLOC(1024, 32, 8);
|
||||
CALL_BATCH_PERCPU_ALLOC(2048, 16, 9);
|
||||
CALL_BATCH_PERCPU_ALLOC(4096, 8, 10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue