[LTP] hugetlb/hugemmap: add hugemmap33 to test hugetlbfs quota accounting

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Wed Sep 9 12:30:28 CEST 2026


Hi Pavithra,

On Wed Sep 9 14:25:55 2026 +0530, Pavithra <pavrampu@linux.ibm.com> wrote:
> hugetlb/hugemmap: add hugemmap33 to test hugetlbfs quota accounting

> Test hugetlbfs quota accounting with filesystem size limits to check
> for regressions in quota handling for MAP_PRIVATE and MAP_SHARED pages.

The empty lines in the commit message body contain trailing whitespace,
which triggers checkpatch errors.

> +/*\
> + * Test hugetlbfs quota accounting with filesystem size limits.
> + *
> + * The number of global huge pages available to a mounted hugetlbfs filesystem
> + * can be limited using a quota mechanism by setting the size attribute at
> + * mount time. Older kernels did not properly handle quota accounting for
> + * MAP_PRIVATE pages and MAP_SHARED reservations.
> + *
> + * Commit a1e78772d72b introduced MAP_PRIVATE reservations at mmap() time,
> + * so quota is checked upfront and mmap() fails with ENOMEM when over quota.
> + * Before this, quota was only checked at fault time resulting in SIGBUS.
> + *
> + * Root is required to mount the quota-limited hugetlbfs instance.
> + */

Use :manpage:`mmap(2)` when referencing mmap() in the documentation block.

> +static void verify_quota_map_unmap(unsigned long size, int mmap_flags)
> +{
> +	int fd;
> +	char path[PATH_MAX];
> +
> +	snprintf(path, sizeof(path), "%s/test_file_%d", MNTPOINT, getpid());
> +	fd = SAFE_OPEN(path, O_CREAT | O_RDWR, 0600);
> +	SAFE_UNLINK(path);
> +
> +	TST_EXP_PASS_PTR_VOID(mmap(NULL, size, PROT_READ | PROT_WRITE, mmap_flags, fd, 0),
> +			       "mmap untouched mapping");
> +	SAFE_CLOSE(fd);
> +}

verify_quota_map_unmap() never unmaps the mapping. As a result, this
tests cleanup on process termination rather than unmapping an untouched
mapping. Call SAFE_MUNMAP(TST_RET_PTR, size) if TST_PASS before closing fd.

> +	snprintf(path, sizeof(path), "%s/test_file_%d", MNTPOINT, getpid());
> +	fd = SAFE_OPEN(path, O_CREAT | O_RDWR, 0600);
> +	SAFE_UNLINK(path);

Use tst_creat_unlinked(MNTPOINT, 0, 0600) instead of manually creating and
unlinking files across the test functions.

> +	if (mount("none", MNTPOINT, "hugetlbfs", 0, mount_opts) == -1) {
> +		if (errno == ENODEV)
> +			tst_brk(TCONF, "hugetlbfs not supported");
> +		tst_brk(TBROK | TERRNO, "mount() failed");
> +	}

Use SAFE_MOUNT("none", MNTPOINT, "hugetlbfs", 0, mount_opts). Hugepage
support is already checked by .hugepages before setup() runs.

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