Re: [PATCH v4 01/15] selftests/mm: restore default nr_hugepages value via EXIT trap in charge_reserved_hugetlb.sh

From: Zi Yan

Date: Tue Apr 07 2026 - 10:43:55 EST


On 6 Apr 2026, at 5:19, Sayali Patil wrote:

> cleanup() resets nr_hugepages to 0 on every invocation, while the test
> reconfigures it again in the next iteration. This leads to repeated
> allocation and freeing of large numbers of hugepages, especially when
> the original value is high.
>
> Additionally, with set -e, failures in earlier cleanup steps (e.g.,
> rmdir or umount returning EBUSY while background activity is still
> ongoing) can cause the script to exit before restoring the original
> value, leaving the system in a modified state.
>
> Use an EXIT trap to restore the original nr_hugepages once at
> script termination. This avoids unnecessary allocation churn and
> ensures the original value is reliably restored on all exit paths.
>
> Fixes: 7d695b1c3695b ("selftests/mm: save and restore nr_hugepages value")
> Signed-off-by: Sayali Patil <sayalip@xxxxxxxxxxxxx>
> ---
> tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
Acked-by: Zi Yan <ziy@xxxxxxxxxx>

Best Regards,
Yan, Zi