On 8/20/26 01:09, Christian Brauner wrote:
> The crashing_child_sparse() helper touches the first page of the
> mapping. That forces everything behind it to be a trailing hole. This is
> easy to handle. Make the test more difficult meaningful by also touchin
> the last page. This causes the hole to sit between two populated pages.
> 
> Signed-off-by: Christian Brauner (Amutable) <[email protected]>
> ---
>  tools/testing/selftests/coredump/coredump_test_helpers.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/coredump/coredump_test_helpers.c 
> b/tools/testing/selftests/coredump/coredump_test_helpers.c
> index 45d76fa0f469..89f3954c5607 100644
> --- a/tools/testing/selftests/coredump/coredump_test_helpers.c
> +++ b/tools/testing/selftests/coredump/coredump_test_helpers.c
> @@ -58,14 +58,16 @@ void crashing_child_sparse(size_t size)
>       char *p;
>  
>       /*
> -      * Touch the first page only. The whole mapping is dumped because
> -      * it has been written to, but all of it save that one page is a
> -      * hole.
> +      * Touch the first and the last page. This will cause the whole mapping
> +      * to be dumped because it has been written to. Everything between
> +      * those two pages is a hole though.
>        */

"hole" as in "no pages mapped"?

With THP enabled, this is not necessarily true. You can either size the mapping
large enough that you get holes in an case, or just disable THPs

madvise(p, size, MADV_NOHUGEPAGE);

before write access.

That's probably the cleanest way here?

>       p = mmap(NULL, size, PROT_READ | PROT_WRITE,
>                MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
> -     if (p != MAP_FAILED)
> +     if (p != MAP_FAILED) {
>               p[0] = 'x';
> +             p[size - 1] = 'x';
> +     }
>  
>       /* crash on purpose */
>       *(volatile int *)NULL = 0;
> 


-- 
Cheers,

David

Reply via email to