Re: [PATCH bpf-next v3 3/6] selftests/vm: extend test_vmalloc to test execmem_* APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 16, 2022 at 05:06:18PM -0800, Song Liu wrote:
> Add logic to test execmem_[alloc|fill|free] in test_vmalloc.c.
> No need to change tools/testing/selftests/vm/test_vmalloc.sh.
> 
> Signed-off-by: Song Liu <song@xxxxxxxxxx>
> ---
>  lib/test_vmalloc.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
> index cf7780572f5b..6591c4932c3c 100644
> --- a/lib/test_vmalloc.c
> +++ b/lib/test_vmalloc.c
> @@ -50,6 +50,7 @@ __param(int, run_test_mask, INT_MAX,
>  		"\t\tid: 128,  name: pcpu_alloc_test\n"
>  		"\t\tid: 256,  name: kvfree_rcu_1_arg_vmalloc_test\n"
>  		"\t\tid: 512,  name: kvfree_rcu_2_arg_vmalloc_test\n"
> +		"\t\tid: 1024, name: execmem_alloc_test\n"
>  		/* Add a new test case description here. */
>  );
>  
> @@ -352,6 +353,34 @@ kvfree_rcu_2_arg_vmalloc_test(void)
>  	return 0;
>  }
>  
> +static int
> +execmem_alloc_test(void)
> +{
> +	void *p, *tmp;
> +	int i;
> +
> +	for (i = 0; i < test_loop_count; i++) {
> +		/* allocate variable size, up to 64kB */
> +		size_t size = (i % 1024 + 1) * 64;
> +
> +		p = execmem_alloc(size, 64);
> +		if (!p)
> +			return -1;
> +
> +		tmp = execmem_fill(p, "a", 1);
> +		if (tmp != p)
> +			return -1;
> +
> +		tmp = execmem_fill(p + size - 1, "b", 1);
> +		if (tmp != p + size - 1)
> +			return -1;
> +
> +		execmem_free(p);
> +	}
> +
> +	return 0;
> +}
> +

This is a basic test and it is useful.

But given all those WARN_ON() and WARN_ON_ONCE() I think the real value
test here would be to race 1000 threads doing this at the same time.
>From a quick look at the test I think adding another entry into the
test_case_array with the same call again or 3 times would suffice
for a basic clash test.

Thoughts?

  Luis




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux