From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 33387A0577; Mon, 6 Apr 2020 10:50:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F10581BEE3; Mon, 6 Apr 2020 10:50:51 +0200 (CEST) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by dpdk.org (Postfix) with ESMTP id B45391BED9 for ; Mon, 6 Apr 2020 10:50:50 +0200 (CEST) Received: by mail-lj1-f196.google.com with SMTP id n17so13726745lji.8 for ; Mon, 06 Apr 2020 01:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=OFZdy+fPDbkkk3CIkbBzv695167bz7xjg6hqQCGIOV8=; b=ABSrATan4ikhw6dLDKiF8jRa3jCIRqdUWq6awWw2VHeRMYQcU+NBIqp2ShPBo0KNmm BYkJmdEOPrpRRTNCku1yz89x9YlBrFzCwLGfeGveFDrzdkoMGZ8fwDgdOI73UVWJE3Q4 PWiPk1ZNadm3VO8g1d30X9eweHlGfAhu6khj0hZUI+Ompz/f8dUXoEN183v1DvVsM12z O2YLOpmhFW6Dpxta52xgyjmf6a4HkyoDHxX3DfrLy6WSylwzVhIsaziCBHeVDMJCs6XE ExIBkehp/lLxfb6saq1uUz1E2oDYwMYHa+L43sVweJgEue36GUqbet6SvOMn6etyyDz/ SmXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OFZdy+fPDbkkk3CIkbBzv695167bz7xjg6hqQCGIOV8=; b=WmCvUrmSCj8lF1iDQU0O2GQE50p27eUjzrHyjV0SGEkZZFxiOaV+VVhSxZEST2BCM1 VlTa+Qkk7fuEoUheYl5+X5pTGdX/3fETd9vVEwJQS54k5B6UM2XerSaXLUfq3+CfOMEV 5MbeToa5qpTragLHcQKzAHF+WvAtcu7ET4ZRtFJa2GOa2XnpgFCSI5mCW5tUmyyCJZYn kQSBQRLZGUyW4kfddLhqCAX4utMVDUf7mJ/HbmnEK0UAlS17gqaO/ClmtTVdClFqQQV8 zjFy5eM+onsyvYXuILjzEtn6lV2RT4zGwnfcUsNbVHPKbI9U8rE7tfIe+1ABmhm2Qe2x kXKg== X-Gm-Message-State: AGi0PuZ9Q6b97Wxa8nDvTgxfqATMQoYoBp0v0C5GbfAi7fmotXnCyDZ/ D8CsD/RxDKDmq1OMYjPGBc3IMw== X-Google-Smtp-Source: APiQypIJX0LuUXBp/TLpJjgpP2YJA4hZZBcHnkP9FPqcb4806h5NKdIHfvym2+Ci22yd3kui0vzUDQ== X-Received: by 2002:a2e:914b:: with SMTP id q11mr11384130ljg.291.1586163050040; Mon, 06 Apr 2020 01:50:50 -0700 (PDT) Received: from localhost.localdomain ([103.255.6.82]) by smtp.gmail.com with ESMTPSA id m13sm255450lfk.12.2020.04.06.01.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 01:50:49 -0700 (PDT) From: Muhammad Bilal To: john.mcnamara@intel.com Cc: dev@dpdk.org, Muhammad Bilal , stable@dpdk.org Date: Mon, 6 Apr 2020 13:50:18 +0500 Message-Id: <20200406085018.25957-1-m.bilal@emumba.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] Nonnumeric input check for Setting hugepages X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Bugzilla ID: 432 Cc: dev@dpdk.org Cc: stable@dpdk.org Cc: john.mcnamara@intel.com Signed-off-by: Muhammad Bilal --- 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