Linux Test Project
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Pavithra <pavrampu@linux.ibm.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] hugetlb/hugefallocate: Add hugefallocate03 to stress test fallocate on hugetlbfs
Date: Wed, 23 Sep 2026 10:00:43 +0000	[thread overview]
Message-ID: <20260923100043.9301-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20260923080150.44934-1-pavrampu@linux.ibm.com>

Hi Pavithra,

On Wed Sep 23 13:31:50 2026 +0530, Pavithra wrote:
> hugetlb/hugefallocate: Add hugefallocate03 to stress test fallocate on hugetlbfs

> +static int fd = -1;
> +static unsigned long max_hpages;
> +static long hpage_size;
> +static void *thread_fallocate(void *arg)

Add a blank line between variable declarations and function definitions.

> +	SAFE_SIGACTION(SIGBUS, &sa, NULL);
> +
> +	fault_mmap_addr = SAFE_MMAP(NULL, max_hpages * hpage_size,
> +			PROT_READ | PROT_WRITE, MAP_SHARED,
> +			fd, 0);
> +
> +	pthread_cleanup_push(thread_fault_cleanup, NULL);
> +
> +	while (1) {
> +		tpage = ((long long)random()) % (max_hpages);
> +
> +		if (sigsetjmp(fault_jmp, 1) == 0) {
> +			foo = *((char *)(fault_mmap_addr + (tpage * hpage_size)));
> +			*((volatile char *)(fault_mmap_addr + (tpage * hpage_size))) = foo;
> +		}

Save the original SIGBUS handler and restore it upon thread termination or in
cleanup. If SIGBUS is raised after this thread terminates, siglongjmp() jumps
to an invalid stack.

> +	while (1) {
> +		addr = mmap(NULL, max_hpages * hpage_size,
> +				PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> +		if (addr != MAP_FAILED)
> +			SAFE_MUNMAP(addr, max_hpages * hpage_size);
> +
> +		pthread_testcancel();
> +	}

Use SAFE_MMAP() instead of mmap() and drop the MAP_FAILED check.

> +	nr_hpages_free = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE);
> +	max_hpages = MIN(nr_hpages_free, MAX_PAGES_TO_USE);
> +	free_before = nr_hpages_free;
> +	rsvd_before = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);
> +
> +	/* First preallocate file with max_hpages pages */
> +	err = fallocate(fd, 0, 0, hpage_size * max_hpages);

Because .hugepages uses TST_REQUEST, nr_hpages_free and max_hpages can be 0.
When max_hpages is 0, fallocate() fails with EINVAL (causing TBROK instead of
TCONF), and the worker threads divide by zero. Add a check to abort with
tst_brk(TCONF, ...) when max_hpages is 0.

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-09-23 10:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  8:01 [LTP] [PATCH v9] hugetlb/hugefallocate: Add hugefallocate03 to stress test fallocate on hugetlbfs Pavithra
2026-09-23 10:00 ` linuxtestproject.agent [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-09-20 11:35 [LTP] [PATCH v8] " Pavithra
2026-09-20 14:43 ` [LTP] " linuxtestproject.agent
2026-09-19 17:49 [LTP] [PATCH v7] " Pavithra
2026-09-19 20:14 ` [LTP] " linuxtestproject.agent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260923100043.9301-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=ltp@lists.linux.it \
    --cc=pavrampu@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox