DPDK patches and discussions
 help / color / mirror / Atom feed
From: Aaron Conole <aconole@redhat.com>
To: dev@dpdk.org
Cc: David Marchand <david.marchand@redhat.com>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: [dpdk-dev] [PATCH] test: make hugepage check more robust under Linux
Date: Wed, 17 Mar 2021 10:44:09 -0400
Message-ID: <20210317144409.288346-1-aconole@redhat.com> (raw)

The hugepage test really needs to check multiple things on Linux:

1. Are hugepages reserved in the system?

2. Is the hugepage mountpoint available so that we can allocate them?

3. Do we have permissions to write into the hugepage mountpoint?

The existing hugepage check only verifies the first.  On some setups,
a non-root user won't have access to the mountpoint for hugepages to
be allocated and that needs to be reflected in the test as well.  Add
such checks for Linux OS to give a more check when running test suites.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 app/test/has-hugepage.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/app/test/has-hugepage.sh b/app/test/has-hugepage.sh
index d600fad319..1c3cfb665a 100755
--- a/app/test/has-hugepage.sh
+++ b/app/test/has-hugepage.sh
@@ -3,7 +3,17 @@
 # Copyright 2020 Mellanox Technologies, Ltd
 
 if [ "$(uname)" = "Linux" ] ; then
-	cat /proc/sys/vm/nr_hugepages || echo 0
+	nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
+	# Need to check if we have permissions to access hugepages
+	perm=""
+	for mount in `mount | grep hugetlbfs | awk '{ print $3; }'`; do
+		test ! -w $mount/. || perm="$mount"
+	done
+	if [ "$perm" = "" -o "$nr_hugepages" = "0" ]; then
+		echo 0
+	else
+		echo $nr_hugepages
+	fi
 elif [ "$(uname)" = "FreeBSD" ] ; then
 	echo 1 # assume FreeBSD always has hugepages
 else
-- 
2.25.4


             reply	other threads:[~2021-03-17 14:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 14:44 Aaron Conole [this message]
2021-03-17 14:57 ` Thomas Monjalon
2021-04-06 12:33   ` Aaron Conole
2021-04-06 12:58     ` Bruce Richardson
2021-04-06 14:20       ` Aaron Conole
2021-04-06 14:50         ` Bruce Richardson
2021-04-09 15:06           ` Aaron Conole
2021-04-09 15:33             ` Thomas Monjalon
2021-04-12 11:33               ` David Marchand
2021-04-09 15:40             ` Bruce Richardson
2021-03-19 13:41 ` David Marchand
2021-03-19 14:34   ` Aaron Conole

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210317144409.288346-1-aconole@redhat.com \
    --to=aconole@redhat.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git