-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Hi all,
I just read the following optimization document for CP4D. https://www.ibm.com/support/producthub/icpdata/docs/content/SSQNUZ_current/cpd/install/node-settings.html
There is a session about SMT configuration implementation with openshift.
It deploy a shell script and service on the nodes in order to control the SMT level of each node via Labels.
oc label nodes worker-1 SMT=4
=> This switch the node to SMT4...
I find this pretty handy and think it could be deployed via this ansible playbook during the customization section.
the shell script:
#!/bin/bash
export PATH=/root/.local/bin:/root/bin:/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
export KUBECONFIG=/var/lib/kubelet/kubeconfig
COREPS=$(/bin/lscpu | /bin/awk -F: ' $1 ~ /^Core\(s\) per socket$/ {print $2}'|/bin/xargs)
SOCKETS=$(/bin/lscpu | /bin/awk -F: ' $1 ~ /^Socket\(s\)$/ {print $2}'|/bin/xargs)
let TOTALCORES=$COREPS*$SOCKETS
MAXTHREADS=$(/bin/lscpu | /bin/awk -F: ' $1 ~ /^CPU\(s\)$/ {print $2}'|/bin/xargs)
let MAXSMT=$MAXTHREADS/$TOTALCORES
CURRENTSMT=$(/bin/lscpu | /bin/awk -F: ' $1 ~ /^Thread\(s\) per core$/ {print $2}'|/bin/xargs)
while :
do
ISNODEDEGRADED=$(/bin/oc get node $HOSTNAME -o yaml |/bin/grep machineconfiguration.openshift.io/reason |/bin/grep "unexpected on-disk state validating")
SMTLABEL=$(/bin/oc get node $HOSTNAME -L SMT --no-headers |/bin/awk '{print $6}')
if [[ -n $SMTLABEL ]]
then
case $SMTLABEL in
1) TARGETSMT=1
;;
2) TARGETSMT=2
;;
4) TARGETSMT=4
;;
8) TARGETSMT=8
;;
*) TARGETSMT=$CURRENTSMT ; echo "SMT value must be 1, 2, 4, or 8 and smaller than Maximum SMT."
;;
esac
else
TARGETSMT=$MAXSMT
fi
if [[ -n $ISNODEDEGRADED ]]
then
touch /run/machine-config-daemon-force
fi
CURRENTSMT=$(/bin/lscpu | /bin/awk -F: ' $1 ~ /^Thread\(s\) per core$/ {print $2}'|/bin/xargs)
if [[ $CURRENTSMT -ne $TARGETSMT ]]
then
INITONTHREAD=0
INITOFFTHREAD=$TARGETSMT
if [[ $MAXSMT -ge $TARGETSMT ]]
then
while [[ $INITONTHREAD -lt $MAXTHREADS ]]
do
ONTHREAD=$INITONTHREAD
OFFTHREAD=$INITOFFTHREAD
while [[ $ONTHREAD -lt $OFFTHREAD ]]
do
/bin/echo 1 > /sys/devices/system/cpu/cpu$ONTHREAD/online
let ONTHREAD=$ONTHREAD+1
done
let INITONTHREAD=$INITONTHREAD+$MAXSMT
while [[ $OFFTHREAD -lt $INITONTHREAD ]]
do
/bin/echo 0 > /sys/devices/system/cpu/cpu$OFFTHREAD/online
let OFFTHREAD=$OFFTHREAD+1
done
let INITOFFTHREAD=$INITOFFTHREAD+$MAXSMT
done
else
echo "Target SMT must be smaller or equal than Maximum SMT supported"
fi
fi
/bin/sleep 30
done
Metadata
Metadata
Assignees
Labels
No labels