[v4] test: remove meson dependency on /proc file

Message ID 20200415131954.2006010-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Headers
Series [v4] test: remove meson dependency on /proc file |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation fail apply issues

Commit Message

Thomas Monjalon April 15, 2020, 1:19 p.m. UTC
  Meson is detecting the path /proc/sys/vm/nr_hugepages in the call to cat
in app/test/meson.build and then adding it as a build dependency.
This causes build loop if the timestamp of this file keeps changing.

It is fixed by hiding hugepage check in a shell script.

Fixes: 77784ef0fba8 ("test: allow no-huge mode for fast-tests")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Tested-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Reviewed-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---

v2: use variable as pointed by Lukasz
v3: avoid TOCTOU issue as suggested by David
v4: remove Linux check in meson file and skip find_program() call

---
 MAINTAINERS              |  1 +
 app/test/has-hugepage.sh |  9 +++++++++
 app/test/meson.build     | 10 +---------
 3 files changed, 11 insertions(+), 9 deletions(-)
 create mode 100755 app/test/has-hugepage.sh
  

Comments

Bruce Richardson April 15, 2020, 1:28 p.m. UTC | #1
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, April 15, 2020 2:20 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Lukasz Wojciechowski
> <l.wojciechow@partner.samsung.com>; Aaron Conole <aconole@redhat.com>;
> Ruifeng Wang <ruifeng.wang@arm.com>; David Marchand
> <david.marchand@redhat.com>; Gavin Hu <gavin.hu@arm.com>
> Subject: [PATCH v4] test: remove meson dependency on /proc file
> 
> Meson is detecting the path /proc/sys/vm/nr_hugepages in the call to cat
> in app/test/meson.build and then adding it as a build dependency.
> This causes build loop if the timestamp of this file keeps changing.
> 
> It is fixed by hiding hugepage check in a shell script.
> 
> Fixes: 77784ef0fba8 ("test: allow no-huge mode for fast-tests")
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Tested-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> Reviewed-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> Acked-by: Aaron Conole <aconole@redhat.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
> 
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Thomas Monjalon April 15, 2020, 1:30 p.m. UTC | #2
15/04/2020 15:28, Richardson, Bruce:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 
> > Meson is detecting the path /proc/sys/vm/nr_hugepages in the call to cat
> > in app/test/meson.build and then adding it as a build dependency.
> > This causes build loop if the timestamp of this file keeps changing.
> > 
> > It is fixed by hiding hugepage check in a shell script.
> > 
> > Fixes: 77784ef0fba8 ("test: allow no-huge mode for fast-tests")
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > Tested-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> > Reviewed-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> > Acked-by: Aaron Conole <aconole@redhat.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > ---
> > 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied
  
David Marchand April 15, 2020, 1:36 p.m. UTC | #3
On Wed, Apr 15, 2020 at 3:20 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> Meson is detecting the path /proc/sys/vm/nr_hugepages in the call to cat
> in app/test/meson.build and then adding it as a build dependency.
> This causes build loop if the timestamp of this file keeps changing.
>
> It is fixed by hiding hugepage check in a shell script.
>
> Fixes: 77784ef0fba8 ("test: allow no-huge mode for fast-tests")
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Tested-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> Reviewed-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> Acked-by: Aaron Conole <aconole@redhat.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
>
> v2: use variable as pointed by Lukasz
> v3: avoid TOCTOU issue as suggested by David
> v4: remove Linux check in meson file and skip find_program() call
>
> ---
>  MAINTAINERS              |  1 +
>  app/test/has-hugepage.sh |  9 +++++++++
>  app/test/meson.build     | 10 +---------
>  3 files changed, 11 insertions(+), 9 deletions(-)
>  create mode 100755 app/test/has-hugepage.sh
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 144cf5d8ea..fe59f0224f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1469,6 +1469,7 @@ F: app/test/Makefile
>  F: app/test/autotest*
>  F: app/test/commands.c
>  F: app/test/get-coremask.sh
> +F: app/test/has-hugepage.sh
>  F: app/test/packet_burst_generator.c
>  F: app/test/packet_burst_generator.h
>  F: app/test/process.h
> diff --git a/app/test/has-hugepage.sh b/app/test/has-hugepage.sh
> new file mode 100755
> index 0000000000..865e66cddd
> --- /dev/null
> +++ b/app/test/has-hugepage.sh
> @@ -0,0 +1,9 @@
> +#! /bin/sh
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright 2020 Mellanox Technologies, Ltd
> +
> +if [ "$(uname)" = "Linux" ] ; then
> +       cat /proc/sys/vm/nr_hugepages || echo 0
> +else
> +       echo 0
> +fi
> diff --git a/app/test/meson.build b/app/test/meson.build
> index 777c536ae0..04b59cffa4 100644
> --- a/app/test/meson.build
> +++ b/app/test/meson.build
> @@ -396,15 +396,7 @@ dpdk_test = executable('dpdk-test',
>         install_rpath: driver_install_path,
>         install: true)
>
> -has_hugepage = true
> -if is_linux
> -       check_hugepage = run_command('cat',
> -                                    '/proc/sys/vm/nr_hugepages')
> -       if (check_hugepage.returncode() != 0 or
> -           check_hugepage.stdout().strip() == '0')
> -               has_hugepage = false
> -       endif
> -endif
> +has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0'

This change will force no-huge mode on FreeBSD while before we were
running with hugepages.
  
Thomas Monjalon April 15, 2020, 1:40 p.m. UTC | #4
15/04/2020 15:36, David Marchand:
> On Wed, Apr 15, 2020 at 3:20 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > --- /dev/null
> > +++ b/app/test/has-hugepage.sh
> > @@ -0,0 +1,9 @@
> > +#! /bin/sh
> > +# SPDX-License-Identifier: BSD-3-Clause
> > +# Copyright 2020 Mellanox Technologies, Ltd
> > +
> > +if [ "$(uname)" = "Linux" ] ; then
> > +       cat /proc/sys/vm/nr_hugepages || echo 0
> > +else
> > +       echo 0
> > +fi
> > diff --git a/app/test/meson.build b/app/test/meson.build
> > index 777c536ae0..04b59cffa4 100644
> > --- a/app/test/meson.build
> > +++ b/app/test/meson.build
> > @@ -396,15 +396,7 @@ dpdk_test = executable('dpdk-test',
> >         install_rpath: driver_install_path,
> >         install: true)
> >
> > -has_hugepage = true
> > -if is_linux
> > -       check_hugepage = run_command('cat',
> > -                                    '/proc/sys/vm/nr_hugepages')
> > -       if (check_hugepage.returncode() != 0 or
> > -           check_hugepage.stdout().strip() == '0')
> > -               has_hugepage = false
> > -       endif
> > -endif
> > +has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0'
> 
> This change will force no-huge mode on FreeBSD while before we were
> running with hugepages.

Indeed

I propose to squash this change to maintain the old behaviour:

+elif [ "$(uname)" = "FreeBSD" ] ; then
+       echo 1 # assume FreeBSD always has hugepages
  
David Marchand April 15, 2020, 1:49 p.m. UTC | #5
On Wed, Apr 15, 2020 at 3:40 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > This change will force no-huge mode on FreeBSD while before we were
> > running with hugepages.
>
> Indeed
>
> I propose to squash this change to maintain the old behaviour:
>
> +elif [ "$(uname)" = "FreeBSD" ] ; then
> +       echo 1 # assume FreeBSD always has hugepages
>

Ok for me.
  
Thomas Monjalon April 15, 2020, 1:56 p.m. UTC | #6
15/04/2020 15:49, David Marchand:
> On Wed, Apr 15, 2020 at 3:40 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > This change will force no-huge mode on FreeBSD while before we were
> > > running with hugepages.
> >
> > Indeed
> >
> > I propose to squash this change to maintain the old behaviour:
> >
> > +elif [ "$(uname)" = "FreeBSD" ] ; then
> > +       echo 1 # assume FreeBSD always has hugepages
> >
> 
> Ok for me.

OK, squashed:
	http://git.dpdk.org/dpdk/commit/?id=5f1a4a8a125672
  

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index 144cf5d8ea..fe59f0224f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1469,6 +1469,7 @@  F: app/test/Makefile
 F: app/test/autotest*
 F: app/test/commands.c
 F: app/test/get-coremask.sh
+F: app/test/has-hugepage.sh
 F: app/test/packet_burst_generator.c
 F: app/test/packet_burst_generator.h
 F: app/test/process.h
diff --git a/app/test/has-hugepage.sh b/app/test/has-hugepage.sh
new file mode 100755
index 0000000000..865e66cddd
--- /dev/null
+++ b/app/test/has-hugepage.sh
@@ -0,0 +1,9 @@ 
+#! /bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2020 Mellanox Technologies, Ltd
+
+if [ "$(uname)" = "Linux" ] ; then
+	cat /proc/sys/vm/nr_hugepages || echo 0
+else
+	echo 0
+fi
diff --git a/app/test/meson.build b/app/test/meson.build
index 777c536ae0..04b59cffa4 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -396,15 +396,7 @@  dpdk_test = executable('dpdk-test',
 	install_rpath: driver_install_path,
 	install: true)
 
-has_hugepage = true
-if is_linux
-	check_hugepage = run_command('cat',
-				     '/proc/sys/vm/nr_hugepages')
-	if (check_hugepage.returncode() != 0 or
-	    check_hugepage.stdout().strip() == '0')
-		has_hugepage = false
-	endif
-endif
+has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0'
 message('hugepage availability: @0@'.format(has_hugepage))
 
 # some perf tests (eg: memcpy perf autotest)take very long