From 76d3082421fa0cb6279981d69299e6c8d036aa06 Mon Sep 17 00:00:00 2001 From: David Sullivan Date: Sun, 27 Jan 2019 23:16:57 -0500 Subject: [PATCH] Platform process pinning Add a service to pin processes back to platform cores after affine-platform. Previously this was done during the nova-compute wrapper script. In kubernetes this script is not run so we need to add a new service to pin tasks back to the platform cores. Depends-On: https://review.openstack.org/#/c/634035/ Story: 2002843 Task: 29125 Change-Id: Ia8ccacb5546a8ea66010b024fe04ed39f9ef447d Signed-off-by: David Sullivan --- worker-utils/centos/build_srpm.data | 2 +- worker-utils/centos/worker-utils.spec | 2 + worker-utils/worker-utils/Makefile | 2 + .../worker-utils/affine-tasks.service | 12 ++++ worker-utils/worker-utils/affine-tasks.sh | 71 +++++++++++++++++++ 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 worker-utils/worker-utils/affine-tasks.service create mode 100644 worker-utils/worker-utils/affine-tasks.sh diff --git a/worker-utils/centos/build_srpm.data b/worker-utils/centos/build_srpm.data index 8a107e9769..25eb4441d4 100644 --- a/worker-utils/centos/build_srpm.data +++ b/worker-utils/centos/build_srpm.data @@ -1,3 +1,3 @@ SRC_DIR="worker-utils" COPY_LIST="$SRC_DIR/LICENSE" -TIS_PATCH_VER=1 +TIS_PATCH_VER=2 diff --git a/worker-utils/centos/worker-utils.spec b/worker-utils/centos/worker-utils.spec index 560b41e361..73d7d2bf11 100644 --- a/worker-utils/centos/worker-utils.spec +++ b/worker-utils/centos/worker-utils.spec @@ -39,6 +39,7 @@ make install BINDIR=%{buildroot}%{local_bindir} \ %post /bin/systemctl enable affine-platform.sh.service >/dev/null 2>&1 +/bin/systemctl enable affine-tasks.service >/dev/null 2>&1 %clean rm -rf $RPM_BUILD_ROOT @@ -53,3 +54,4 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) %{local_etc_platform}/worker_reserved.conf %{_unitdir}/affine-platform.sh.service +%{_unitdir}/affine-tasks.service diff --git a/worker-utils/worker-utils/Makefile b/worker-utils/worker-utils/Makefile index 97ab6c607b..a7c3cca568 100644 --- a/worker-utils/worker-utils/Makefile +++ b/worker-utils/worker-utils/Makefile @@ -18,6 +18,7 @@ install: install -d -m 755 $(PLATFORMCONFDIR) install -d -m 755 $(SYSTEMDDIR) install -p -D -m 755 affine-platform.sh $(INITDDIR)/affine-platform.sh + install -p -D -m 755 affine-tasks.sh $(INITDDIR)/affine-tasks.sh install -p -D -m 755 cpumap_functions.sh $(INITDDIR)/cpumap_functions.sh install -p -D -m 755 task_affinity_functions.sh $(INITDDIR)/task_affinity_functions.sh install -p -D -m 755 ps-sched.sh $(BINDIR)/ps-sched.sh @@ -29,3 +30,4 @@ install: install -p -D -m 755 worker_reserved.conf $(PLATFORMCONFDIR)/worker_reserved.conf install -p -D -m 755 worker-goenabled.sh $(GOENABLEDDIR)/worker-goenabled.sh install -p -D -m 664 affine-platform.sh.service $(SYSTEMDDIR)/affine-platform.sh.service + install -p -D -m 664 affine-tasks.service $(SYSTEMDDIR)/affine-tasks.service diff --git a/worker-utils/worker-utils/affine-tasks.service b/worker-utils/worker-utils/affine-tasks.service new file mode 100644 index 0000000000..6bf2a81b51 --- /dev/null +++ b/worker-utils/worker-utils/affine-tasks.service @@ -0,0 +1,12 @@ +[Unit] +Description=StarlingX Affine Tasks +After=syslog.service network.service dbus.service sw-patch.service affine-platform.sh.service +Before=kubelet.service +Requires=kubelet.service + +[Service] +Type=oneshot +ExecStart=/etc/init.d/affine-tasks.sh start + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/worker-utils/worker-utils/affine-tasks.sh b/worker-utils/worker-utils/affine-tasks.sh new file mode 100644 index 0000000000..72eb67ee94 --- /dev/null +++ b/worker-utils/worker-utils/affine-tasks.sh @@ -0,0 +1,71 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +############################################################################### + +# This script will affine tasks to the platform cores of the host. +# This ensures that system processes are constrained to platform cores and will +# not run on cores with VMs/containers. + +. /usr/bin/tsconfig +. /etc/init.d/task_affinity_functions.sh + +log () +{ + logger -p local1.info -t affine_tasks $@ + echo affine_tasks: "$@" +} + +start () +{ + log "Starting affine_tasks. Reaffining tasks to platform cores..." + if [ ! -f ${INITIAL_CONFIG_COMPLETE_FLAG} ]; then + log "Initial Configuration incomplete. Skipping affining tasks." + exit 0 + fi + affine_tasks_to_platform_cores + [[ $? -eq 0 ]] && log "Tasks re-affining done." || log "Tasks re-affining failed." +} + +stop () +{ + log "Stopping affine_tasks..." +} + +status() +{ + : +} + +reset() +{ + : +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|force-reload|reload) + stop + start + ;; + status) + status + ;; + reset) + reset + ;; + *) + echo "Usage: $0 {start|stop|force-reload|restart|reload|status|reset}" + exit 1 + ;; +esac + +exit 0 \ No newline at end of file