diff mbox series

selftests/mm: Restore default nr_hugepages value during cleanup in hugetlb_reparenting_test.sh

Message ID 20250410100748.2310-1-donettom@linux.ibm.com (mailing list archive)
State New
Headers show
Series selftests/mm: Restore default nr_hugepages value during cleanup in hugetlb_reparenting_test.sh | expand

Commit Message

Donet Tom April 10, 2025, 10:07 a.m. UTC
During cleanup, the value of /proc/sys/vm/nr_hugepages is currently
being set to 0. At the end of the test, if all tests pass, the
original nr_hugepages value is restored. However, if any test fails,
it remains set to 0.

With this patch, we ensure that the original nr_hugepages value is
restored during cleanup, regardless of whether the test passes or fails.

Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests")
Signed-off-by: Donet Tom <donettom@linux.ibm.com>
---
 tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anshuman Khandual April 15, 2025, 6:58 a.m. UTC | #1
On 4/10/25 15:37, Donet Tom wrote:
> During cleanup, the value of /proc/sys/vm/nr_hugepages is currently
> being set to 0. At the end of the test, if all tests pass, the
> original nr_hugepages value is restored. However, if any test fails,
> it remains set to 0.
> 
> With this patch, we ensure that the original nr_hugepages value is
> restored during cleanup, regardless of whether the test passes or fails.
> 
> Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests")
Although this change makes sense as an improvement or a cleanup but
not sure if this also deserves a Fixes: tag as well.

> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
> ---
>  tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
> index 11f9bbe7dc22..114875a2b018 100755
> --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
> +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
> @@ -56,7 +56,7 @@ function cleanup() {
>    rmdir "$CGROUP_ROOT"/a/b 2>/dev/null
>    rmdir "$CGROUP_ROOT"/a 2>/dev/null
>    rmdir "$CGROUP_ROOT"/test1 2>/dev/null
> -  echo 0 >/proc/sys/vm/nr_hugepages
> +  echo $nr_hugepgs >/proc/sys/vm/nr_hugepages
>    set -e
>  }
>
Dev Jain April 15, 2025, 7:30 a.m. UTC | #2
On 15/04/25 12:28 pm, Anshuman Khandual wrote:
> 
> 
> On 4/10/25 15:37, Donet Tom wrote:
>> During cleanup, the value of /proc/sys/vm/nr_hugepages is currently
>> being set to 0. At the end of the test, if all tests pass, the
>> original nr_hugepages value is restored. However, if any test fails,
>> it remains set to 0.
>>
>> With this patch, we ensure that the original nr_hugepages value is
>> restored during cleanup, regardless of whether the test passes or fails.
>>
>> Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests")
> Although this change makes sense as an improvement or a cleanup but
> not sure if this also deserves a Fixes: tag as well.

IMHO it deserves a Fixes tag, the tests should always cleanly exit 
without changing system state. It may or may not cause an actual 
problem, so let's be proactive : )

> 
>> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
>> ---
>>   tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
>> index 11f9bbe7dc22..114875a2b018 100755
>> --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
>> +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
>> @@ -56,7 +56,7 @@ function cleanup() {
>>     rmdir "$CGROUP_ROOT"/a/b 2>/dev/null
>>     rmdir "$CGROUP_ROOT"/a 2>/dev/null
>>     rmdir "$CGROUP_ROOT"/test1 2>/dev/null
>> -  echo 0 >/proc/sys/vm/nr_hugepages
>> +  echo $nr_hugepgs >/proc/sys/vm/nr_hugepages
>>     set -e
>>   }
>>   
>
Donet Tom April 15, 2025, 10:18 a.m. UTC | #3
On 4/15/25 1:00 PM, Dev Jain wrote:
>
>
> On 15/04/25 12:28 pm, Anshuman Khandual wrote:
>>
>>
>> On 4/10/25 15:37, Donet Tom wrote:
>>> During cleanup, the value of /proc/sys/vm/nr_hugepages is currently
>>> being set to 0. At the end of the test, if all tests pass, the
>>> original nr_hugepages value is restored. However, if any test fails,
>>> it remains set to 0.
>>>
>>> With this patch, we ensure that the original nr_hugepages value is
>>> restored during cleanup, regardless of whether the test passes or 
>>> fails.
>>>
>>> Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation 
>>> tests")
>> Although this change makes sense as an improvement or a cleanup but
>> not sure if this also deserves a Fixes: tag as well.
>
> IMHO it deserves a Fixes tag, the tests should always cleanly exit 
> without changing system state. It may or may not cause an actual 
> problem, so let's be proactive : )
>
Yes, I was thinking the same.

>
>>
>>> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
>>> ---
>>>   tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh 
>>> b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
>>> index 11f9bbe7dc22..114875a2b018 100755
>>> --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
>>> +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
>>> @@ -56,7 +56,7 @@ function cleanup() {
>>>     rmdir "$CGROUP_ROOT"/a/b 2>/dev/null
>>>     rmdir "$CGROUP_ROOT"/a 2>/dev/null
>>>     rmdir "$CGROUP_ROOT"/test1 2>/dev/null
>>> -  echo 0 >/proc/sys/vm/nr_hugepages
>>> +  echo $nr_hugepgs >/proc/sys/vm/nr_hugepages
>>>     set -e
>>>   }
>>
>
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
index 11f9bbe7dc22..114875a2b018 100755
--- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
+++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh
@@ -56,7 +56,7 @@  function cleanup() {
   rmdir "$CGROUP_ROOT"/a/b 2>/dev/null
   rmdir "$CGROUP_ROOT"/a 2>/dev/null
   rmdir "$CGROUP_ROOT"/test1 2>/dev/null
-  echo 0 >/proc/sys/vm/nr_hugepages
+  echo $nr_hugepgs >/proc/sys/vm/nr_hugepages
   set -e
 }