[LTP] hugetlb/hugefallocate: Add hugefallocate03 to stress test fallocate on hugetlbfs

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Sun Sep 20 16:43:13 CEST 2026


Hi Pavithra,

On Sun Sep 20 17:05:19 2026 +0530, Pavithra wrote:
> hugetlb/hugefallocate: Add hugefallocate03 to stress test fallocate on hugetlbfs

> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#include <sys/mount.h>
> +#include <limits.h>
> +#include <sys/param.h>
> +#include <sys/types.h>
> +#include <pthread.h>
> +#include <signal.h>
> +#include <setjmp.h>

Add missing #include <time.h> for time().

> +		if (err) {
> +			tst_res(TFAIL | TERRNO, "fallocate(PUNCH_HOLE) failed at page %ld:", tpage);
> +			thread_err = 1;
> +		}
> +		err = fallocate(fd, 0, tpage * hpage_size, hpage_size);
> +		if (err) {
> +			tst_res(TFAIL | TERRNO, "fallocate(fill) failed at page %ld:", tpage);
> +			thread_err = 1;
> +		}

Drop the trailing colons in the format strings; TERRNO automatically appends
": <errno>". Remove thread_err as tst_res() already records the failure.
Break the loop or return early on failure to avoid flooding the test log
with thousands of failure messages.

> +static void thread_fault_cleanup(void *arg)
> +{
> +	(void)arg;
> +
> +	if (fault_mmap_addr) {
> +		munmap(fault_mmap_addr, max_hpages * hpage_size);
> +		fault_mmap_addr = NULL;
> +	}
> +}

Use SAFE_MUNMAP() instead of munmap().

> +	nr_hpages_free = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE);
> +	max_hpages = MIN(nr_hpages_free, MAX_PAGES_TO_USE);
> +	free_before = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE);

Assign free_before = nr_hpages_free instead of reading /proc/meminfo
twice in consecutive lines.

> +	if (thread_err)
> +		tst_res(TFAIL, "fallocate() failed during stress, see above");

Remove this check; tst_res() in thread_fallocate() already marks the test
as failed.

> +	.hugepages = {MAX_PAGES_TO_USE, TST_NEEDS},

Using TST_NEEDS with MAX_PAGES_TO_USE (100) causes unnecessary TCONF on
systems where hugepages are large (e.g. 16MB on ppc64le, 512MB on arm64)
or where memory is limited. Use TST_REQUEST, or require a smaller minimum
in .hugepages to keep the test portable.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list