From 2877589c9c2d04eccb575aa0f6e2bd4f62806203 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter.cai@uwaterloo.ca>
Date: Mon, 13 Feb 2023 17:19:02 -0500
Subject: [PATCH] Add tunings to normalize IRQs and polling settings before
 experiments

---
 run.sh                      |  3 +++
 tunings/base.sh             | 11 +++++++++++
 tunings/normalize_queues.sh |  3 +++
 3 files changed, 17 insertions(+)
 create mode 100644 tunings/normalize_queues.sh

diff --git a/run.sh b/run.sh
index f9487fa..b254f86 100755
--- a/run.sh
+++ b/run.sh
@@ -10,6 +10,7 @@ fi
 export EXP_ROOT="$PWD"
 
 source ./configs/base.sh
+source ./configs/nic.sh
 
 if [ -e "./configs/$(uname -r).sh" ]; then
     echo "Loading kernel-specific config for $(uname -r)"
@@ -55,6 +56,8 @@ DATA_OUT="$EXP_ROOT/data/$EXPERIMENT_NAME"
 rm -rf "$DATA_OUT"
 mkdir -p "$DATA_OUT"
 
+source ./tunings/normalize_queues.sh
+
 run_exp
 
 post_start
diff --git a/tunings/base.sh b/tunings/base.sh
index 6b5094d..0224423 100644
--- a/tunings/base.sh
+++ b/tunings/base.sh
@@ -14,3 +14,14 @@ echo 0 > /proc/sys/kernel/nmi_watchdog              # perf cache tracing
 # CPU frequency
 $X86_ENERGY_PERF_POLICY --turbo-enable 0
 $CPUPOWER frequency-set -f 2.7GHz || true # This can throw out errors but it's generally harmless
+
+# Default non-polling NIC settings
+# ethtool may fail without fatal errors (e.g. when it made no changes)
+ethtool -G $NET_IF rx 1024 || true
+ethtool -C $NET_IF rx-usecs  16 rx-frames   44 adaptive-rx on || true
+ethtool -C $NET_IF tx-usecs  16 tx-frames   16 adaptive-tx off || true
+sysctl net.core.busy_poll=0
+sysctl net.core.busy_read=0
+sysctl net.core.dev_weight=64
+sysctl net.core.netdev_budget=300
+sysctl net.core.netdev_budget_usecs=8000
diff --git a/tunings/normalize_queues.sh b/tunings/normalize_queues.sh
new file mode 100644
index 0000000..48e878a
--- /dev/null
+++ b/tunings/normalize_queues.sh
@@ -0,0 +1,3 @@
+ethtool -L $NET_IF rx $THREADS tx $THREADS || true
+$EXP_ROOT/irq.sh set 0 $((THREADS - 1))
+$EXP_ROOT/irq.sh set rx 0 $((THREADS - 1))
-- 
GitLab