[LTP] [PATCH v4] Migrating the libhugetlbfs/testcases/stack_grow_into_huge.c test

Cyril Hrubis chrubis@suse.cz
Wed Sep 4 11:49:11 CEST 2024


Hi!
> + /*\
> +  * [Description]
> +  *
> + * Test Name: stack_grow_into_huge

Drop the test name please, it has no value in the description.

> + * On PowerPC, the address space is divided into segments.  These segments can
> + * contain either huge pages or normal pages, but not both.  All segments are
> + * initially set up to map normal pages.  When a huge page mapping is created
> + * within a set of empty segments, they are "enabled" for huge pages at that
> + * time.  Once enabled for huge pages, they can not be used again for normal
> + * pages for the remaining lifetime of the process.
> + *
> + * If the segment immediately preceeding the segment containing the stack is
> + * converted to huge pages and the stack is made to grow into the this
> + * preceeding segment, some kernels may attempt to map normal pages into the
> + * huge page-only segment -- resulting in bugs.
> + */
> +
> +#include "hugetlb.h"
> +#include <errno.h>
> +
> +#ifdef __LP64__
> +#define STACK_ALLOCATION_SIZE	(256*1024*1024)
> +#else
> +#define STACK_ALLOCATION_SIZE	(16*1024*1024)
> +#endif
> +#define PALIGN(p, a) ((void *)LTP_ALIGN((unsigned long)(p), (a)))
> +#define MNTPOINT "hugetlbfs/"
> +static int  fd = -1;
> +static unsigned long long hpage_size;
> +static int page_size;
> +
> +
> +void do_child(void *stop_address)
> +{
> +	struct rlimit r;
> +	volatile int *x;
> +
> +	/* corefile from this process is not interesting and limiting
> +	 * its size can save a lot of time. '1' is a special value,
> +	 * that will also abort dumping via pipe, which by default
> +	 * sets limit to RLIM_INFINITY.
> +	 */
> +	r.rlim_cur = 1;
> +	r.rlim_max = 1;
> +	SAFE_SETRLIMIT(RLIMIT_CORE, &r);

We have a library function tst_no_corefile() exactly for this purpose,
please use that one instead.


The rest looks good. You can add my Reviewed-by: Cyril Hrubis
<chrubis@suse.cz> with these minor changes added.


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list