]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/mm: restore default nr_hugepages value via exit trap in hugetlb_reparenting...
authorSayali Patil <sayalip@linux.ibm.com>
Thu, 21 May 2026 06:47:43 +0000 (12:17 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 21 Jun 2026 18:37:32 +0000 (11:37 -0700)
commit7f9c0920ff3debae3cb4d60260e3daf56ab68395
treeae53e528ff90707bf7d1b4013f13247375a7bd21
parent404c04e010da2edc93cada07d4d50deda12a68e4
selftests/mm: restore default nr_hugepages value via exit trap in hugetlb_reparenting_test.sh

The test modifies nr_hugepages during execution and restores it from
cleanup() and again reconfigure it setup, which is invoked multiple times
across test flow.  This can lead to repeated allocation/freeing of
hugepages.

With set -e, failures in cleanup (e.g., rmdir/umount) can also cause early
exit before restoring the original value at the end.

Move restoration of the original nr_hugepages value to a trap handler
registered for EXIT, INT, and TERM signals so it is always restored on all
exit paths.  This also avoids unnecessary allocation churn across repeated
cleanup/setup cycles.

Link: https://lore.kernel.org/29db637c3c6ba6c168f6b33f59f059a0b39c35c8.1779296493.git.sayalip@linux.ibm.com
Fixes: 585a9145886a ("selftests/mm: restore default nr_hugepages value during cleanup in hugetlb_reparenting_test.sh")
Signed-off-by: Sayali Patil <sayalip@linux.ibm.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Cc: David Hildenbrand (Arm) <david@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/hugetlb_reparenting_test.sh