xenserver: Renice netback process to priority 0 by default.
authorBen Pfaff <blp@nicira.com>
Wed, 19 Aug 2009 22:59:18 +0000 (15:59 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 19 Aug 2009 22:59:18 +0000 (15:59 -0700)
Under heavy VM network load, we have observed that ovs-vswitchd can be
starved for CPU time, which prevents flows from being set up.  This can
in turn cause connections to XAPI in Dom0 to time out (among other issues).

It is probably not necessary to renice netback all the way to priority 0
as done in this commit.  That is simply the value that we have tested.  QA
has not reported any ill side-effects of this choice of value (yet).  One
reasonable alternative, should any problems be noticed, would be to leave
netback at its default -5 priority and simply boost ovs-vswitchd's priority
to say -6 or -7.

Bug #1656.

xenserver/etc_init.d_vswitch
xenserver/etc_sysconfig_vswitch.example

index 83d84ec..abd594e 100755 (executable)
@@ -34,6 +34,7 @@ VSWITCHD_CONF="${VSWITCHD_CONF:-/etc/ovs-vswitchd.conf}"
 VSWITCHD_PIDFILE="${VSWITCHD_PIDFILE:-/var/run/ovs-vswitchd.pid}"
 VSWITCHD_RUN_DIR="${VSWITCHD_RUN_DIR:-/var/xen/vswitch}"
 VSWITCHD_PRIORITY="${VSWITCHD_PRIORITY:--5}"
+VSWITCHD_NETBACK_PRIORITY="${VSWITCHD_NETBACK_PRIORITY:-0}"
 VSWITCHD_LOGFILE="${VSWITCHD_LOGFILE:-/var/log/ovs-vswitchd.log}"
 VSWITCHD_FILE_LOGLEVEL="${VSWITCHD_FILE_LOGLEVEL:-}"
 VSWITCHD_SYSLOG_LOGLEVEL="${VSWITCHD_SYSLOG_LOGLEVEL:-WARN}"
@@ -115,6 +116,28 @@ function reload_vswitchd {
     fi
 }
 
+function quietly {
+    "$@" > /dev/null
+}
+
+# renice_netback PRIORITY PID [PID...]
+#
+# Renices the netback processes given as each PID to nice level PRIORITY.
+function renice_netback {
+    local pri=$1
+    shift
+
+    if test $# = 0; then
+        warning "Netback not running, nothing to renice"
+        return
+    fi
+
+    for pid
+    do
+        action "Renicing netback (pid $pid) to priority $pri" quietly renice $pri -p $pid
+    done
+}
+
 function start_vswitchd {
     local syslog_opt="-vANY:SYSLOG:${VSWITCHD_SYSLOG_LOGLEVEL}"
     local logfile_file_opt=""
@@ -152,6 +175,11 @@ function start_vswitchd {
     if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then
         fake_proc_net_opt="--fake-proc-net"
     fi
+    if [ "$VSWITCHD_NETBACK_PRIORITY" != default ]; then
+        renice_netback $VSWITCHD_NETBACK_PRIORITY $(pidof netback)
+    else
+        warning "Netback renicing disabled (see /etc/sysconfig/vswitch)"
+    fi
     if [ "$daemonize" != "y" ]; then
         # Start in background and force a "success" message
         action "Starting ovs-vswitchd ($strace_opt$valgrind_opt)" true
index 789d61a..ea8efe1 100644 (file)
 #     processes.
 # VSWITCHD_PRIORITY=-5
 
+# VSWITCHD_NETBACK_PRIORITY: "nice" priority at which to run netback.
+#     It is a good idea to run ovs-vswitchd at a higher priority than
+#     netback to ensure that it gets enough CPU time to set up flows
+#     (bug #1656).  Set this to 'default' to avoid changing netback's
+#     priority.
+# VSWITCHD_NETBACK_PRIORITY=0
+
 # VSWITCHD_LOGFILE: File to send the FILE_LOGLEVEL log messages to.
 # VSWITCHD_LOGFILE=/var/log/ovs-vswitchd.log