1 #!/bin/sh 1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0 << 3 2 4 CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e 3 CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#') 5 #use last CPU for host. Why not the first? 4 #use last CPU for host. Why not the first? 6 #many devices tend to use cpu0 by default so 5 #many devices tend to use cpu0 by default so 7 #it tends to be busier 6 #it tends to be busier 8 HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 7 HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1) 9 8 10 #run command on all cpus 9 #run command on all cpus 11 for cpu in $CPUS_ONLINE 10 for cpu in $CPUS_ONLINE 12 do 11 do 13 #Don't run guest and host on same CPU 12 #Don't run guest and host on same CPU 14 #It actually works ok if using signall 13 #It actually works ok if using signalling 15 if 14 if 16 (echo "$@" | grep -e "--sleep" 15 (echo "$@" | grep -e "--sleep" > /dev/null) || \ 17 test $HOST_AFFINITY '! 16 test $HOST_AFFINITY '!=' $cpu 18 then 17 then 19 echo "GUEST AFFINITY $cpu" 18 echo "GUEST AFFINITY $cpu" 20 "$@" --host-affinity $HOST_AFF 19 "$@" --host-affinity $HOST_AFFINITY --guest-affinity $cpu 21 fi 20 fi 22 done 21 done 23 echo "NO GUEST AFFINITY" 22 echo "NO GUEST AFFINITY" 24 "$@" --host-affinity $HOST_AFFINITY 23 "$@" --host-affinity $HOST_AFFINITY 25 echo "NO AFFINITY" 24 echo "NO AFFINITY" 26 "$@" 25 "$@"
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.