From f062f79768f46bdfe6c2791bff92e5c611805a03 Mon Sep 17 00:00:00 2001 From: Hailiang Wang Date: Thu, 31 Aug 2017 02:20:22 +0800 Subject: [PATCH] scripts: replace NRHUGE with HUGEMEM in setup.sh This allows to use same command for allocating hugepages on systems with different hugepage sizes. The old NRHUGE variable can be still set on Linux machines, but is currently undocumented. Change-Id: I1fba315d95e9aae8b6a8c9c445deb447fecc65dc Signed-off-by: Hailiang Wang Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/369546 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- doc/blobfs.md | 7 +++---- doc/getting_started.md | 9 ++++++--- scripts/autotest_common.sh | 4 ++-- scripts/setup.sh | 9 ++++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/doc/blobfs.md b/doc/blobfs.md index 1fb14b18a..e0ad29fe7 100644 --- a/doc/blobfs.md +++ b/doc/blobfs.md @@ -46,12 +46,11 @@ Verify the configuration file has specified the correct NVMe SSD. If there are any NVMe SSDs you do not wish to use for RocksDB/SPDK testing, remove them from the configuration file. Make sure you have at least 5GB of memory allocated for huge pages. -By default, the SPDK `setup.sh` script only allocates 2GB (1024 huge pages). -The following will allocate 5GB worth of 2MB huge pages (in addition to binding the NVMe devices to uio/vfio). -If using 1GB huge pages, adjust the `NRHUGE` value accordingly. +By default, the SPDK `setup.sh` script only allocates 2GB. +The following will allocate 5GB of huge page memory (in addition to binding the NVMe devices to uio/vfio). ~~~{.sh} -NRHUGE=2560 scripts/setup.sh +HUGEMEM=5120 scripts/setup.sh ~~~ Create an empty SPDK blobfs for testing. diff --git a/doc/getting_started.md b/doc/getting_started.md index 65523c59c..0b948d259 100644 --- a/doc/getting_started.md +++ b/doc/getting_started.md @@ -105,13 +105,16 @@ To rebind devices back to the kernel, you can run sudo scripts/setup.sh reset ~~~ -By default, the script allocates 1024 2MB hugepages. To change this number, -specify NRHUGE as follows: +By default, the script allocates 2048MB of hugepages. To change this number, +specify HUGEMEM (in MB) as follows: ~~~{.sh} -sudo NRHUGE=4096 scripts/setup.sh +sudo HUGEMEM=4096 scripts/setup.sh ~~~ +On Linux machines HUGEMEM will be rounded up to system-default huge page +size boundary. + Example code is located in the examples directory. The examples are compiled automatically as part of the build process. Simply call any of the examples with no arguments to see the help output. If your system has its IOMMU diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index a658aff04..850bb2afd 100755 --- a/scripts/autotest_common.sh +++ b/scripts/autotest_common.sh @@ -43,8 +43,8 @@ export SPDK_GPT_GUID=`grep SPDK_GPT_PART_TYPE_GUID $rootdir/lib/bdev/gpt/gpt.h \ | awk -F "(" '{ print $2}' | sed 's/)//g' \ | awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g'` -# Override the default NRHUGE in scripts/setup.sh -export NRHUGE=4096 +# Override the default HUGEMEM in scripts/setup.sh +export HUGEMEM=8192 case `uname` in FreeBSD) diff --git a/scripts/setup.sh b/scripts/setup.sh index 33c0417f4..419e782ba 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -239,7 +239,7 @@ function configure_freebsd { rm $TMP kldunload contigmem.ko || true - kenv hw.contigmem.num_buffers=$((NRHUGE * 2 / 256)) + kenv hw.contigmem.num_buffers=$((HUGEMEM / 256)) kenv hw.contigmem.buffer_size=$((256 * 1024 * 1024)) kldload contigmem.ko } @@ -249,8 +249,6 @@ function reset_freebsd { kldunload nic_uio.ko || true } -: ${NRHUGE:=1024} - username=$1 mode=$2 @@ -270,7 +268,12 @@ if [ "$username" = "" ]; then fi fi +: ${HUGEMEM:=2048} + if [ `uname` = Linux ]; then + HUGEPGSZ=$(( `grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'` / 1024 )) + : ${NRHUGE=$(( (HUGEMEM + HUGEPGSZ - 1) / HUGEPGSZ ))} + if [ "$mode" == "config" ]; then configure_linux elif [ "$mode" == "reset" ]; then