From 593cf6ee8e0c8f2790c59de6d6e3ec7a88606608 Mon Sep 17 00:00:00 2001 From: kneutron <50146127+kneutron@users.noreply.github.com> Date: Fri, 23 Feb 2024 16:32:22 -0700 Subject: [PATCH] mod for different multicore systems, be more automatic --- proxmox/proxmox-vm-assign-cpu-cores.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/proxmox/proxmox-vm-assign-cpu-cores.sh b/proxmox/proxmox-vm-assign-cpu-cores.sh index 60f13e8..e08b6c4 100644 --- a/proxmox/proxmox-vm-assign-cpu-cores.sh +++ b/proxmox/proxmox-vm-assign-cpu-cores.sh @@ -3,10 +3,12 @@ # 2024.feb kneutron # optional arg1 $1 = vmid if already known # Assign cores 6,7 to boinc win10 2-core vm +# This should obviously be done on quad-core or better CPU psax -declare -i vmid # has to be a number +declare -i vmid lastcpu # has to be a number + if [ "$1" = "" ]; then read -p "Enter VMID of highest-CPU kvm: " vmid else @@ -15,6 +17,10 @@ fi [ "$vmid" = "" ] || [ "$vmid" = "0" ] && exit 44; +lastcpu=$(grep processor /proc/cpuinfo |tail -n 1 |awk '{print $3}') +let penultcpu=$lastcpu-1 + +# print only pid / subthreads that are using >0 CPU pidlist=$(ps -eLf --columns $COLUMNS |grep "kvm -id $vmid" |egrep -v 'grep|bash' |awk '$5>0 {print $4}') echo $pidlist @@ -24,10 +30,10 @@ function assigncores () { set -x taskset -p $1 - taskset -cp 6,7 $1 + taskset -cp $penultcpu,$lastcpu $1 - taskset -cp 6 $2 - taskset -cp 7 $3 + taskset -cp $penultcpu $2 + taskset -cp $lastcpu $3 } # assign cpu cores 6,7 to win10 vm for better latency # REF: https://www.youtube.com/watch?v=-c_451HV6fE @@ -36,5 +42,14 @@ set -x assigncores $pidlist +set +x echo "Monitor changes with htop" +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