Skip to content

Commit

Permalink
selftests/mm: save and restore nr_hugepages value
Browse files Browse the repository at this point in the history
Save and restore nr_hugepages before changing it during the test.  A test
should not change system wide settings.

Link: https://lkml.kernel.org/r/20240125154608.720072-4-usama.anjum@collabora.com
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
musamaanjum authored and akpm00 committed Feb 22, 2024
1 parent 20a2191 commit 7d695b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/testing/selftests/mm/charge_reserved_hugetlb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if [[ $(id -u) -ne 0 ]]; then
exit $ksft_skip
fi

nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages)

fault_limit_file=limit_in_bytes
reservation_limit_file=rsvd.limit_in_bytes
fault_usage_file=usage_in_bytes
Expand Down Expand Up @@ -582,3 +584,5 @@ if [[ $do_umount ]]; then
umount $cgroup_path
rmdir $cgroup_path
fi

echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages
3 changes: 3 additions & 0 deletions tools/testing/selftests/mm/hugetlb_reparenting_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if [[ $(id -u) -ne 0 ]]; then
exit $ksft_skip
fi

nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages)
usage_file=usage_in_bytes

if [[ "$1" == "-cgroup-v2" ]]; then
Expand Down Expand Up @@ -252,3 +253,5 @@ if [[ $do_umount ]]; then
umount $CGROUP_ROOT
rm -rf $CGROUP_ROOT
fi

echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages

0 comments on commit 7d695b1

Please sign in to comment.