mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
common: simplify set_common_vars, rename to common_setup
Don't pass all arguments explicitly, just use existing vars. Prefix all common_setup inputs and outputs with common_ to avoid name conflicts.
This commit is contained in:
@@ -2340,7 +2340,7 @@ s
|
|||||||
This is made possible by the GDB command:
|
This is made possible by the GDB command:
|
||||||
|
|
||||||
....
|
....
|
||||||
set sysroot ${buildroot_out_dir}/staging
|
set sysroot ${common_buildroot_out_dir}/staging
|
||||||
....
|
....
|
||||||
|
|
||||||
which automatically finds unstripped shared libraries on the host for us.
|
which automatically finds unstripped shared libraries on the host for us.
|
||||||
|
|||||||
36
bench-all
36
bench-all
@@ -47,7 +47,7 @@ comment="${1:-}"
|
|||||||
|
|
||||||
# Create output directory.
|
# Create output directory.
|
||||||
sha="$(git log -1 --format="%H")"
|
sha="$(git log -1 --format="%H")"
|
||||||
benchmark_repo="${root_dir}/../linux-kernel-module-cheat-regression"
|
benchmark_repo="${common_root_dir}/../linux-kernel-module-cheat-regression"
|
||||||
mkdir -p "$benchmark_repo"
|
mkdir -p "$benchmark_repo"
|
||||||
last_dir="$(ls "$benchmark_repo" | grep -E '^[0-9]' | tail -n 1)"
|
last_dir="$(ls "$benchmark_repo" | grep -E '^[0-9]' | tail -n 1)"
|
||||||
if [ -n "$last_dir" ]; then
|
if [ -n "$last_dir" ]; then
|
||||||
@@ -62,17 +62,17 @@ new_dir="${benchmark_repo}/${dir_basename}"
|
|||||||
mkdir "$new_dir"
|
mkdir "$new_dir"
|
||||||
|
|
||||||
if "$bench_build"; then
|
if "$bench_build"; then
|
||||||
arch="$default_arch"
|
common_arch="$default_arch"
|
||||||
suffix=bench
|
common_suffix=bench
|
||||||
set_common_vars "$arch" false "$suffix"
|
common_setup
|
||||||
rm -rf "$out_arch_dir"
|
rm -rf "$common_out_arch_dir"
|
||||||
./build -a "$arch" -B 'BR2_CCACHE=n' -s "$suffix"
|
./build -a "$common_arch" -B 'BR2_CCACHE=n' -s "$suffix"
|
||||||
cp "${build_dir}/build-time.log" "${new_dir}/build-time-${arch}.log"
|
cp "${common_build_dir}/build-time.log" "${new_dir}/build-time-${common_arch}.log"
|
||||||
rm -rf "$out_arch_dir"
|
rm -rf "$common_out_arch_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if "$bench_buildroot_baseline"; then
|
if "$bench_buildroot_baseline"; then
|
||||||
cd "${root_dir}/buildroot"
|
cd "${common_root_dir}/buildroot"
|
||||||
git clean -xdf
|
git clean -xdf
|
||||||
make "qemu_${default_arch}_defconfig"
|
make "qemu_${default_arch}_defconfig"
|
||||||
printf '
|
printf '
|
||||||
@@ -90,27 +90,27 @@ fi
|
|||||||
|
|
||||||
if "$bench_gem5_build"; then
|
if "$bench_gem5_build"; then
|
||||||
arches='x86_64 arm'
|
arches='x86_64 arm'
|
||||||
for arch in $arches; do
|
for common_arch in $arches; do
|
||||||
set_common_vars "$arch"
|
common_setup
|
||||||
cd "${root_dir}/gem5/gem5"
|
cd "${common_root_dir}/gem5/gem5"
|
||||||
git clean -xdf
|
git clean -xdf
|
||||||
cd "${root_dir}/gem5"
|
cd "${common_root_dir}/gem5"
|
||||||
results_file="${common_gem5_out_dir}/bench-build.txt"
|
results_file="${common_gem5_out_dir}/bench-build.txt"
|
||||||
gem5_outdir="${out_dir}/bench_build"
|
gem5_outdir="${common_out_dir}/bench_build"
|
||||||
rm -fr "$results_file" "${gem5_outdir}"
|
rm -fr "$results_file" "${gem5_outdir}"
|
||||||
# TODO understand better: --foreground required otherwise we cannot
|
# TODO understand better: --foreground required otherwise we cannot
|
||||||
# kill the build with Ctrl+C if something goes wrong, can be minimized to:
|
# kill the build with Ctrl+C if something goes wrong, can be minimized to:
|
||||||
# bash -c "eval 'timeout 5 sleep 3'"
|
# bash -c "eval 'timeout 5 sleep 3'"
|
||||||
common_bench_cmd "timeout --foreground 900 ./build -a '$arch' -o '${gem5_outdir}'" "$results_file"
|
common_bench_cmd "timeout --foreground 900 ./build -a '$common_arch' -o '${gem5_outdir}'" "$results_file"
|
||||||
cp "$results_file" "${new_dir}/gem5-bench-build-${arch}.txt"
|
cp "$results_file" "${new_dir}/gem5-bench-build-${common_arch}.txt"
|
||||||
cd "${root_dir}/gem5/gem5"
|
cd "${common_root_dir}/gem5/gem5"
|
||||||
git clean -xdf
|
git clean -xdf
|
||||||
rm -fr "${gem5_outdir}"
|
rm -fr "${gem5_outdir}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if "$bench_linux_boot"; then
|
if "$bench_linux_boot"; then
|
||||||
cd "${root_dir}"
|
cd "${common_root_dir}"
|
||||||
./build-all
|
./build-all
|
||||||
./bench-boot
|
./bench-boot
|
||||||
cp "$common_bench_boot" "$new_dir"
|
cp "$common_bench_boot" "$new_dir"
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ gem5_insts() (
|
|||||||
printf "instructions $(./gem5-stat -a "$1" sim_insts)\n" >> "$common_bench_boot"
|
printf "instructions $(./gem5-stat -a "$1" sim_insts)\n" >> "$common_bench_boot"
|
||||||
)
|
)
|
||||||
qemu_insts() (
|
qemu_insts() (
|
||||||
arch="$1"
|
common_arch="$1"
|
||||||
./qemu-trace2txt -a "$arch"
|
./qemu-trace2txt -a "$common_arch"
|
||||||
set_common_vars "$arch"
|
common_setup
|
||||||
printf "instructions $(wc -l "${common_trace_txt_file}" | cut -d' ' -f1)\n" >> "$common_bench_boot"
|
printf "instructions $(wc -l "${common_trace_txt_file}" | cut -d' ' -f1)\n" >> "$common_bench_boot"
|
||||||
)
|
)
|
||||||
rm -f "${common_bench_boot}"
|
rm -f "${common_bench_boot}"
|
||||||
|
|||||||
45
build
45
build
@@ -2,16 +2,16 @@
|
|||||||
set -eu
|
set -eu
|
||||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
||||||
set -- ${cli_build:-} "$@"
|
set -- ${cli_build:-} "$@"
|
||||||
mkdir -p "${out_dir}"
|
mkdir -p "${common_out_dir}"
|
||||||
br2_cli_file="${out_dir}/br2_cli"
|
br2_cli_file="${common_out_dir}/br2_cli"
|
||||||
rm -f "$br2_cli_file"
|
rm -f "$br2_cli_file"
|
||||||
touch "$br2_cli_file"
|
touch "$br2_cli_file"
|
||||||
kernel_config_fragment_cli_file="${out_dir}/kernel_config_fragment_cli"
|
kernel_config_fragment_cli_file="${common_out_dir}/kernel_config_fragment_cli"
|
||||||
kernel_config_fragment_cli_file_tmp="${kernel_config_fragment_cli_file}_tmp"
|
kernel_config_fragment_cli_file_tmp="${kernel_config_fragment_cli_file}_tmp"
|
||||||
rm -f "$kernel_config_fragment_cli_file_tmp"
|
rm -f "$kernel_config_fragment_cli_file_tmp"
|
||||||
touch "$kernel_config_fragment_cli_file_tmp"
|
touch "$kernel_config_fragment_cli_file_tmp"
|
||||||
configure=true
|
configure=true
|
||||||
config_fragments="${root_dir}/br2/default"
|
config_fragments="${common_root_dir}/br2/default"
|
||||||
extra_make_args=
|
extra_make_args=
|
||||||
j="$(nproc)"
|
j="$(nproc)"
|
||||||
linux_reconfigure=false
|
linux_reconfigure=false
|
||||||
@@ -19,12 +19,11 @@ linux_kernel_custom_config_file=
|
|||||||
kernel_config_fragments=
|
kernel_config_fragments=
|
||||||
post_script_args=
|
post_script_args=
|
||||||
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
||||||
suffix=
|
|
||||||
v=0
|
v=0
|
||||||
while getopts 'a:B:b:C:c:fGgj:hIiK:kL:lM:p:Q:qSst::v' OPT; do
|
while getopts 'a:B:b:C:c:fGgj:hIiK:kL:lM:p:Q:qSst::v' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
B)
|
B)
|
||||||
echo "$OPTARG" >> "$br2_cli_file"
|
echo "$OPTARG" >> "$br2_cli_file"
|
||||||
@@ -44,7 +43,7 @@ while getopts 'a:B:b:C:c:fGgj:hIiK:kL:lM:p:Q:qSst::v' OPT; do
|
|||||||
g)
|
g)
|
||||||
extra_make_args="${extra_make_args} gem5-reconfigure \\
|
extra_make_args="${extra_make_args} gem5-reconfigure \\
|
||||||
"
|
"
|
||||||
gem5=true
|
common_gem5=true
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
cat build-usage.adoc 1>&2
|
cat build-usage.adoc 1>&2
|
||||||
@@ -99,7 +98,7 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
|
|||||||
qemu_sdl=
|
qemu_sdl=
|
||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
suffix="$OPTARG"
|
common_suffix="$OPTARG"
|
||||||
;;
|
;;
|
||||||
t)
|
t)
|
||||||
common_gem5_build_type="$OPTARG"
|
common_gem5_build_type="$OPTARG"
|
||||||
@@ -114,9 +113,9 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
|
|||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
extra_make_args="${extra_make_args} $@"
|
extra_make_args="${extra_make_args} $@"
|
||||||
set_common_vars -L "$common_linux_variant" -M "$common_gem5_variant" "$arch" "$gem5" "$suffix"
|
common_setup
|
||||||
config_file="${buildroot_out_dir}/.config"
|
config_file="${common_buildroot_out_dir}/.config"
|
||||||
case "$arch" in
|
case "$common_arch" in
|
||||||
x86_64)
|
x86_64)
|
||||||
defconfig=qemu_x86_64_defconfig
|
defconfig=qemu_x86_64_defconfig
|
||||||
;;
|
;;
|
||||||
@@ -130,7 +129,7 @@ case "$arch" in
|
|||||||
defconfig=qemu_mips64r6_malta_defconfig
|
defconfig=qemu_mips64r6_malta_defconfig
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
config_fragments="${config_fragments} ${root_dir}/br2/qemu ${br2_cli_file}"
|
config_fragments="${config_fragments} ${common_root_dir}/br2/qemu ${br2_cli_file}"
|
||||||
|
|
||||||
time {
|
time {
|
||||||
# Configure.
|
# Configure.
|
||||||
@@ -139,16 +138,16 @@ if "$configure"; then
|
|||||||
# Only copy if modified, otherwise the kernel always rebuilds.
|
# Only copy if modified, otherwise the kernel always rebuilds.
|
||||||
cp "${kernel_config_fragment_cli_file_tmp}" "${kernel_config_fragment_cli_file}"
|
cp "${kernel_config_fragment_cli_file_tmp}" "${kernel_config_fragment_cli_file}"
|
||||||
fi
|
fi
|
||||||
cd "${buildroot_dir}"
|
cd "${common_buildroot_dir}"
|
||||||
for p in $(find "${root_dir}/buildroot_patches/" -maxdepth 1 -name '*.patch' -print); do
|
for p in $(find "${common_root_dir}/buildroot_patches/" -maxdepth 1 -name '*.patch' -print); do
|
||||||
patch -N -r - -p 1 < "$p" || :
|
patch -N -r - -p 1 < "$p" || :
|
||||||
done
|
done
|
||||||
br2_external='../kernel_module:../gem5:../parsec-benchmark'
|
br2_external='../kernel_module:../gem5:../parsec-benchmark'
|
||||||
packages_dir="${root_dir}/packages"
|
packages_dir="${common_root_dir}/packages"
|
||||||
for package_dir in "${packages_dir}"/*/; do
|
for package_dir in "${packages_dir}"/*/; do
|
||||||
br2_external="${br2_external}:../packages/$(basename "${package_dir}")"
|
br2_external="${br2_external}:../packages/$(basename "${package_dir}")"
|
||||||
done
|
done
|
||||||
make O="$buildroot_out_dir" BR2_EXTERNAL="$br2_external" "$defconfig"
|
make O="$common_buildroot_out_dir" BR2_EXTERNAL="$br2_external" "$defconfig"
|
||||||
# TODO Can't get rid of these for now.
|
# TODO Can't get rid of these for now.
|
||||||
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
|
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
|
||||||
for config_fragment in $config_fragments; do
|
for config_fragment in $config_fragments; do
|
||||||
@@ -159,7 +158,7 @@ BR2_JLEVEL=${j}
|
|||||||
BR2_DL_DIR=\"${common_dir}/dl\"
|
BR2_DL_DIR=\"${common_dir}/dl\"
|
||||||
BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
|
BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
|
||||||
" >> "$config_file"
|
" >> "$config_file"
|
||||||
if "$gem5"; then
|
if "$common_gem5"; then
|
||||||
printf "BR2_PACKAGE_GEM5=y\n" >> "${config_file}"
|
printf "BR2_PACKAGE_GEM5=y\n" >> "${config_file}"
|
||||||
fi
|
fi
|
||||||
kernel_config_fragment_dir=../kernel_config_fragment
|
kernel_config_fragment_dir=../kernel_config_fragment
|
||||||
@@ -182,11 +181,11 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
|
|||||||
# https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
|
# https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
|
||||||
touch "${kernel_config_fragment_dir}/min"
|
touch "${kernel_config_fragment_dir}/min"
|
||||||
fi
|
fi
|
||||||
if [ "$arch" = 'mips64' ]; then
|
if [ "$common_arch" = 'mips64' ]; then
|
||||||
# Workaround for: https://bugs.busybox.net/show_bug.cgi?id=10276
|
# Workaround for: https://bugs.busybox.net/show_bug.cgi?id=10276
|
||||||
sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "$config_file"
|
sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "$config_file"
|
||||||
fi
|
fi
|
||||||
make O="$buildroot_out_dir" olddefconfig
|
make O="$common_buildroot_out_dir" olddefconfig
|
||||||
fi
|
fi
|
||||||
echo 'config time:'
|
echo 'config time:'
|
||||||
}
|
}
|
||||||
@@ -214,13 +213,13 @@ symlink_buildroot_variant "$common_qemu_custom_dir" "$common_qemu_variant_dir"
|
|||||||
#symlink_buildroot_variant "$common_qemu_guest_custom_dir" "$common_qemu_guest_variant_dir"
|
#symlink_buildroot_variant "$common_qemu_guest_custom_dir" "$common_qemu_guest_variant_dir"
|
||||||
|
|
||||||
# Manage gem5 variants.
|
# Manage gem5 variants.
|
||||||
if "$gem5"; then
|
if "$common_gem5"; then
|
||||||
if [ ! -e "${common_gem5_src_dir}/.git" ]; then
|
if [ ! -e "${common_gem5_src_dir}/.git" ]; then
|
||||||
git -C "$common_gem5_default_src_dir" worktree add -b "wt/${common_gem5_variant}" "${common_gem5_src_dir}"
|
git -C "$common_gem5_default_src_dir" worktree add -b "wt/${common_gem5_variant}" "${common_gem5_src_dir}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$buildroot_dir"
|
cd "$common_buildroot_dir"
|
||||||
# HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times.
|
# HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times.
|
||||||
# It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936
|
# It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936
|
||||||
#
|
#
|
||||||
@@ -233,7 +232,7 @@ cmd="time \\
|
|||||||
env \\
|
env \\
|
||||||
-u LD_LIBRARY_PATH \\
|
-u LD_LIBRARY_PATH \\
|
||||||
make \\
|
make \\
|
||||||
O='${buildroot_out_dir}' \\
|
O='${common_buildroot_out_dir}' \\
|
||||||
HOST_QEMU_OPTS='--enable-debug --enable-trace-backends=simple ${qemu_sdl}' \\
|
HOST_QEMU_OPTS='--enable-debug --enable-trace-backends=simple ${qemu_sdl}' \\
|
||||||
GEM5_LKMC_GEM5_BUILD_TYPE="$common_gem5_build_type" \\
|
GEM5_LKMC_GEM5_BUILD_TYPE="$common_gem5_build_type" \\
|
||||||
GEM5_LKMC_OUTDIR="$common_gem5_out_dir" \\
|
GEM5_LKMC_OUTDIR="$common_gem5_out_dir" \\
|
||||||
@@ -242,4 +241,4 @@ V='${v}' \\
|
|||||||
${extra_make_args} \
|
${extra_make_args} \
|
||||||
all \\
|
all \\
|
||||||
"
|
"
|
||||||
"${root_dir}/eeval" "$cmd" "${out_arch_dir}/build.sh"
|
"${common_root_dir}/eeval" "$cmd" "${common_out_arch_dir}/build.sh"
|
||||||
|
|||||||
163
common
163
common
@@ -1,104 +1,89 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
common_abspath() (
|
common_abspath() (
|
||||||
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
|
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Benchmark a command.
|
||||||
|
#
|
||||||
|
# $1: command to benchmark
|
||||||
|
# $2: where to append write results to. Default: /dev/null.
|
||||||
|
#
|
||||||
|
# Result format:
|
||||||
|
#
|
||||||
|
# cmd <command run>
|
||||||
|
# time <time in seconds to finish>
|
||||||
|
# exit_status <exit status>
|
||||||
common_bench_cmd() (
|
common_bench_cmd() (
|
||||||
# Benchmark a command.
|
|
||||||
#
|
|
||||||
# $1: command to benchmark
|
|
||||||
# $2: where to append write results to. Default: /dev/null.
|
|
||||||
#
|
|
||||||
# Result format:
|
|
||||||
#
|
|
||||||
# cmd <command run>
|
|
||||||
# time <time in seconds to finish>
|
|
||||||
# exit_status <exit status>
|
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
results_file="${2:-/dev/null}"
|
results_file="${2:-/dev/null}"
|
||||||
printf 'cmd ' >> "$results_file"
|
printf 'cmd ' >> "$results_file"
|
||||||
env time --append -f 'time %e' --output="$results_file" "${root_dir}/eeval" -a "$cmd" "$results_file"
|
env time --append -f 'time %e' --output="$results_file" "${common_root_dir}/eeval" -a "$cmd" "$results_file"
|
||||||
printf "exit_status $?\n" >> "$results_file"
|
printf "exit_status $?\n" >> "$results_file"
|
||||||
)
|
)
|
||||||
set_common_vars() {
|
|
||||||
linux_variant=
|
# Setup several variables and do other initialization common to most scripts.
|
||||||
gem5_variant=
|
# Typically done after getting inputs from the command line arguments.
|
||||||
OPTIND=1
|
common_setup() {
|
||||||
while getopts L:M:n: OPT; do
|
case "$common_arch" in
|
||||||
case "$OPT" in
|
|
||||||
L)
|
|
||||||
linux_variant="$OPTARG"
|
|
||||||
;;
|
|
||||||
M)
|
|
||||||
gem5_variant="$OPTARG"
|
|
||||||
;;
|
|
||||||
n)
|
|
||||||
common_run_id="$OPTARG"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift "$(($OPTIND - 1))"
|
|
||||||
arch="$1"
|
|
||||||
gem5="${2:-false}"
|
|
||||||
case "$arch" in
|
|
||||||
a|arm)
|
a|arm)
|
||||||
arch=arm
|
common_arch=arm
|
||||||
;;
|
;;
|
||||||
A|aarch64)
|
A|aarch64)
|
||||||
arch=aarch64
|
common_arch=aarch64
|
||||||
;;
|
;;
|
||||||
m|mips64)
|
m|mips64)
|
||||||
arch=mips64
|
common_arch=mips64
|
||||||
;;
|
;;
|
||||||
x|x86_64)
|
x|x86_64)
|
||||||
arch=x86_64
|
common_arch=x86_64
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "unknown arch: ${arch}\n" 1>&2
|
printf "unknown arch: ${common_arch}\n" 1>&2
|
||||||
exit 2
|
exit 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
common_suffix="${3:-}"
|
common_buildroot_dir="${common_root_dir}/buildroot"
|
||||||
buildroot_dir="${root_dir}/buildroot"
|
common_arch_dir="$common_arch"
|
||||||
arch_dir="$arch"
|
|
||||||
if [ -n "$common_suffix" ]; then
|
if [ -n "$common_suffix" ]; then
|
||||||
arch_dir="${arch_dir}-${common_suffix}"
|
common_arch_dir="${arch_dir}-${common_suffix}"
|
||||||
fi
|
fi
|
||||||
out_arch_dir="${out_dir}/${arch_dir}"
|
common_out_arch_dir="${common_out_dir}/${common_arch_dir}"
|
||||||
buildroot_out_dir="${out_arch_dir}/buildroot"
|
common_buildroot_out_dir="${common_out_arch_dir}/buildroot"
|
||||||
build_dir="${buildroot_out_dir}/build"
|
common_build_dir="${common_buildroot_out_dir}/build"
|
||||||
common_images_dir="${buildroot_out_dir}/images"
|
common_linux_custom_dir="${common_build_dir}/linux-custom"
|
||||||
host_dir="${buildroot_out_dir}/host"
|
common_linux_variant_dir="${common_linux_custom_dir}.${common_linux_variant}"
|
||||||
common_qemu_run_dir="${out_arch_dir}/qemu/${common_run_id}"
|
common_vmlinux="${common_linux_variant_dir}/vmlinux"
|
||||||
common_qemu_termout_file="${common_qemu_run_dir}/termout.txt"
|
common_qemu_custom_dir="${common_build_dir}/host-qemu-custom"
|
||||||
common_qemu_rrfile="${common_qemu_run_dir}/rrfile"
|
common_qemu_guest_variant_dir="${common_qemu_custom_dir}.${common_qemu_variant}"
|
||||||
common_linux_custom_dir="${build_dir}/linux-custom"
|
common_qemu_variant_dir="${common_qemu_custom_dir}.${common_qemu_variant}"
|
||||||
common_linux_variant_dir="${common_linux_custom_dir}.${linux_variant}"
|
common_qemu_guest_custom_dir="${common_build_dir}/qemu-custom"
|
||||||
common_qemu_custom_dir="${build_dir}/host-qemu-custom"
|
common_host_dir="${common_buildroot_out_dir}/host"
|
||||||
common_qemu_variant_dir="${common_qemu_custom_dir}.${common_qemu_variant}"
|
common_images_dir="${common_buildroot_out_dir}/images"
|
||||||
common_qemu_guest_custom_dir="${build_dir}/qemu-custom"
|
common_gem5_run_dir="${common_out_arch_dir}/gem5/${common_run_id}"
|
||||||
common_qemu_guest_variant_dir="${common_qemu_custom_dir}.${common_qemu_variant}"
|
common_m5out_dir="${common_gem5_run_dir}/m5out"
|
||||||
common_vmlinux="${common_linux_variant_dir}/vmlinux"
|
common_trace_txt_file="${common_m5out_dir}/trace.txt"
|
||||||
|
common_gem5_termout_file="${common_gem5_run_dir}/termout.txt"
|
||||||
|
common_qemu_run_dir="${common_out_arch_dir}/qemu/${common_run_id}"
|
||||||
|
common_qemu_termout_file="${common_qemu_run_dir}/termout.txt"
|
||||||
|
common_qemu_rrfile="${common_qemu_run_dir}/rrfile"
|
||||||
|
common_gem5_out_dir="${common_dir}/gem5/${common_gem5_variant}"
|
||||||
|
common_gem5_m5term="${common_gem5_out_dir}/m5term"
|
||||||
|
common_gem5_build_dir="${common_gem5_out_dir}/build"
|
||||||
|
common_gem5_system_dir="${common_gem5_out_dir}/system"
|
||||||
if [ -n "$common_gem5_worktree" ]; then
|
if [ -n "$common_gem5_worktree" ]; then
|
||||||
common_gem5_src_dir="${common_gem5_non_default_src_root_dir}/${common_gem5_worktree}"
|
common_gem5_src_dir="${common_gem5_non_default_src_root_dir}/${common_gem5_worktree}"
|
||||||
else
|
else
|
||||||
common_gem5_src_dir="${root_dir}/gem5/gem5"
|
common_gem5_src_dir="${common_root_dir}/gem5/gem5"
|
||||||
fi
|
fi
|
||||||
common_gem5_out_dir="${common_dir}/gem5/${gem5_variant}"
|
if "$common_gem5"; then
|
||||||
common_gem5_m5term="${common_gem5_out_dir}/m5term"
|
|
||||||
common_gem5_build_dir="${common_gem5_out_dir}/build"
|
|
||||||
common_gem5_system_dir="${common_gem5_out_dir}/system"
|
|
||||||
common_gem5_run_dir="${out_arch_dir}/gem5/${common_run_id}"
|
|
||||||
common_gem5_termout_file="${common_gem5_run_dir}/termout.txt"
|
|
||||||
common_m5out_dir="${common_gem5_run_dir}/m5out"
|
|
||||||
if "$gem5"; then
|
|
||||||
common_run_dir="$common_gem5_run_dir"
|
common_run_dir="$common_gem5_run_dir"
|
||||||
common_termout_file="$common_gem5_termout_file"
|
common_termout_file="$common_gem5_termout_file"
|
||||||
else
|
else
|
||||||
common_run_dir="$common_qemu_run_dir"
|
common_run_dir="$common_qemu_run_dir"
|
||||||
common_termout_file="$common_qemu_termout_file"
|
common_termout_file="$common_qemu_termout_file"
|
||||||
fi
|
fi
|
||||||
common_trace_txt_file="${common_m5out_dir}/trace.txt"
|
case "$common_arch" in
|
||||||
case "$arch" in
|
|
||||||
arm)
|
arm)
|
||||||
common_linux_image=arch/arm/boot/zImage
|
common_linux_image=arch/arm/boot/zImage
|
||||||
;;
|
;;
|
||||||
@@ -116,7 +101,7 @@ set_common_vars() {
|
|||||||
|
|
||||||
# Ports.
|
# Ports.
|
||||||
common_run_id_number="$(echo "$common_run_id" | cut -d . -f 2)"
|
common_run_id_number="$(echo "$common_run_id" | cut -d . -f 2)"
|
||||||
if "$gem5"; then
|
if "$common_gem5"; then
|
||||||
common_gem5_telnet_port="$((3456 + $common_run_id_number))"
|
common_gem5_telnet_port="$((3456 + $common_run_id_number))"
|
||||||
common_gdb_port="$((7000 + $common_run_id_number))"
|
common_gdb_port="$((7000 + $common_run_id_number))"
|
||||||
else
|
else
|
||||||
@@ -128,34 +113,40 @@ set_common_vars() {
|
|||||||
common_gdb_port="$common_qemu_gdb_port"
|
common_gdb_port="$common_qemu_gdb_port"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
common_mkdir() (
|
common_mkdir() (
|
||||||
mkdir -p \
|
mkdir -p \
|
||||||
"$build_dir" \
|
"$common_build_dir" \
|
||||||
"$common_gem5_out_dir" \
|
"$common_gem5_out_dir" \
|
||||||
"$common_gem5_run_dir" \
|
"$common_gem5_run_dir" \
|
||||||
"$common_qemu_run_dir" \
|
"$common_qemu_run_dir" \
|
||||||
"$p9_dir" \
|
"$common_9p_dir" \
|
||||||
;
|
;
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Default paths.
|
||||||
|
common_root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
common_data_dir="${common_root_dir}/data"
|
||||||
|
common_9p_dir="${common_data_dir}/9p"
|
||||||
|
common_gem5_non_default_src_root_dir="${common_data_dir}/gem5"
|
||||||
|
common_gem5_readfile_file="${common_data_dir}/readfile"
|
||||||
|
common_gem5_default_src_dir="${common_root_dir}/gem5/gem5"
|
||||||
|
common_out_dir="${common_root_dir}/out"
|
||||||
|
common_bench_boot="${common_out_dir}/bench-boot.txt"
|
||||||
|
common_dir="${common_out_dir}/common"
|
||||||
|
|
||||||
|
# Other default variables.
|
||||||
|
common_arch=x86_64
|
||||||
|
common_gem5=false
|
||||||
|
common_gem5_build_type=opt
|
||||||
|
common_gem5_variant=default
|
||||||
|
common_gem5_worktree=
|
||||||
common_linux_variant=default
|
common_linux_variant=default
|
||||||
common_qemu_variant=default
|
common_qemu_variant=default
|
||||||
root_dir="$(pwd)"
|
|
||||||
out_dir="${root_dir}/out"
|
|
||||||
common_bench_boot="${out_dir}/bench-boot.txt"
|
|
||||||
data_dir="${root_dir}/data"
|
|
||||||
p9_dir="${data_dir}/9p"
|
|
||||||
readfile_file="${data_dir}/readfile"
|
|
||||||
common_dir="${out_dir}/common"
|
|
||||||
common_gem5_build_type=opt
|
|
||||||
common_gem5_default_src_dir="${root_dir}/gem5/gem5"
|
|
||||||
common_gem5_non_default_src_root_dir="${data_dir}/gem5"
|
|
||||||
common_gem5_worktree=
|
|
||||||
common_gem5_variant=default
|
|
||||||
common_run_id=0
|
common_run_id=0
|
||||||
f="${data_dir}/cli"
|
common_suffix=
|
||||||
|
|
||||||
|
f="${common_data_dir}/cli"
|
||||||
if [ -f "$f" ]; then
|
if [ -f "$f" ]; then
|
||||||
. "$f"
|
. "$f"
|
||||||
fi
|
fi
|
||||||
# Default arch.
|
|
||||||
arch=x86_64
|
|
||||||
gem5=false
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eu
|
set -eu
|
||||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
||||||
|
common_gem5=true
|
||||||
generate_checkpoints=true
|
generate_checkpoints=true
|
||||||
while getopts a:C OPT; do
|
while getopts a:C OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
generate_checkpoints=false
|
generate_checkpoints=false
|
||||||
@@ -15,8 +16,8 @@ done
|
|||||||
shift "$(($OPTIND - 1))"
|
shift "$(($OPTIND - 1))"
|
||||||
|
|
||||||
# Vars
|
# Vars
|
||||||
set_common_vars "$arch" true
|
common_setup
|
||||||
cmd="./run -a $arch -g"
|
cmd="./run -a ${common_arch} -g"
|
||||||
cache_small='--caches --l2cache --l1d_size=1024 --l1i_size=1024 --l2_size=1024 --l3_size=1024 '
|
cache_small='--caches --l2cache --l1d_size=1024 --l1i_size=1024 --l2_size=1024 --l3_size=1024 '
|
||||||
cache_large='--caches --l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB'
|
cache_large='--caches --l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB'
|
||||||
results_file="${common_gem5_run_dir}/bench-cache.txt"
|
results_file="${common_gem5_run_dir}/bench-cache.txt"
|
||||||
@@ -25,11 +26,11 @@ bench() (
|
|||||||
common_bench_cmd "$1" "$results_file"
|
common_bench_cmd "$1" "$results_file"
|
||||||
{
|
{
|
||||||
printf 'cycles '
|
printf 'cycles '
|
||||||
./gem5-stat -a "$arch"
|
./gem5-stat -a "$common_arch"
|
||||||
printf 'instructions '
|
printf 'instructions '
|
||||||
./gem5-stat -a "$arch" sim_insts
|
./gem5-stat -a "$common_arch" sim_insts
|
||||||
# RESTORE_INVESTIGATION
|
# RESTORE_INVESTIGATION
|
||||||
#cycles_switch="$(./gem5-stat -a "$arch" system.switch_cpus.numCycles)"
|
#cycles_switch="$(./gem5-stat -a "$common_arch" system.switch_cpus.numCycles)"
|
||||||
#if [ -n "$cycles_switch" ]; then
|
#if [ -n "$cycles_switch" ]; then
|
||||||
# printf "cycles_switch ${cycles_switch}\n"
|
# printf "cycles_switch ${cycles_switch}\n"
|
||||||
#fi
|
#fi
|
||||||
@@ -67,7 +68,7 @@ bench-all() (
|
|||||||
if "$generate_checkpoints"; then
|
if "$generate_checkpoints"; then
|
||||||
# Create the checkpoints after the kernel boot.
|
# Create the checkpoints after the kernel boot.
|
||||||
rm -rf "${common_m5out_dir}"/cpt.*;
|
rm -rf "${common_m5out_dir}"/cpt.*;
|
||||||
printf 'm5 exit' > "${readfile_file}"
|
printf 'm5 exit' > "${common_gem5_readfile_file}"
|
||||||
cpt_cmd="-E '/gem5.sh'"
|
cpt_cmd="-E '/gem5.sh'"
|
||||||
# 1
|
# 1
|
||||||
./eeval "$cmd $cpt_cmd"
|
./eeval "$cmd $cpt_cmd"
|
||||||
@@ -88,10 +89,10 @@ printf '#!/bin/sh
|
|||||||
m5 resetstats
|
m5 resetstats
|
||||||
dhrystone XXX
|
dhrystone XXX
|
||||||
m5 exit
|
m5 exit
|
||||||
' >"${readfile_file}"
|
' >"${common_gem5_readfile_file}"
|
||||||
for n in 1000 10000 100000; do
|
for n in 1000 10000 100000; do
|
||||||
printf "n ${n}\n" >> "$results_file"
|
printf "n ${n}\n" >> "$results_file"
|
||||||
sed -Ei "s/^dhrystone .*/dhrystone ${n}/" "${readfile_file}"
|
sed -Ei "s/^dhrystone .*/dhrystone ${n}/" "${common_gem5_readfile_file}"
|
||||||
bench-all
|
bench-all
|
||||||
printf "\n" >> "$results_file"
|
printf "\n" >> "$results_file"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
||||||
|
common_gem5=true
|
||||||
while getopts M:n: OPT; do
|
while getopts M:n: OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
M)
|
M)
|
||||||
@@ -14,5 +15,5 @@ while getopts M:n: OPT; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift "$(($OPTIND - 1))"
|
shift "$(($OPTIND - 1))"
|
||||||
set_common_vars -M "$common_gem5_variant" -n "$common_run_id" "$arch" true
|
common_setup
|
||||||
"${common_gem5_m5term}" localhost "$common_gem5_telnet_port"
|
"${common_gem5_m5term}" localhost "$common_gem5_telnet_port"
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eu
|
set -eu
|
||||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
||||||
|
common_gem5=true
|
||||||
while getopts a:hs: OPT; do
|
while getopts a:hs: OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
printf "\
|
printf "\
|
||||||
@@ -21,5 +22,5 @@ if [ $# -gt 0 ]; then
|
|||||||
else
|
else
|
||||||
stat=system.cpu[0-9]*.numCycles
|
stat=system.cpu[0-9]*.numCycles
|
||||||
fi
|
fi
|
||||||
set_common_vars "$arch" true
|
common_setup
|
||||||
awk "/^$stat /{ print \$2 }" "${common_m5out_dir}/stats.txt"
|
awk "/^$stat /{ print \$2 }" "${common_m5out_dir}/stats.txt"
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ set -- ${cli_qemu_trace2txt:-} "$@"
|
|||||||
while getopts a: OPT; do
|
while getopts a: OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
set_common_vars "$arch" false
|
common_setup
|
||||||
./qemu/scripts/simpletrace.py \
|
./qemu/scripts/simpletrace.py \
|
||||||
"${build_dir}/host-qemu-custom/trace-events-all" \
|
"${common_build_dir}/host-qemu-custom/trace-events-all" \
|
||||||
"${common_qemu_run_dir}/trace.bin" \
|
"${common_qemu_run_dir}/trace.bin" \
|
||||||
> "${common_trace_txt_file}"
|
> "${common_trace_txt_file}"
|
||||||
|
|||||||
39
run
39
run
@@ -18,7 +18,6 @@ extra_append_after_dash=
|
|||||||
extra_flags=
|
extra_flags=
|
||||||
extra_flags_qemu=
|
extra_flags_qemu=
|
||||||
extra_opts=
|
extra_opts=
|
||||||
gem5=false
|
|
||||||
gem5opts=
|
gem5opts=
|
||||||
gem5_fsbiglittle=false
|
gem5_fsbiglittle=false
|
||||||
lkmc_eval=
|
lkmc_eval=
|
||||||
@@ -39,7 +38,7 @@ vnc=
|
|||||||
while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:N:n:PQ:RrT:t:U:uVX:x OPT; do
|
while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:N:n:PQ:RrT:t:U:uVX:x OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
c)
|
c)
|
||||||
cpus="$OPTARG"
|
cpus="$OPTARG"
|
||||||
@@ -70,7 +69,7 @@ while getopts a:c:DdE:e:F:f:G:ghIiKkL:M:m:N:n:PQ:RrT:t:U:uVX:x OPT; do
|
|||||||
"
|
"
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
gem5=true
|
common_gem5=true
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
cat build-usage.adoc 1>&2
|
cat build-usage.adoc 1>&2
|
||||||
@@ -161,7 +160,7 @@ if [ -n "$extra_opts" ]; then
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
set_common_vars -L "$common_linux_variant" -M "$common_gem5_variant" -n "$common_run_id" "$arch" "$gem5"
|
common_setup
|
||||||
if "$debug" && "$kvm"; then
|
if "$debug" && "$kvm"; then
|
||||||
echo 'error: -d and -K are incompatible' 1>&2
|
echo 'error: -d and -K are incompatible' 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -181,7 +180,7 @@ if [ -n "$lkmc_eval" ]; then
|
|||||||
extra_append_after_dash="${extra_append_after_dash} lkmc_eval=\"$(printf "$lkmc_eval" | base64)\""
|
extra_append_after_dash="${extra_append_after_dash} lkmc_eval=\"$(printf "$lkmc_eval" | base64)\""
|
||||||
fi
|
fi
|
||||||
if "$nographic"; then
|
if "$nographic"; then
|
||||||
if [ "$arch" = x86_64 ]; then
|
if [ "$common_arch" = x86_64 ]; then
|
||||||
extra_append="${extra_append} console=ttyS0"
|
extra_append="${extra_append} console=ttyS0"
|
||||||
fi
|
fi
|
||||||
extra_flags_qemu="${extra_flags_qemu} -nographic \\
|
extra_flags_qemu="${extra_flags_qemu} -nographic \\
|
||||||
@@ -191,9 +190,9 @@ if [ -n "$extra_append_after_dash" ]; then
|
|||||||
extra_append="${extra_append} - ${extra_append_after_dash}"
|
extra_append="${extra_append} - ${extra_append_after_dash}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if "$gem5"; then
|
if "$common_gem5"; then
|
||||||
memory="${memory}B"
|
memory="${memory}B"
|
||||||
if [ "$arch" = x86_64 ]; then
|
if [ "$common_arch" = x86_64 ]; then
|
||||||
gem5_arch=X86
|
gem5_arch=X86
|
||||||
else
|
else
|
||||||
gem5_arch=ARM
|
gem5_arch=ARM
|
||||||
@@ -229,9 +228,9 @@ ${gem5_common} \
|
|||||||
--kernel='${common_vmlinux}' \\
|
--kernel='${common_vmlinux}' \\
|
||||||
--mem-size='${memory}' \\
|
--mem-size='${memory}' \\
|
||||||
--num-cpus='${cpus}' \\
|
--num-cpus='${cpus}' \\
|
||||||
--script='${readfile_file}' \\
|
--script='${common_gem5_readfile_file}' \\
|
||||||
"
|
"
|
||||||
if [ "$arch" = x86_64 ]; then
|
if [ "$common_arch" = x86_64 ]; then
|
||||||
if "$kvm"; then
|
if "$kvm"; then
|
||||||
extra_flags="$extra_flags --cpu-type=X86KvmCPU"
|
extra_flags="$extra_flags --cpu-type=X86KvmCPU"
|
||||||
fi
|
fi
|
||||||
@@ -240,12 +239,12 @@ ${gem5_common} \
|
|||||||
--command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/sda ${extra_append}' \\
|
--command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/sda ${extra_append}' \\
|
||||||
${extra_flags} \
|
${extra_flags} \
|
||||||
"
|
"
|
||||||
elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then
|
elif [ "$common_arch" = arm ] || [ "$common_arch" = aarch64 ]; then
|
||||||
# TODO why is it mandatory to pass mem= here? Not true for QEMU.
|
# TODO why is it mandatory to pass mem= here? Not true for QEMU.
|
||||||
# Anything smaller than physical blows up as expected, but why can't it auto-detect the right value?
|
# Anything smaller than physical blows up as expected, but why can't it auto-detect the right value?
|
||||||
cmd="${gem5_common} \
|
cmd="${gem5_common} \
|
||||||
--command-line='earlyprintk=pl011,0x1c090000 console=ttyAMA0 lpj=19988480 rw loglevel=8 mem=${memory} root=/dev/sda ${extra_append}' \\
|
--command-line='earlyprintk=pl011,0x1c090000 console=ttyAMA0 lpj=19988480 rw loglevel=8 mem=${memory} root=/dev/sda ${extra_append}' \\
|
||||||
--dtb-file='${common_gem5_system_dir}/arm/dt/$([ "$arch" = arm ] && echo "armv7_gem5_v1_${cpus}cpu" || echo "armv8_gem5_v1_${cpus}cpu").dtb' \\
|
--dtb-file='${common_gem5_system_dir}/arm/dt/$([ "$common_arch" = arm ] && echo "armv7_gem5_v1_${cpus}cpu" || echo "armv8_gem5_v1_${cpus}cpu").dtb' \\
|
||||||
--machine-type=VExpress_GEM5_V1 \\
|
--machine-type=VExpress_GEM5_V1 \\
|
||||||
${extra_flags} \
|
${extra_flags} \
|
||||||
"
|
"
|
||||||
@@ -268,9 +267,9 @@ else
|
|||||||
fi
|
fi
|
||||||
if "$prebuilt"; then
|
if "$prebuilt"; then
|
||||||
common_mkdir
|
common_mkdir
|
||||||
qemu_executable="qemu-system-${arch}"
|
qemu_executable="qemu-system-${common_arch}"
|
||||||
else
|
else
|
||||||
qemu_executable="${common_qemu_variant_dir}/${arch}-softmmu/qemu-system-${arch}"
|
qemu_executable="${common_qemu_variant_dir}/${common_arch}-softmmu/qemu-system-${common_arch}"
|
||||||
fi
|
fi
|
||||||
extra_flags="${extra_flags_qemu} ${extra_flags}"
|
extra_flags="${extra_flags_qemu} ${extra_flags}"
|
||||||
qemu_common="\
|
qemu_common="\
|
||||||
@@ -285,8 +284,8 @@ ${qemu_executable} \\
|
|||||||
${serial_monitor} \
|
${serial_monitor} \
|
||||||
-smp '${cpus}' \\
|
-smp '${cpus}' \\
|
||||||
-trace 'enable=${trace_type},file=${common_qemu_run_dir}/trace.bin' \\
|
-trace 'enable=${trace_type},file=${common_qemu_run_dir}/trace.bin' \\
|
||||||
-virtfs 'local,path=${p9_dir},mount_tag=host_scratch,security_model=mapped,id=host_scratch' \\
|
-virtfs 'local,path=${common_9p_dir},mount_tag=host_scratch,security_model=mapped,id=host_scratch' \\
|
||||||
-virtfs 'local,path=${buildroot_out_dir}/build,mount_tag=host_out,security_model=mapped,id=host_out' \\
|
-virtfs 'local,path=${common_buildroot_out_dir}/build,mount_tag=host_out,security_model=mapped,id=host_out' \\
|
||||||
${vnc}"
|
${vnc}"
|
||||||
if "$initrd"; then
|
if "$initrd"; then
|
||||||
extra_flags="${extra_flags} -initrd '${common_images_dir}/rootfs.cpio' \\
|
extra_flags="${extra_flags} -initrd '${common_images_dir}/rootfs.cpio' \\
|
||||||
@@ -298,7 +297,7 @@ ${vnc}"
|
|||||||
# TODO why is this needed, and why any string works.
|
# TODO why is this needed, and why any string works.
|
||||||
root='root=/dev/anything'
|
root='root=/dev/anything'
|
||||||
else
|
else
|
||||||
if [ ! "$arch" = mips64 ]; then
|
if [ ! "$common_arch" = mips64 ]; then
|
||||||
if [ -n "$rr" ]; then
|
if [ -n "$rr" ]; then
|
||||||
driveif=none
|
driveif=none
|
||||||
rrid=',id=img-direct'
|
rrid=',id=img-direct'
|
||||||
@@ -331,7 +330,7 @@ ${vnc}"
|
|||||||
virtio_gpu_pci="-device virtio-gpu-pci \\
|
virtio_gpu_pci="-device virtio-gpu-pci \\
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
case "$arch" in
|
case "$common_arch" in
|
||||||
x86_64)
|
x86_64)
|
||||||
if "$kgdb"; then
|
if "$kgdb"; then
|
||||||
extra_append="${extra_append} kgdboc=ttyS0,115200"
|
extra_append="${extra_append} kgdboc=ttyS0,115200"
|
||||||
@@ -390,10 +389,10 @@ ${extra_flags} \
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
if "$tmux"; then
|
if "$tmux"; then
|
||||||
if "$gem5"; then
|
if "$common_gem5"; then
|
||||||
eval "./tmu 'sleep 2;./gem5-shell -n ${common_run_id} ${tmux_args};'"
|
eval "./tmu 'sleep 2;./gem5-shell -n ${common_run_id} ${tmux_args};'"
|
||||||
elif "$debug"; then
|
elif "$debug"; then
|
||||||
eval "./tmu ./rungdb -a '${arch} -L ${common_linux_variant}' -n ${common_run_id} ${tmux_args}"
|
eval "./tmu ./rungdb -a '${common_arch} -L ${common_linux_variant}' -n ${common_run_id} ${tmux_args}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cmd="time ${cmd}"
|
cmd="time ${cmd}"
|
||||||
@@ -402,4 +401,4 @@ if [ -z "$debug_vm" ]; then
|
|||||||
|& tee >(ts -s %.s > ${common_termout_file}) \
|
|& tee >(ts -s %.s > ${common_termout_file}) \
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
"${root_dir}/eeval" "$cmd" "${common_run_dir}/run.sh"
|
"${common_root_dir}/eeval" "$cmd" "${common_run_dir}/run.sh"
|
||||||
|
|||||||
10
rungdb
10
rungdb
@@ -14,7 +14,7 @@ while getopts A:a:b:CgkL:n:X OPT; do
|
|||||||
after="$OPTARG"
|
after="$OPTARG"
|
||||||
;;
|
;;
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
b)
|
b)
|
||||||
before="$OPTARG"
|
before="$OPTARG"
|
||||||
@@ -24,7 +24,7 @@ while getopts A:a:b:CgkL:n:X OPT; do
|
|||||||
docontinue=false
|
docontinue=false
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
gem5=true
|
common_gem5=true
|
||||||
;;
|
;;
|
||||||
k)
|
k)
|
||||||
kgdb=true
|
kgdb=true
|
||||||
@@ -51,8 +51,8 @@ if [ "$#" -gt 0 ]; then
|
|||||||
else
|
else
|
||||||
brk=
|
brk=
|
||||||
fi
|
fi
|
||||||
set_common_vars -L "$common_linux_variant" -n "$common_run_id" "$arch" "$gem5"
|
common_setup
|
||||||
gdb="${host_dir}/usr/bin/${arch}-linux-gdb \\
|
gdb="${common_host_dir}/usr/bin/${common_arch}-linux-gdb \\
|
||||||
${before}"
|
${before}"
|
||||||
if "$kgdb"; then
|
if "$kgdb"; then
|
||||||
cmd="\
|
cmd="\
|
||||||
@@ -98,5 +98,5 @@ if "$docontinue"; then
|
|||||||
${lx_symbols} \
|
${lx_symbols} \
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
"${root_dir}/eeval" "cd '${common_linux_variant_dir}' && \\
|
"${common_root_dir}/eeval" "cd '${common_linux_variant_dir}' && \\
|
||||||
$cmd $after" "${common_run_dir}/rungdb.sh"
|
$cmd $after" "${common_run_dir}/rungdb.sh"
|
||||||
|
|||||||
12
rungdb-user
12
rungdb-user
@@ -7,10 +7,10 @@ gem5_opt=
|
|||||||
while getopts a:gh OPT; do
|
while getopts a:gh OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
gem5=true
|
common_gem5=true
|
||||||
gem5_opt=-g
|
gem5_opt=-g
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
@@ -31,15 +31,15 @@ if [ "$#" -gt 0 ]; then
|
|||||||
else
|
else
|
||||||
brk=
|
brk=
|
||||||
fi
|
fi
|
||||||
set_common_vars "$arch" "$gem5"
|
common_setup
|
||||||
executable="${build_dir}/${executable_rel}"
|
executable="${common_build_dir}/${executable_rel}"
|
||||||
addr="$("${root_dir}/runtc" readelf -h "$executable" | awk '/Entry/{ print $NF }' )"
|
addr="$("${common_root_dir}/runtc" readelf -h "$executable" | awk '/Entry/{ print $NF }' )"
|
||||||
ex="-ex \"add-symbol-file $executable $addr\""
|
ex="-ex \"add-symbol-file $executable $addr\""
|
||||||
# -X or else lx-symbols throws for arm:
|
# -X or else lx-symbols throws for arm:
|
||||||
# gdb.MemoryError: Cannot access memory at address 0xbf0040cc
|
# gdb.MemoryError: Cannot access memory at address 0xbf0040cc
|
||||||
# TODO understand better.
|
# TODO understand better.
|
||||||
#
|
#
|
||||||
# Also, lx-symbols overrides the add-symbol-file commands.
|
# Also, lx-symbols overrides the add-symbol-file commands.
|
||||||
cmd="./rungdb -a '${arch}' -b '${ex}' ${gem5_opt} -X ${brk}"
|
cmd="./rungdb -a '${common_arch}' -b '${ex}' ${gem5_opt} -X ${brk}"
|
||||||
echo "$cmd"
|
echo "$cmd"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
|
|||||||
12
rungdbserver
12
rungdbserver
@@ -5,21 +5,21 @@ set -- ${cli_rungdbserver:-} "$@"
|
|||||||
while getopts a:g OPT; do
|
while getopts a:g OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
gem5=true
|
common_gem5=true
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift "$(($OPTIND - 1))"
|
shift "$(($OPTIND - 1))"
|
||||||
executable="$1"
|
executable="$1"
|
||||||
set_common_vars "$arch" "$gem5"
|
common_setup
|
||||||
"${host_dir}/usr/bin/${arch}-linux-gdb" \
|
"${common_host_dir}/usr/bin/${common_arch}-linux-gdb" \
|
||||||
-q \
|
-q \
|
||||||
-ex "set sysroot ${buildroot_out_dir}/staging" \
|
-ex "set sysroot ${common_buildroot_out_dir}/staging" \
|
||||||
-ex "target remote localhost:${common_qemu_hostfwd_generic_port}" \
|
-ex "target remote localhost:${common_qemu_hostfwd_generic_port}" \
|
||||||
-ex 'tb main' \
|
-ex 'tb main' \
|
||||||
-ex 'c' \
|
-ex 'c' \
|
||||||
"${build_dir}/${executable}" \
|
"${common_build_dir}/${executable}" \
|
||||||
;
|
;
|
||||||
|
|||||||
6
runtc
6
runtc
@@ -5,7 +5,7 @@ set -- ${cli_runtc:-} "$@"
|
|||||||
while getopts a:gh OPT; do
|
while getopts a:gh OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
printf "Usage: $0 TOOL [TOOL_ARGS]...
|
printf "Usage: $0 TOOL [TOOL_ARGS]...
|
||||||
@@ -20,6 +20,6 @@ done
|
|||||||
shift "$(($OPTIND - 1))"
|
shift "$(($OPTIND - 1))"
|
||||||
tool="$1"
|
tool="$1"
|
||||||
shift
|
shift
|
||||||
set_common_vars "$arch"
|
common_setup
|
||||||
"${buildroot_out_dir}/host/bin/"*-buildroot-*"${tool}" "$@"
|
"${common_buildroot_out_dir}/host/bin/"*-buildroot-*"${tool}" "$@"
|
||||||
exit "$?"
|
exit "$?"
|
||||||
|
|||||||
16
trace-boot
16
trace-boot
@@ -5,25 +5,25 @@ set -- ${cli_trace_boot:-} "$@"
|
|||||||
while getopts a:g OPT; do
|
while getopts a:g OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
gem5=true
|
common_gem5=true
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift "$(($OPTIND - 1))"
|
shift "$(($OPTIND - 1))"
|
||||||
set_common_vars "$arch" "$gem5"
|
common_setup
|
||||||
if "$gem5"; then
|
if "$common_gem5"; then
|
||||||
time ./run -a "$arch" -E 'm5 exit' -g -T 'Exec,-ExecSymbol,-ExecMicro' "$@"
|
time ./run -a "$common_arch" -E 'm5 exit' -g -T 'Exec,-ExecSymbol,-ExecMicro' "$@"
|
||||||
else
|
else
|
||||||
time ./run -a "$arch" -e 'init=/poweroff.out' -T exec_tb "$@"
|
time ./run -a "$common_arch" -e 'init=/poweroff.out' -T exec_tb "$@"
|
||||||
time ./qemu-trace2txt -a "$arch"
|
time ./qemu-trace2txt -a "$common_arch"
|
||||||
# Instruction count.
|
# Instruction count.
|
||||||
# We could put this on a separate script, but it just adds more arch boilerplate to a new script.
|
# We could put this on a separate script, but it just adds more arch boilerplate to a new script.
|
||||||
# So let's just leave it here for now since it did not add a significant processing time.
|
# So let's just leave it here for now since it did not add a significant processing time.
|
||||||
echo "instructions $(wc -l "${common_trace_txt_file}" | cut -d' ' -f1)"
|
echo "instructions $(wc -l "${common_trace_txt_file}" | cut -d' ' -f1)"
|
||||||
entry_addr=$("${root_dir}/runtc" readelf -h "${build_dir}/linux-custom/vmlinux" | grep 'Entry point address' | sed -E 's/.*: *//')
|
entry_addr=$("${common_root_dir}/runtc" readelf -h "${common_build_dir}/linux-custom/vmlinux" | grep 'Entry point address' | sed -E 's/.*: *//')
|
||||||
echo "entry_address ${entry_addr}"
|
echo "entry_address ${entry_addr}"
|
||||||
sed "/${entry_addr}/q" "${common_trace_txt_file}" >"${common_qemu_run_dir}/trace-boot.txt"
|
sed "/${entry_addr}/q" "${common_trace_txt_file}" >"${common_qemu_run_dir}/trace-boot.txt"
|
||||||
echo "instructions_firmware $(wc -l "${common_qemu_run_dir}/trace-boot.txt" | cut -d' ' -f1)"
|
echo "instructions_firmware $(wc -l "${common_qemu_run_dir}/trace-boot.txt" | cut -d' ' -f1)"
|
||||||
|
|||||||
12
trace2line
12
trace2line
@@ -5,23 +5,23 @@ set -- ${cli_trace2line:-} "$@"
|
|||||||
while getopts a:g OPT; do
|
while getopts a:g OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
common_arch="$OPTARG"
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
gem5=true
|
common_gem5=true
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
set_common_vars "$arch" "$gem5"
|
common_setup
|
||||||
kernel_dir="${build_dir}/linux-custom"
|
kernel_dir="${common_build_dir}/linux-custom"
|
||||||
(
|
(
|
||||||
if "$gem5"; then
|
if "$common_gem5"; then
|
||||||
sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file"
|
sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file"
|
||||||
else
|
else
|
||||||
sed -r 's/.*pc=//' "$common_trace_txt_file"
|
sed -r 's/.*pc=//' "$common_trace_txt_file"
|
||||||
fi
|
fi
|
||||||
) | \
|
) | \
|
||||||
xargs "${host_dir}/bin/${arch}-linux-addr2line" -e "${kernel_dir}/vmlinux" -fp | \
|
xargs "${common_host_dir}/bin/${common_arch}-linux-addr2line" -e "${common_vmlinux}" -fp | \
|
||||||
sed -E "s|at ${kernel_dir}/(\./\|)||" | \
|
sed -E "s|at ${kernel_dir}/(\./\|)||" | \
|
||||||
uniq -c \
|
uniq -c \
|
||||||
> "${common_run_dir}/trace-lines.txt"
|
> "${common_run_dir}/trace-lines.txt"
|
||||||
|
|||||||
Reference in New Issue
Block a user