[LTP] [PATCH v6] hugemmap43: Migrate truncate_sigbus_versus_oom from libhugetlbfs

Cyril Hrubis chrubis@suse.cz
Fri Aug 28 17:12:44 CEST 2026


Hi!
> +static void run_test(void)
> +{
> +	void *p, *q;
> +	unsigned long totpages;
> +	unsigned long i;
> +
> +	test_pass = 0;
> +
> +	fd = tst_creat_unlinked(MNTPOINT, 0, 0600);
> +	p = SAFE_MMAP(NULL, hpage_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> +	SAFE_FTRUNCATE(fd, 0);
> +
> +	fdx = tst_creat_unlinked(MNTPOINT, 0, 0600);
> +	totpages = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE);
> +	q = SAFE_MMAP(NULL, totpages * hpage_size, PROT_READ | PROT_WRITE,
> +		      MAP_SHARED, fdx, 0);
> +
> +	/* Touch the pages to ensure they're removed from the pool */
> +	for (i = 0; i < totpages; i++) {
> +		volatile char *x = (volatile char *)q + i * hpage_size;
> +		*x = 0;
> +	}

Why do we need two mappings? Shouldn't one mapping, faulted in then
truncated suffice?

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list