From c83f9378da97582d31eeb1675c649c4efe6ef08f Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 14 Apr 2016 13:22:11 -0700 Subject: [PATCH] scripts: merge hugepage config into setup.sh For now, drop the option to configure the number of hugepages (just use the default 1024). Change-Id: I686b6151e4a32ffa4ae9a9cf2694693369e03f49 Signed-off-by: Daniel Verkamp --- README.md | 7 +++---- autotest.sh | 1 - scripts/configure_hugepages.sh | 32 -------------------------------- scripts/setup.sh | 13 +++++++++++++ 4 files changed, 16 insertions(+), 37 deletions(-) delete mode 100755 scripts/configure_hugepages.sh diff --git a/README.md b/README.md index 9cb2b7ac4..76ab91bd0 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 fffcd2134..f12bb8afe 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 0907d8e5c..000000000 --- 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 96e724863..50573160c 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"