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 <hailiangx.e.wang@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/369546
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Hailiang Wang 2017-08-31 02:20:22 +08:00 committed by Daniel Verkamp
parent 0722434074
commit f062f79768
4 changed files with 17 additions and 12 deletions

View File

@ -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. 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. 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). By default, the SPDK `setup.sh` script only allocates 2GB.
The following will allocate 5GB worth of 2MB huge pages (in addition to binding the NVMe devices to uio/vfio). The following will allocate 5GB of huge page memory (in addition to binding the NVMe devices to uio/vfio).
If using 1GB huge pages, adjust the `NRHUGE` value accordingly.
~~~{.sh} ~~~{.sh}
NRHUGE=2560 scripts/setup.sh HUGEMEM=5120 scripts/setup.sh
~~~ ~~~
Create an empty SPDK blobfs for testing. Create an empty SPDK blobfs for testing.

View File

@ -105,13 +105,16 @@ To rebind devices back to the kernel, you can run
sudo scripts/setup.sh reset sudo scripts/setup.sh reset
~~~ ~~~
By default, the script allocates 1024 2MB hugepages. To change this number, By default, the script allocates 2048MB of hugepages. To change this number,
specify NRHUGE as follows: specify HUGEMEM (in MB) as follows:
~~~{.sh} ~~~{.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 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 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 with no arguments to see the help output. If your system has its IOMMU

View File

@ -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 $2}' | sed 's/)//g' \
| awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g'` | awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g'`
# Override the default NRHUGE in scripts/setup.sh # Override the default HUGEMEM in scripts/setup.sh
export NRHUGE=4096 export HUGEMEM=8192
case `uname` in case `uname` in
FreeBSD) FreeBSD)

View File

@ -239,7 +239,7 @@ function configure_freebsd {
rm $TMP rm $TMP
kldunload contigmem.ko || true 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)) kenv hw.contigmem.buffer_size=$((256 * 1024 * 1024))
kldload contigmem.ko kldload contigmem.ko
} }
@ -249,8 +249,6 @@ function reset_freebsd {
kldunload nic_uio.ko || true kldunload nic_uio.ko || true
} }
: ${NRHUGE:=1024}
username=$1 username=$1
mode=$2 mode=$2
@ -270,7 +268,12 @@ if [ "$username" = "" ]; then
fi fi
fi fi
: ${HUGEMEM:=2048}
if [ `uname` = Linux ]; then 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 if [ "$mode" == "config" ]; then
configure_linux configure_linux
elif [ "$mode" == "reset" ]; then elif [ "$mode" == "reset" ]; then