Skip to contentSkip to conversation

test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages

PATCH In review Petr Vorel 4 participants 6 messages Nov 4, 2021 – Nov 9, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages

Fix running make test-c as non-root.

Fixes 057d6b046 ("lib/tst_hugepage: Fix .request_hugepages = 0 bug")

---
Hi,

maybe echo "128" would not have to be checked.

Kind regards,
Petr

 lib/newlib_tests/test_zero_hugepage.sh | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
lib/newlib_tests/test_zero_hugepage.sh +18 -3
index d270e686c..663bd2316 100755
@@ -3,16 +3,31 @@
 # Copyright (c) 2021 Yang Xu <[email protected]>
 # Copyright (c) 2021 Petr Vorel <[email protected]>
 
+tconf()
+{
+	echo "TCONF: $1"
+	exit 32
+}
+
 echo "Testing .request_hugepages = TST_NO_HUGEPAGES"
 
 orig_value=`cat /proc/sys/vm/nr_hugepages`
 
 if grep -q -E '^proc /proc(/sys)? proc ro' /proc/mounts; then
-	echo "TCONF: /proc or /proc/sys mounted as read-only"
-	exit 32
+	tconf "/proc or /proc/sys mounted as read-only"
+fi
+
+if [ ! -f /proc/sys/vm/nr_hugepages ]; then
+	tconf "/proc/sys/vm/nr_hugepages does not exist"
+fi
+
+if [ ! -w /proc/sys/vm/nr_hugepages ]; then
+	tconf "no write permission to /proc/sys/vm/nr_hugepages (run as root)"
 fi
 
-echo "128" > /proc/sys/vm/nr_hugepages
+if ! echo "128" > /proc/sys/vm/nr_hugepages; then
+	tconf "Failed to write /proc/sys/vm/nr_hugepages"
+fi
 
 ./test_zero_hugepage
 
Signature · 5 lines
2.33.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Petr Vorel

Fix running make test-c as non-root.

Fixes 057d6b046 ("lib/tst_hugepage: Fix .request_hugepages = 0 bug")

---
Hi,

maybe echo "128" would not have to be checked.

Agreed, If the system memory is too fragmental to keep enough hpages, there won't be an error returned.

Quoted 56 lines

Kind regards,
Petr

 lib/newlib_tests/test_zero_hugepage.sh | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
lib/newlib_tests/test_zero_hugepage.sh +15 -2
index d270e686c..663bd2316 100755
@@ -3,16 +3,31 @@
 # Copyright (c) 2021 Yang Xu <[email protected]>
 # Copyright (c) 2021 Petr Vorel <[email protected]>
 
+tconf()
+{
+       echo "TCONF: $1"
+       exit 32
+}
+
 echo "Testing .request_hugepages = TST_NO_HUGEPAGES"
 
 orig_value=`cat /proc/sys/vm/nr_hugepages`
 
 if grep -q -E '^proc /proc(/sys)? proc ro' /proc/mounts; then
-       echo "TCONF: /proc or /proc/sys mounted as read-only"
-       exit 32
+       tconf "/proc or /proc/sys mounted as read-only"
+fi
+
+if [ ! -f /proc/sys/vm/nr_hugepages ]; then
+       tconf "/proc/sys/vm/nr_hugepages does not exist"
+fi
+
+if [ ! -w /proc/sys/vm/nr_hugepages ]; then
+       tconf "no write permission to /proc/sys/vm/nr_hugepages (run as

root)"
fi

lib/newlib_tests/test_zero_hugepage.sh +3 -2
-echo "128" > /proc/sys/vm/nr_hugepages
+if ! echo "128" > /proc/sys/vm/nr_hugepages; then
+       tconf "Failed to write /proc/sys/vm/nr_hugepages"
+fi
 
 ./test_zero_hugepage
 
--

2.33.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#2 lore raw

Hi Li,

Quoted 10 lines · Petr Vorel
Quoted 8 lines

Fix running make test-c as non-root.

Fixes 057d6b046 ("lib/tst_hugepage: Fix .request_hugepages = 0 bug")

---
Hi,

Quoted 5 lines
Quoted 1 line

maybe echo "128" would not have to be checked.

Agreed, If the system memory is too fragmental to keep enough hpages, there won't be an error returned.

OK, wait little longer and then merge with keeping echo "128" > /proc/sys/vm/nr_hugepages

...

Quoted 4 lines

lib/newlib_tests/test_zero_hugepage.sh line 30

Quoted 4 lines
lib/newlib_tests/test_zero_hugepage.sh +3 -1
-echo "128" > /proc/sys/vm/nr_hugepages
+if ! echo "128" > /proc/sys/vm/nr_hugepages; then
+       tconf "Failed to write /proc/sys/vm/nr_hugepages"
+fi

Thanks for your review!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#3 lore raw

Hi!

Quoted 4 lines
Quoted 2 lines

Agreed, If the system memory is too fragmental to keep enough hpages, there won't be an error returned.

OK, wait little longer and then merge with keeping echo "128" > /proc/sys/vm/nr_hugepages

Also I wonder why do we request 128? I guess that 4 would be more than enough.

Other than that:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hi Cyril

Quoted 8 lines

Hi!

Quoted 4 lines
Quoted 2 lines

Agreed, If the system memory is too fragmental to keep enough hpages, there won't be an error returned.

OK, wait little longer and then merge with keeping echo "128"> /proc/sys/vm/nr_hugepages

Also I wonder why do we request 128? I guess that 4 would be more than enough.

I don't think about so much when I wrote this script. Using a small number is also ok for me.

Quoted 5 lines

Other than that:

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw

Hi all,

Quoted 11 lines

Hi Cyril

Quoted 8 lines

Hi!

Quoted 4 lines
Quoted 2 lines

Agreed, If the system memory is too fragmental to keep enough hpages, there won't be an error returned.

OK, wait little longer and then merge with keeping echo "128"> /proc/sys/vm/nr_hugepages

Also I wonder why do we request 128? I guess that 4 would be more than enough.

I don't think about so much when I wrote this script. Using a small number is also ok for me.

Good point! I thought it's needed to have that high value. I'll send a separate patch for this.

Merged this one.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp