config/worker-utils/worker-utils/affine-interrupts.sh
Tao Liu 6256b0d106 Change compute node to worker node personality
This update replaced the compute personality & subfunction
to worker, and updated internal and customer visible
references.

In addition, the compute-huge package has been renamed to
worker-utils as it contains various scripts/services that
used to affine running tasks or interface IRQ to specific CPUs.
The worker_reserved.conf is now installed to /etc/platform.

The cpu function 'VM' has also been renamed to 'Application'.

Tests Performed:
Non-containerized deployment
AIO-SX: Sanity and Nightly automated test suite
AIO-DX: Sanity and Nightly automated test suite
2+2 System: Sanity and Nightly automated test suite
2+2 System: Horizon Patch Orchestration
Kubernetes deployment:
AIO-SX: Create, delete, reboot and rebuild instances
2+2+2 System: worker nodes are unlock enable and no alarms

Story: 2004022
Task: 27013

Change-Id: I0e0be6b3a6f25f7fb8edf64ea4326854513aa396
Signed-off-by: Tao Liu <tao.liu@windriver.com>
2018-12-13 14:15:55 -05:00

60 lines
1.6 KiB
Bash

#!/bin/bash
################################################################################
# Copyright (c) 2015-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
################################################################################
#
# Purpose:
# Affine the interface IRQ to specified cpulist.
#
# Usage: /usr/bin/affine-interrupts.sh interface cpulist
#
# Define minimal path
PATH=/bin:/usr/bin:/usr/local/bin
# logger setup
WHOAMI=`basename $0`
LOG_FACILITY=user
LOG_PRIORITY=info
TMPLOG=/tmp/${WHOAMI}.log
# LOG() - generates log and puts in temporary file
function LOG {
logger -t "${0##*/}[$$]" -p ${LOG_FACILITY}.${LOG_PRIORITY} "$@"
echo "${0##*/}[$$]" "$@" >> ${TMPLOG}
}
function INFO {
MSG="INFO"
LOG "${MSG} $@"
}
function ERROR {
MSG="ERROR"
LOG "${MSG} $@"
}
if [ "$#" -ne 2 ]; then
ERROR "Interface name and cpulist are required"
exit 1
fi
interface=$1
cpulist=$2
# Find PCI device matching interface, keep last matching device name
dev=$(find /sys/devices -name "${interface}" | \
perl -ne 'print $1 if /([[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]])\/[[:alpha:]]/;')
# Obtain all IRQs for this device
irq=$(cat /sys/bus/pci/devices/${dev}/irq 2>/dev/null)
msi_irqs=$(ls /sys/bus/pci/devices/${dev}/msi_irqs 2>/dev/null | xargs)
INFO $LINENO "affine ${interface} (dev:${dev} irq:${irq} msi_irqs:${msi_irqs}) with cpus (${cpulist})"
for i in $(echo "${irq} ${msi_irqs}"); do echo $i; done | \
xargs --no-run-if-empty -i{} \
/bin/bash -c "[[ -e /proc/irq/{} ]] && echo ${cpulist} > /proc/irq/{}/smp_affinity_list" 2>/dev/null
exit 0