From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: Pavithra <pavrampu@linux.ibm.com>
Cc: pavrampu@linux.ibm.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] [PATCH] [PATCH v5] Hugetlb: Migrating libhugetlbfs test truncate_reserve_wraparound.c
Date: Thu, 26 Mar 2026 11:24:13 +0000 [thread overview]
Message-ID: <69c5175d.df0a0220.190c3f.bcd5@mx.google.com> (raw)
In-Reply-To: <20260310112044.123827-1-pavrampu@linux.ibm.com>
Hi!
Here a deeper analysis on the patch:
> Changes in v5:
> - removed unused parameters from sigbus_handler call
> - Added check for after_mmap_rsvd == initial_rsvd + 1
> - Used TST_EXP_EQ_LU for comparsion
This should stay away from the commit message. And commit message should have
a meaningful explaination of the test or what was done by the patch.
>
> Signed-off-by: Pavithra <pavrampu@linux.ibm.com>
> ---
> runtest/hugetlb | 1 +
> testcases/kernel/mem/.gitignore | 1 +
> .../kernel/mem/hugetlb/hugemmap/hugemmap35.c | 125 ++++++++++++++++++
> 3 files changed, 127 insertions(+)
> create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap35.c
>
> diff --git a/runtest/hugetlb b/runtest/hugetlb
> index 0896d3c94..8ee0e6f82 100644
> --- a/runtest/hugetlb
> +++ b/runtest/hugetlb
> @@ -36,6 +36,7 @@ hugemmap30 hugemmap30
> hugemmap31 hugemmap31
> hugemmap32 hugemmap32
> hugemmap34 hugemmap34
> +hugemmap35 hugemmap35
> hugemmap05_1 hugemmap05 -m
> hugemmap05_2 hugemmap05 -s
> hugemmap05_3 hugemmap05 -s -m
> diff --git a/testcases/kernel/mem/.gitignore b/testcases/kernel/mem/.gitignore
> index b4455de51..0e59035df 100644
> --- a/testcases/kernel/mem/.gitignore
> +++ b/testcases/kernel/mem/.gitignore
> @@ -36,6 +36,7 @@
> /hugetlb/hugemmap/hugemmap31
> /hugetlb/hugemmap/hugemmap32
> /hugetlb/hugemmap/hugemmap34
> +/hugetlb/hugemmap/hugemmap35
> /hugetlb/hugeshmat/hugeshmat01
> /hugetlb/hugeshmat/hugeshmat02
> /hugetlb/hugeshmat/hugeshmat03
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap35.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap35.c
> new file mode 100644
> index 000000000..dc678661e
> --- /dev/null
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap35.c
> @@ -0,0 +1,125 @@
> +// SPDX-License-Identifier: LGPL-2.1-or-later
> +/*
> + * Copyright (C) 2005-2006 David Gibson & Adam Litke, IBM Corporation.
> + */
> +
> +/*\
> + * [Description]
This is deprecated. Pleae use /*\
> + *
> + * Origin: https://github.com/libhugetlbfs/libhugetlbfs/blob/master/tests/truncate_reserve_wraparound.c
> + *
> + * At one stage, improper handling of tests against i_size could mess
> + * up accounting of reserved hugepages on certain truncate
> + * operations.
Can we write the description a bit better? At the moment is a bit generic.
> + *
> + */
> +
> +#include <signal.h>
> +#include <setjmp.h>
> +#include "hugetlb.h"
> +
> +#define MNTPOINT "hugetlbfs/"
> +
> +static long hpage_size;
> +static int fd = -1;
> +
> +static sigjmp_buf sig_escape;
> +
> +static void sigbus_handler(int signum LTP_ATTRIBUTE_UNUSED)
> +{
> + siglongjmp(sig_escape, 17);
> +}
> +
> +static void run_test(void)
> +{
> +
> + static int sigbus_count;
Is it needed to be static? We just need `int sigbus_count = 0`.
> + unsigned long initial_rsvd, after_map_rsvd, after_touch_rsvd;
> + unsigned long after_trunc_rsvd, after_unmap_rsvd, after_sigbus_rsvd;
> + volatile unsigned int *q;
> + void *p;
> +
> + sigbus_count = 0;
And this goes away.
> +
> + initial_rsvd = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);
> + tst_res(TINFO, "Reserve count before map: %lu", initial_rsvd);
> +
> + p = SAFE_MMAP(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_SHARED,
> + fd, 0);
> + q = p;
> +
> + after_map_rsvd = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);
> +
> + TST_EXP_EQ_LU(initial_rsvd + 1, after_map_rsvd);
> + if (!TST_PASS)
> + goto windup;
> +
> + *q = 0;
> + after_touch_rsvd = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);
> +
> + TST_EXP_EQ_LU(initial_rsvd, after_touch_rsvd);
> + if (!TST_PASS)
> + goto windup;
> +
> + SAFE_FTRUNCATE(fd, 0);
> + after_trunc_rsvd = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);
> +
> + TST_EXP_EQ_LU(initial_rsvd, after_trunc_rsvd);
> + if (!TST_PASS)
> + goto windup;
> +
> + if (sigsetjmp(sig_escape, 1) == 0)
> + *q; /* Fault, triggering a SIGBUS */
> + else
> + sigbus_count++;
> +
> + if (sigbus_count != 1) {
> + tst_res(TFAIL, "Didn't SIGBUS after truncate");
> + goto windup;
> + }
> +
> + after_sigbus_rsvd = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);
> +
> + TST_EXP_EQ_LU(initial_rsvd, after_sigbus_rsvd);
> + if (!TST_PASS)
> + goto windup;
> +
> +windup:
> + SAFE_MUNMAP(p, hpage_size);
> + after_unmap_rsvd = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);
> + tst_res(TINFO, "Reserve count after munmap: %lu", after_unmap_rsvd);
This variable is printed but never checked inside the test.
> +
> +}
> +
> +static void setup(void)
> +{
> + hpage_size = tst_get_hugepage_size();
Need space here.
> + fd = tst_creat_unlinked(MNTPOINT, 0, 0600);
> +
> + struct sigaction sa = {
> + .sa_handler = sigbus_handler,
> + .sa_flags = 0,
> + };
> +
> + SAFE_SIGACTION(SIGBUS, &sa, NULL);
> +}
> +
> +static void cleanup(void)
> +{
> + if (fd >= 0)
> + SAFE_CLOSE(fd);
Pleae use fd != -1 here.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2026-03-26 11:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 11:20 [LTP] [PATCH] [PATCH] [PATCH v5] Hugetlb: Migrating libhugetlbfs test truncate_reserve_wraparound.c Pavithra
2026-03-26 11:24 ` Andrea Cervesato via ltp [this message]
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=69c5175d.df0a0220.190c3f.bcd5@mx.google.com \
--to=ltp@lists.linux.it \
--cc=andrea.cervesato@suse.com \
--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