TO RESET: mcreboot, mcstop+release.sh: add functions

Change-Id: Ic3992dc4e16b7ade00e93edbd107c64a32068c02
This commit is contained in:
Balazs Gerofi
2020-01-10 15:51:01 +09:00
committed by Masamichi Takagi
parent 10b17e230c
commit bbfb296c26
3 changed files with 123 additions and 2 deletions

View File

@ -0,0 +1,99 @@
#!/bin/bash
# IHK/McKernel user priviledge reboot script.
# author: Balazs Gerofi <bgerofi@riken.jp>
# Copyright (C) 2019 RIKEN
#
prefix="@prefix@"
BINDIR="${prefix}/bin"
SBINDIR="${prefix}/sbin"
KERNDIR="@MCKERNELDIR@"
mem=""
cpus=""
ikc_map=""
while getopts c:m:r: OPT
do
case ${OPT} in
c) cpus=${OPTARG}
;;
m) mem=${OPTARG}
;;
r) ikc_map=${OPTARG}
;;
\?) exit 1
;;
esac
done
if [ "${ikc_map}" == "" ]; then
# Query IKC map
if ! ${SBINDIR}/ihkosctl 0 get ikc_map > /dev/null; then
echo "error: querying IKC map" >&2
exit 1
fi
ikc_map=`${SBINDIR}/ihkosctl 0 get ikc_map`
fi
# Shutdown OS
if ! ${SBINDIR}/ihkosctl 0 shutdown; then
echo "error: shuting down OS" >&2
exit 1
fi
sleep 2
# Query IHK-SMP resources and reassign
if ! ${SBINDIR}/ihkconfig 0 query cpu > /dev/null; then
echo "error: querying cpus" >&2
exit 1
fi
cpus=`${SBINDIR}/ihkconfig 0 query cpu`
if [ "${cpus}" == "" ]; then
echo "error: querying CPUs" >&2
exit 1
fi
# Assign CPUs
if ! ${SBINDIR}/ihkosctl 0 assign cpu ${cpus}; then
echo "error: assign CPUs" >&2
exit 1
fi
# Assign memory
for i in `seq 0 15`; do
if ! ${SBINDIR}/ihkosctl 0 assign mem all@${i}; then
echo "error: assign memory" >&2
exit 1
fi
done
if [ "${ikc_map}" != "" ]; then
# Set IKC map
if ! ${SBINDIR}/ihkosctl 0 set ikc_map ${ikc_map}; then
echo "error: setting IKC map" >&2
exit 1
fi
fi
# Load kernel image
if ! ${SBINDIR}/ihkosctl 0 load ${KERNDIR}/mckernel.img; then
echo "error: loading kernel image: ${KERNDIR}/mckernel.img" >&2
exit 1
fi
# Set kernel arguments
if ! ${SBINDIR}/ihkosctl 0 kargs "hidos dump_level=24"; then
echo "error: setting kernel arguments" >&2
exit 1
fi
# Boot OS instance
if ! ${SBINDIR}/ihkosctl 0 boot; then
echo "error: booting" >&2
exit 1
fi

View File

@ -65,8 +65,9 @@ umask_old=`umask`
idle_halt="" idle_halt=""
allow_oversubscribe="" allow_oversubscribe=""
time_sharing="time_sharing" time_sharing="time_sharing"
force_reserve="no"
while getopts stk:c:m:o:f:r:q:i:d:e:hOT: OPT while getopts stk:c:m:o:f:r:q:i:d:e:hROT: OPT
do do
case ${OPT} in case ${OPT} in
f) facility=${OPTARG} f) facility=${OPTARG}
@ -97,6 +98,8 @@ do
;; ;;
O) allow_oversubscribe="allow_oversubscribe" O) allow_oversubscribe="allow_oversubscribe"
;; ;;
R) force_reserve="yes"
;;
T) T)
case ${OPTARG} in case ${OPTARG} in
1) time_sharing="time_sharing" 1) time_sharing="time_sharing"
@ -343,6 +346,17 @@ if ! grep ihk_smp_@ARCH@ /proc/modules &>/dev/null; then
fi fi
fi fi
if [ ${force_reserve} == "yes" ]; then
if ! ${SUDO} ${SBINDIR}/ihkconfig 0 reserve mem ${mem}; then
echo "error: reserving memory" >&2
error_exit "ihk_smp_loaded"
fi
if ! ${SUDO} ${SBINDIR}/ihkconfig 0 reserve cpu ${cpus}; then
echo "error: reserving CPUs" >&2;
error_exit "mem_reserved"
fi
fi
# Load mcctrl if not loaded # Load mcctrl if not loaded
if ! grep mcctrl /proc/modules &>/dev/null; then if ! grep mcctrl /proc/modules &>/dev/null; then
if ! taskset -c 0 ${SUDO} insmod ${KMODDIR}/mcctrl.ko 2>/dev/null; then if ! taskset -c 0 ${SUDO} insmod ${KMODDIR}/mcctrl.ko 2>/dev/null; then

View File

@ -18,9 +18,10 @@ KERNDIR="@KERNDIR@"
mem="" mem=""
cpus="" cpus=""
kill_in_use="" kill_in_use=""
dont_unload="no"
RMMOD_PATH=/sbin/rmmod RMMOD_PATH=/sbin/rmmod
while getopts r:k OPT while getopts r:kR OPT
do do
case ${OPT} in case ${OPT} in
r) r)
@ -29,6 +30,9 @@ do
k) k)
kill_in_use=1 kill_in_use=1
;; ;;
R)
dont_unload="yes"
;;
\?) exit 1 \?) exit 1
;; ;;
esac esac
@ -115,6 +119,10 @@ if ! sudo ${SBINDIR}/ihkconfig 0 release mem "all" > /dev/null; then
exit 1 exit 1
fi fi
if [ "${dont_unload}" == "yes" ]; then
exit 0
fi
# Remove delegator if loaded # Remove delegator if loaded
if grep mcctrl /proc/modules &>/dev/null; then if grep mcctrl /proc/modules &>/dev/null; then
if ! sudo ${RMMOD_PATH} mcctrl 2>/dev/null; then if ! sudo ${RMMOD_PATH} mcctrl 2>/dev/null; then