blob: dcc3ea758f48ede0615730b3a3e4ef167e03aae0 [file] [log] [blame]
Michael S. Tsirkin481eaec2016-01-21 14:44:10 +02001#!/bin/sh
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Michael S. Tsirkin481eaec2016-01-21 14:44:10 +02003
Halil Pasic21f5eda2016-08-29 18:25:22 +02004CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')
Michael S. Tsirkin481eaec2016-01-21 14:44:10 +02005#use last CPU for host. Why not the first?
6#many devices tend to use cpu0 by default so
7#it tends to be busier
Halil Pasic21f5eda2016-08-29 18:25:22 +02008HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)
Michael S. Tsirkin481eaec2016-01-21 14:44:10 +02009
10#run command on all cpus
Halil Pasic21f5eda2016-08-29 18:25:22 +020011for cpu in $CPUS_ONLINE
Michael S. Tsirkin481eaec2016-01-21 14:44:10 +020012do
13 #Don't run guest and host on same CPU
14 #It actually works ok if using signalling
15 if
16 (echo "$@" | grep -e "--sleep" > /dev/null) || \
17 test $HOST_AFFINITY '!=' $cpu
18 then
19 echo "GUEST AFFINITY $cpu"
20 "$@" --host-affinity $HOST_AFFINITY --guest-affinity $cpu
21 fi
22done
23echo "NO GUEST AFFINITY"
24"$@" --host-affinity $HOST_AFFINITY
25echo "NO AFFINITY"
26"$@"