patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Muhammad Bilal <m.bilal@emumba.com>
To: john.mcnamara@intel.com
Cc: dev@dpdk.org, Muhammad Bilal <m.bilal@emumba.com>, stable@dpdk.org
Subject: [dpdk-stable] [PATCH] Nonnumeric input check for Setting hugepages
Date: Mon,  6 Apr 2020 13:50:18 +0500	[thread overview]
Message-ID: <20200406085018.25957-1-m.bilal@emumba.com> (raw)

Bugzilla ID: 432
Cc: dev@dpdk.org
Cc: stable@dpdk.org
Cc: john.mcnamara@intel.com
Signed-off-by: Muhammad Bilal <m.bilal@emumba.com>
---
 usertools/dpdk-setup.sh | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/usertools/dpdk-setup.sh b/usertools/dpdk-setup.sh
index e5bbe9fee..b0535be34 100755
--- a/usertools/dpdk-setup.sh
+++ b/usertools/dpdk-setup.sh
@@ -321,13 +321,19 @@ set_non_numa_pages()
 	echo -n "Number of pages: "
 	read Pages
 
-	echo "echo $Pages > /sys/kernel/mm/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages" > .echo_tmp
 
-	echo "Reserving hugepages"
-	sudo sh .echo_tmp
-	rm -f .echo_tmp
+	numeric="^[[:digit:]]+$"
+	PG_PATH="/sys/kernel/mm/hugepages/hugepages-${HUGEPGSZ}"
+    	if [[ $Pages =~ $numeric ]]; then
+		echo "echo $Pages > $PG_PATH/nr_hugepages" > .echo_tmp
+		echo "Reserving hugepages"
+		sudo sh .echo_tmp
+		rm -f .echo_tmp
 
-	create_mnt_huge
+		create_mnt_huge
+	else
+		echo "Please enter a numeric value"
+	fi
 }
 
 #
@@ -343,10 +349,17 @@ set_numa_pages()
 	echo "  enter '64' to reserve 64 * 2MB pages on each node"
 
 	echo > .echo_tmp
+	numeric="^[[:digit:]]+$"
 	for d in /sys/devices/system/node/node? ; do
 		node=$(basename $d)
 		echo -n "Number of pages for $node: "
 		read Pages
+		while [[ ! "$Pages" =~ $numeric ]]; do
+			echo "Please enter a numeric value"
+			echo -n "Number of pages for $node: "
+			read Pages
+		done
+
 		echo "echo $Pages > $d/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages" >> .echo_tmp
 	done
 	echo "Reserving hugepages"
-- 
2.17.1


             reply	other threads:[~2020-04-06  8:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06  8:50 Muhammad Bilal [this message]
2020-11-26 17:52 ` Thomas Monjalon

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=20200406085018.25957-1-m.bilal@emumba.com \
    --to=m.bilal@emumba.com \
    --cc=dev@dpdk.org \
    --cc=john.mcnamara@intel.com \
    --cc=stable@dpdk.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).