@@ -199,6 +199,11 @@ The following options are less important:
Sets the ``nice(1)`` level used for each daemon. All of them
default to ``-10``.
+* ``--ovsdb-server-affinity=<corelist>`` or
+ ``--ovs-vswitchd-affinity=<corelist>``
+
+ Sets the ``taskset(1)`` affinity for each daemon process.
+
* ``--ovsdb-server-wrapper=<wrapper>`` or
``--ovs-vswitchd-wrapper=<wrapper>``
@@ -157,7 +157,7 @@ do_start_ovsdb () {
[ "$OVSDB_SERVER_OPTIONS" != "" ] && set "$@" $OVSDB_SERVER_OPTIONS
start_daemon "$OVSDB_SERVER_PRIORITY" "$OVSDB_SERVER_WRAPPER" \
- "$OVSDB_SERVER_UMASK" "$@" || return 1
+ "$OVSDB_SERVER_UMASK" "$OVSDB_SERVER_AFFINITY" "$@" || return 1
# Initialize database settings.
ovs_vsctl -- init -- set Open_vSwitch . db-version="$schemaver" \
@@ -227,7 +227,7 @@ do_start_forwarding () {
[ "$OVS_VSWITCHD_OPTIONS" != "" ] &&set "$@" $OVS_VSWITCHD_OPTIONS
start_daemon "$OVS_VSWITCHD_PRIORITY" "$OVS_VSWITCHD_WRAPPER" \
- "$OVS_VSWITCHD_UMASK" "$@" || return 1
+ "$OVS_VSWITCHD_UMASK" "$OVS_VSWITCHD_AFFINITY" "$@" || return 1
fi
}
@@ -344,6 +344,8 @@ set_defaults () {
OVS_VSWITCHD=yes
OVSDB_SERVER_PRIORITY=-10
OVS_VSWITCHD_PRIORITY=-10
+ OVSDB_SERVER_AFFINITY=
+ OVS_VSWITCHD_AFFINITY=
OVSDB_SERVER_WRAPPER=
OVS_VSWITCHD_WRAPPER=
OVSDB_SERVER_OPTIONS=
@@ -436,8 +438,10 @@ Less important options for "start", "restart" and "force-reload-kmod":
--dump-hugepages include hugepages in core dumps
--no-mlockall do not lock all of ovs-vswitchd into memory
--ovsdb-server-priority=NICE set ovsdb-server's niceness (default: $OVSDB_SERVER_PRIORITY)
+ --ovsdb-server-affinity=CORE set ovsdb-server's affinity (default: $OVSDB_SERVER_AFFINITY)
--ovsdb-server-options=OPTIONS additional options for ovsdb-server (example: '-vconsole:dbg -vfile:dbg')
--ovs-vswitchd-priority=NICE set ovs-vswitchd's niceness (default: $OVS_VSWITCHD_PRIORITY)
+ --ovs-vswitchd-affinity=CORE set ovs-vswitchd's affinity (default: $OVS_VSWITCHD_AFFINITY)
--ovs-vswitchd-options=OPTIONS additional options for ovs-vswitchd (example: '-vconsole:dbg -vfile:dbg')
--no-full-hostname set short hostname instead of full hostname
--no-record-hostname do not attempt to determine/record system
@@ -168,6 +168,7 @@ start_daemon () {
priority=$1 && shift
wrapper=$1 && shift
umask=$1 && shift
+ affinity=$1 && shift
daemon=$1
strace=""
@@ -223,6 +224,11 @@ start_daemon () {
set nice -n "$priority" "$@"
fi
+ # affinity
+ if test X"$affinity" != X; then
+ set taskset -c "$affinity" "$@"
+ fi
+
# Set requested umask if any and turn previous value back.
if [ -n "$umask" ]; then
previuos_umask_value=$(umask)
Deployment with dpdk and spdk should limit the core of non-pmd threads. When starting ovs with ovs-ctl or systemd, the process will inherit the affinity of its parent process. Even if we manuanlly set the affinity, restarting after crash will lose the setting. Prepend taskset in ovs-ctl when start daemon, so it will set the affinity each time starting the ovs. Signed-off-by: Wan Junjie <wanjunjie@bytedance.com> --- Documentation/ref/ovs-ctl.8.rst | 5 +++++ utilities/ovs-ctl.in | 8 ++++++-- utilities/ovs-lib.in | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-)