Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')
0005 #use last CPU for host. Why not the first?
0006 #many devices tend to use cpu0 by default so
0007 #it tends to be busier
0008 HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)
0009 
0010 #run command on all cpus
0011 for cpu in $CPUS_ONLINE
0012 do
0013         #Don't run guest and host on same CPU
0014         #It actually works ok if using signalling
0015         if
0016                 (echo "$@" | grep -e "--sleep" > /dev/null) || \
0017                         test $HOST_AFFINITY '!=' $cpu
0018         then
0019                 echo "GUEST AFFINITY $cpu"
0020                 "$@" --host-affinity $HOST_AFFINITY --guest-affinity $cpu
0021         fi
0022 done
0023 echo "NO GUEST AFFINITY"
0024 "$@" --host-affinity $HOST_AFFINITY
0025 echo "NO AFFINITY"
0026 "$@"