diff --git a/arch/x86/tools/mcreboot-smp-x86.sh.in b/arch/x86/tools/mcreboot-smp-x86.sh.in index 2b69b27d..9ac24d58 100644 --- a/arch/x86/tools/mcreboot-smp-x86.sh.in +++ b/arch/x86/tools/mcreboot-smp-x86.sh.in @@ -6,9 +6,10 @@ # # This is an example script for loading IHK, configuring a partition and # booting McKernel on it. -# The script reserves half of the CPU cores and 512MB from NUMA node 0 if -# IHK is loaded for the first time, otherwise it destroys the current -# McKernel instances and reboots it using the same set of resources as previously. +# The script reserves half of the CPU cores and 512MB of RAM from NUMA node 0 +# when IHK is loaded for the first time, otherwise it destroys the current +# McKernel instance and reboots it using the same set of resources as it used +# previously. # Note that the script does not output anything unless an error occurs. prefix="@prefix@" @@ -39,20 +40,34 @@ fi # Load IHK-SMP if not loaded and reserve CPUs and memory if [ "`lsmod | grep ihk_smp_x86`" == "" ]; then - if ! insmod ${KMODDIR}/ihk-smp-x86.ko; then echo "error: loading ihk-smp-x86"; exit; fi; + ihk_irq="" + for i in `seq 64 255`; do + if [ ! -d /proc/irq/$i ] && [ "`cat /proc/interrupts | grep ":" | awk '{print $1}' | grep -o '[0-9]*' | grep $i`" == "" ]; then + ihk_irq=$i + break + fi + done + if [ "$ihk_irq" == "" ]; then echo "error: no IRQ available"; exit; fi + if ! insmod ${KMODDIR}/ihk-smp-x86.ko ihk_start_irq=$ihk_irq; then echo "error: loading ihk-smp-x86"; exit; fi; if ! ${SBINDIR}/ihkconfig 0 reserve cpu ${cpus}; then echo "error: reserving CPUs"; exit; fi if ! ${SBINDIR}/ihkconfig 0 reserve mem ${mem}; then echo "error: reserving memory"; exit; fi fi # Check for existing OS instance and destroy if [ -c /dev/mcos0 ]; then - if ! ${SBINDIR}/ihkconfig 0 destroy 0; then echo "warning: destroy failed"; fi - - # Query CPU cores and memory so that the same values are used as previously - if ! ${SBINDIR}/ihkconfig 0 query cpu > /dev/null; then echo "error: querying cpus"; exit; fi - cpus=`${SBINDIR}/ihkconfig 0 query cpu` - if ! ${SBINDIR}/ihkconfig 0 query mem > /dev/null; then echo "error: querying memory"; exit; fi - mem=`${SBINDIR}/ihkconfig 0 query mem` + # Query CPU cores and memory of OS instance so that the same values are used as previously + if ! ${SBINDIR}/ihkosctl 0 query cpu > /dev/null; then echo "error: querying cpus"; exit; fi + cpus=`${SBINDIR}/ihkosctl 0 query cpu` + if ! ${SBINDIR}/ihkosctl 0 query mem > /dev/null; then echo "error: querying memory"; exit; fi + mem=`${SBINDIR}/ihkosctl 0 query mem` + + if ! ${SBINDIR}/ihkconfig 0 destroy 0; then echo "warning: destroy failed"; fi +else + # Otherwise query IHK-SMP for resources + if ! ${SBINDIR}/ihkconfig 0 query cpu > /dev/null; then echo "error: querying cpus"; exit; fi + cpus=`${SBINDIR}/ihkconfig 0 query cpu` + if ! ${SBINDIR}/ihkconfig 0 query mem > /dev/null; then echo "error: querying memory"; exit; fi + mem=`${SBINDIR}/ihkconfig 0 query mem` fi if ! ${SBINDIR}/ihkconfig 0 create; then echo "error: create"; exit; fi