Staging
v0.5.1
https://github.com/torvalds/linux
Raw File
Tip revision: 523d939ef98fd712632d93a5a2b588e477a7565e authored by Linus Torvalds on 24 July 2016, 19:23:50 UTC
Linux 4.7
Tip revision: 523d939
run-on-all.sh
#!/bin/sh

#use last CPU for host. Why not the first?
#many devices tend to use cpu0 by default so
#it tends to be busier
HOST_AFFINITY=$(lscpu -p=cpu | tail -1)

#run command on all cpus
for cpu in $(seq 0 $HOST_AFFINITY)
do
	#Don't run guest and host on same CPU
	#It actually works ok if using signalling
	if
		(echo "$@" | grep -e "--sleep" > /dev/null) || \
			test $HOST_AFFINITY '!=' $cpu
	then
		echo "GUEST AFFINITY $cpu"
		"$@" --host-affinity $HOST_AFFINITY --guest-affinity $cpu
	fi
done
echo "NO GUEST AFFINITY"
"$@" --host-affinity $HOST_AFFINITY
echo "NO AFFINITY"
"$@"
back to top