Last active
January 4, 2024 10:56
-
-
Save ayufan/37be5c0b8fd26113a8be to your computer and use it in GitHub Desktop.
KVM CPU pinning for Proxmox VE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eo pipefail | |
VMID=200 | |
cpu_tasks() { | |
expect <<EOF | sed -n 's/^.* CPU .*thread_id=\(.*\)$/\1/p' | tr -d '\r' || true | |
spawn qm monitor $VMID | |
expect ">" | |
send "info cpus\r" | |
expect ">" | |
EOF | |
} | |
VCPUS=($(cpu_tasks)) | |
VCPU_COUNT="${#VCPUS[@]}" | |
if [[ $VCPU_COUNT -eq 0 ]]; then | |
echo "* No VCPUS for VM$VMID" | |
exit 1 | |
fi | |
echo "* Detected ${#VCPUS[@]} assigned to VM$VMID..." | |
echo "* Resetting cpu shield..." | |
for CPU_INDEX in "${!VCPUS[@]}" | |
do | |
CPU_TASK="${VCPUS[$CPU_INDEX]}" | |
echo "* Assigning $CPU_INDEX to $CPU_TASK..." | |
taskset -pc "$CPU_INDEX" "$CPU_TASK" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it giving a notable speed increased ? And was it only noticable in game .. ? thanks