summaryrefslogtreecommitdiffstats
path: root/ci/envs
diff options
context:
space:
mode:
authorJiang, Yunhong <yunhong.jiang@intel.com>2016-01-06 03:28:20 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-01-06 03:28:20 +0000
commitc62485d24a1f1eac3ec655a214b64198dfad7819 (patch)
tree675274ae6c9b4dc28cb753505c10ddd4ac7a5346 /ci/envs
parent4f32d7e65d2df10accf0a410fd62eabd12dd6f43 (diff)
parentd792accb76bb16af0cbf0710a41491d21de75721 (diff)
Merge "Add host environment setup scripts"
Diffstat (limited to 'ci/envs')
-rw-r--r--ci/envs/host-config19
-rwxr-xr-xci/envs/host-setup0.sh76
-rwxr-xr-xci/envs/host-setup1.sh76
3 files changed, 171 insertions, 0 deletions
diff --git a/ci/envs/host-config b/ci/envs/host-config
new file mode 100644
index 000000000..ce6243ce0
--- /dev/null
+++ b/ci/envs/host-config
@@ -0,0 +1,19 @@
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+# Isolated cpus for nfv, must be delimited with ','
+host_isolcpus=3,4
+
+# Number of huge pages to create and on which NUMA node
+numa_node=0
+huge_pages=2
+
+# QEMU executable path and number of cpus for guest
+qemu=/usr/libexec/qemu-kvm
+guest_cpus=2
diff --git a/ci/envs/host-setup0.sh b/ci/envs/host-setup0.sh
new file mode 100755
index 000000000..eeb91c19d
--- /dev/null
+++ b/ci/envs/host-setup0.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+source host-config
+
+rpmdir=${1:-"/root/workspace/rpm/"}
+rpmpat="kernel-4.1*.rpm"
+
+config_grub () {
+ key=$1
+ val=$2
+
+ if grep '[" ]'${key} /etc/default/grub > /dev/null ; then
+ sed -i 's/\([" ]\)'${key}'=[^ "]*/\1'${key}'='${val}'/' /etc/default/grub
+ else
+ sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="\1 '${key}'='${val}'"/' /etc/default/grub
+ fi
+}
+
+# The script's caller should passing the rpm directory that is built out from
+# build.sh. The default rpmdir is the one used by yardstick scripts.
+install_kernel () {
+ # Install the kernel rpm
+ filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
+ if [ $filenum -eq 0 ]
+ then
+ echo "No kernel rpm found in workspace/rpm"
+ exit 1
+ elif [ $filenum -gt 1 ]
+ then
+ echo "Multiple kernel rpm found in workspace/rpm"
+ exit 1
+ else
+ krpm=`find "${rpmdir}" -name "${rpmpat}"`
+ rpm -ihv $krpm
+ fi
+}
+
+# Isolate CPUs from the general scheduler
+config_grub 'isolcpus' ${host_isolcpus}
+
+# Stop timer ticks on isolated CPUs whenever possible
+config_grub 'nohz_full' ${host_isolcpus}
+
+# Do not call RCU callbacks on isolated CPUs
+config_grub 'rcu_nocbs' ${host_isolcpus}
+
+# Enable intel iommu driver and disable DMA translation for devices
+config_grub 'iommu' 'pt'
+config_grub 'intel_iommu' 'on'
+
+# Set HugeTLB pages to 1GB
+config_grub 'default_hugepagesz' '1G'
+config_grub 'hugepagesz' '1G'
+
+# Disable machine check
+config_grub 'mce' 'off'
+
+## Use polling idle loop to improve performance
+config_grub 'idle' 'poll'
+
+## Disable clocksource verification at runtime
+config_grub 'tsc' 'reliable'
+
+sed -i s/GRUB_DEFAULT=saved/GRUB_DEFAULT=0/ /etc/default/grub
+grub2-mkconfig -o /boot/grub2/grub.cfg
+
+install_kernel
diff --git a/ci/envs/host-setup1.sh b/ci/envs/host-setup1.sh
new file mode 100755
index 000000000..3d2de6ddf
--- /dev/null
+++ b/ci/envs/host-setup1.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+source host-config
+
+
+##############################
+# Create 1GB pages for guest #
+##############################
+
+hugepage_size=`cat /proc/meminfo |grep Hugepagesize |tr -s " "| cut -f 2 -d " "`
+if [[ $hugepage_size -ne 1048576 ]]
+then
+ echo "Need 1G huge page support for performance benefit"
+ exit 1
+fi
+
+mkdir -p /mnt/hugetlbfs-1g
+mount -t hugetlbfs hugetlbfs /mnt/hugetlbfs-1g -osize=1G
+
+hugepage_dir="/sys/devices/system/node/node${numa_node}/hugepages/hugepages-1048576kB/nr_hugepages"
+
+huge_pages+=`cat $hugepage_dir`
+echo ${huge_pages} > ${hugepage_dir}
+
+############################
+# RT optimization #
+############################
+# Disable watchdogs to reduce overhead
+echo 0 > /proc/sys/kernel/watchdog
+echo 0 > /proc/sys/kernel/nmi_watchdog
+
+# Change RT priority of ksoftirqd and rcuc kernel threads on isolated CPUs
+i=0
+for c in `echo $host_isolcpus | sed 's/,/ /g'` ; do
+ tid=`pgrep -a ksoftirq | grep "ksoftirqd/${c}$" | cut -d ' ' -f 1`
+ chrt -fp 2 ${tid}
+
+ tid=`pgrep -a rcuc | grep "rcuc/${c}$" | cut -d ' ' -f 1`
+ chrt -fp 3 ${tid}
+
+ cpu[$i]=${c}
+ i=`expr $i + 1`
+done
+
+# Change RT priority of rcub kernel threads
+for tid in `pgrep -a rcub | cut -d ' ' -f 1` ; do
+ chrt -fp 3 ${tid}
+done
+
+# Disable RT throttling
+echo -1 > /proc/sys/kernel/sched_rt_period_us
+echo -1 > /proc/sys/kernel/sched_rt_runtime_us
+
+# Reroute interrupts bound to isolated CPUs to CPU 0
+for irq in /proc/irq/* ; do
+ if [ -d ${irq} ] && ! grep - ${irq}/smp_affinity_list > /dev/null ; then
+ al=`cat ${irq}/smp_affinity_list`
+ if [[ ${cpu[*]} =~ ${al} ]] ; then
+ echo 0 > ${irq}/smp_affinity_list
+ fi
+ fi
+done
+
+# Change the iptable so that we can ssh to the guest remotely
+iptables -I INPUT -p tcp --dport 5555 -j ACCEPT
+# TODO: download guest disk image from artifactory
+