public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
@ 2021-11-04 16:45 Petr Vorel
  2021-11-08  7:31 ` Li Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2021-11-04 16:45 UTC (permalink / raw)
  To: ltp

Fix running make test-c as non-root.

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

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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(-)

diff --git a/lib/newlib_tests/test_zero_hugepage.sh b/lib/newlib_tests/test_zero_hugepage.sh
index d270e686c..663bd2316 100755
--- a/lib/newlib_tests/test_zero_hugepage.sh
+++ b/lib/newlib_tests/test_zero_hugepage.sh
@@ -3,16 +3,31 @@
 # Copyright (c) 2021 Yang Xu <xuyang2018.jy@fujitsu.com>
 # Copyright (c) 2021 Petr Vorel <pvorel@suse.cz>
 
+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
 
-- 
2.33.1


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
  2021-11-04 16:45 [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages Petr Vorel
@ 2021-11-08  7:31 ` Li Wang
  2021-11-08 10:17   ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2021-11-08  7:31 UTC (permalink / raw)
  To: Petr Vorel; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1894 bytes --]

On Fri, Nov 5, 2021 at 12:45 AM Petr Vorel <pvorel@suse.cz> wrote:

> Fix running make test-c as non-root.
>
> Fixes: 057d6b046 ("lib/tst_hugepage: Fix .request_hugepages = 0 bug")
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> 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.

Reviewed-by: Li Wang <liwang@redhat.com>



>
> Kind regards,
> Petr
>
>  lib/newlib_tests/test_zero_hugepage.sh | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/lib/newlib_tests/test_zero_hugepage.sh
> b/lib/newlib_tests/test_zero_hugepage.sh
> index d270e686c..663bd2316 100755
> --- a/lib/newlib_tests/test_zero_hugepage.sh
> +++ b/lib/newlib_tests/test_zero_hugepage.sh
> @@ -3,16 +3,31 @@
>  # Copyright (c) 2021 Yang Xu <xuyang2018.jy@fujitsu.com>
>  # Copyright (c) 2021 Petr Vorel <pvorel@suse.cz>
>
> +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
>
> --
> 2.33.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 3411 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
  2021-11-08  7:31 ` Li Wang
@ 2021-11-08 10:17   ` Petr Vorel
  2021-11-08 14:34     ` Cyril Hrubis
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2021-11-08 10:17 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

Hi Li,

> On Fri, Nov 5, 2021 at 12:45 AM Petr Vorel <pvorel@suse.cz> wrote:

> > Fix running make test-c as non-root.

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

> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > 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.
OK, wait little longer and then merge with keeping
echo "128" > /proc/sys/vm/nr_hugepages

...
> > -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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
  2021-11-08 10:17   ` Petr Vorel
@ 2021-11-08 14:34     ` Cyril Hrubis
  2021-11-09  0:51       ` xuyang2018.jy
  0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2021-11-08 14:34 UTC (permalink / raw)
  To: Petr Vorel; +Cc: LTP List

Hi!
> > 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:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
  2021-11-08 14:34     ` Cyril Hrubis
@ 2021-11-09  0:51       ` xuyang2018.jy
  2021-11-09  9:43         ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: xuyang2018.jy @ 2021-11-09  0:51 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List

Hi Cyril
> Hi!
>>> 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.
>
> Other than that:
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
  2021-11-09  0:51       ` xuyang2018.jy
@ 2021-11-09  9:43         ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2021-11-09  9:43 UTC (permalink / raw)
  To: xuyang2018.jy@fujitsu.com; +Cc: LTP List

Hi all,

> Hi Cyril
> > Hi!
> >>> 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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-09  9:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-04 16:45 [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages Petr Vorel
2021-11-08  7:31 ` Li Wang
2021-11-08 10:17   ` Petr Vorel
2021-11-08 14:34     ` Cyril Hrubis
2021-11-09  0:51       ` xuyang2018.jy
2021-11-09  9:43         ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox