diff --git a/README.md b/README.md index 9cb2b7ac47..76ab91bd09 100644 --- a/README.md +++ b/README.md @@ -87,11 +87,10 @@ Hugepages and Device Binding Before running an SPDK application, some hugepages must be allocated and any NVMe and I/OAT devices must be unbound from the native kernel drivers. -SPDK includes scripts to automate this process on both Linux and FreeBSD. -Both of these scripts should be run as root. +SPDK includes a script to automate this process on both Linux and FreeBSD. +This script should be run as root. - 1) scripts/configure_hugepages.sh - 2) scripts/setup.sh + sudo scripts/setup.sh Examples ======== diff --git a/autotest.sh b/autotest.sh index fffcd21342..f12bb8afe9 100755 --- a/autotest.sh +++ b/autotest.sh @@ -35,7 +35,6 @@ fi # set up huge pages timing_enter afterboot -./scripts/configure_hugepages.sh 1024 ./scripts/setup.sh timing_exit afterboot diff --git a/scripts/configure_hugepages.sh b/scripts/configure_hugepages.sh deleted file mode 100755 index 0907d8e5c5..0000000000 --- a/scripts/configure_hugepages.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -e - -function configure_linux { - if mount | grep -qv hugetlbfs; then - mkdir -p /mnt/huge - mount -t hugetlbfs nodev /mnt/huge - fi - - echo $NRHUGE > /proc/sys/vm/nr_hugepages -} - -function configure_freebsd { - kldunload contigmem.ko || true - kenv hw.contigmem.num_buffers=$((NRHUGE * 2 / 32)) - kenv hw.contigmem.buffer_size=$((32 * 1024 * 1024)) - kldload contigmem.ko -} - -if [ "$1" = "" ]; then - NRHUGE=1024 -else - NRHUGE="$1" -fi - -if [ `uname` = Linux ]; then - configure_linux -else - configure_freebsd -fi - diff --git a/scripts/setup.sh b/scripts/setup.sh index 96e7248636..50573160c9 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -63,6 +63,12 @@ function configure_linux { rm $TMP echo "1" > "/sys/bus/pci/rescan" + + if ! mount | grep -q hugetlbs; then + mkdir -p /mnt/huge + mount -t hugetlbfs nodev /mnt/huge + fi + echo "$NRHUGE" > /proc/sys/vm/nr_hugepages } function reset_linux { @@ -101,6 +107,11 @@ function configure_freebsd { kenv hw.nic_uio.bdfs=$BDFS kldload nic_uio.ko rm $TMP + + kldunload contigmem.ko || true + kenv hw.contigmem.num_buffers=$((NRHUGE * 2 / 32)) + kenv hw.contigmem.buffer_size=$((32 * 1024 * 1024)) + kldload contigmem.ko } function reset_freebsd { @@ -108,6 +119,8 @@ function reset_freebsd { kldunload nic_uio.ko || true } +NRHUGE=1024 + mode=$1 if [ "$mode" == "" ]; then mode="config"