2024-02-18 16:18:50 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-02-23 11:42:35 -07:00
|
|
|
# 2024.feb kneutron
|
|
|
|
# optional arg1 $1 = vmid if already known
|
|
|
|
# Assign cores 6,7 to boinc win10 2-core vm
|
2024-02-23 16:32:22 -07:00
|
|
|
# This should obviously be done on quad-core or better CPU
|
2024-02-23 11:42:35 -07:00
|
|
|
|
2024-02-18 16:18:50 -07:00
|
|
|
psax
|
|
|
|
|
2024-02-23 16:32:22 -07:00
|
|
|
declare -i vmid lastcpu # has to be a number
|
|
|
|
|
2024-02-23 11:43:51 -07:00
|
|
|
if [ "$1" = "" ]; then
|
2024-02-23 11:42:35 -07:00
|
|
|
read -p "Enter VMID of highest-CPU kvm: " vmid
|
|
|
|
else
|
|
|
|
vmid=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ "$vmid" = "" ] || [ "$vmid" = "0" ] && exit 44;
|
2024-02-18 16:18:50 -07:00
|
|
|
|
2024-02-23 16:32:22 -07:00
|
|
|
lastcpu=$(grep processor /proc/cpuinfo |tail -n 1 |awk '{print $3}')
|
|
|
|
let penultcpu=$lastcpu-1
|
|
|
|
|
|
|
|
# print only pid / subthreads that are using >0 CPU
|
2024-02-23 11:42:35 -07:00
|
|
|
pidlist=$(ps -eLf --columns $COLUMNS |grep "kvm -id $vmid" |egrep -v 'grep|bash' |awk '$5>0 {print $4}')
|
|
|
|
echo $pidlist
|
2024-02-18 16:18:50 -07:00
|
|
|
|
2024-02-23 11:42:35 -07:00
|
|
|
#exit;
|
2024-02-18 16:18:50 -07:00
|
|
|
|
2024-02-23 11:42:35 -07:00
|
|
|
function assigncores () {
|
|
|
|
|
|
|
|
set -x
|
|
|
|
taskset -p $1
|
2024-02-23 16:32:22 -07:00
|
|
|
taskset -cp $penultcpu,$lastcpu $1
|
2024-02-23 11:42:35 -07:00
|
|
|
|
2024-02-23 16:32:22 -07:00
|
|
|
taskset -cp $penultcpu $2
|
|
|
|
taskset -cp $lastcpu $3
|
2024-02-23 11:42:35 -07:00
|
|
|
}
|
2024-02-18 16:18:50 -07:00
|
|
|
# assign cpu cores 6,7 to win10 vm for better latency
|
|
|
|
# REF: https://www.youtube.com/watch?v=-c_451HV6fE
|
2024-02-23 11:42:35 -07:00
|
|
|
|
|
|
|
# psthreads.sh 'kvm -id 112' |awk '$5>0 {print}' # field 4 is pid + subthreads
|
|
|
|
|
|
|
|
assigncores $pidlist
|
|
|
|
|
2024-02-23 16:32:22 -07:00
|
|
|
set +x
|
2024-02-23 11:42:35 -07:00
|
|
|
echo "Monitor changes with htop"
|
|
|
|
|
2024-02-23 16:32:22 -07:00
|
|
|
exit;
|
|
|
|
|
|
|
|
# Adapt to different multicore systems
|
|
|
|
|
|
|
|
# grep processor /proc/cpuinfo |tail -n 1
|
|
|
|
processor : 7
|
|
|
|
# grep processor /proc/cpuinfo |tail -n 1 |awk '{print $3}'
|
|
|
|
7
|