mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 19:21:35 +01:00
bench-boot: start convert to cli function
This commit is contained in:
202
bench-boot
202
bench-boot
@@ -1,95 +1,125 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
test_size=1
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--size)
|
||||
# 1: a few seconds and important
|
||||
# 2: < 5 minutes and important or a few seconds and not too important
|
||||
# 3: all
|
||||
test_size="$2"
|
||||
shift 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
#!/usr/bin/env python3
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
extra_args=" $*"
|
||||
else
|
||||
extra_args=
|
||||
fi
|
||||
getvar="${root_dir}/getvar"
|
||||
common_bench_boot="$("$getvar" bench_boot)"
|
||||
caches='--caches --l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB'
|
||||
import common
|
||||
from shell_helpers import LF
|
||||
|
||||
bench() (
|
||||
"${root_dir}/bench-cmd" "./run --arch ${1}${extra_args}" "$common_bench_boot"
|
||||
)
|
||||
class Main(common.LkmcCliFunction):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
defaults={
|
||||
'print_time': False,
|
||||
},
|
||||
description='''\
|
||||
Run Linux kernel boot tests and benchmarks.
|
||||
'''
|
||||
)
|
||||
self.add_argument(
|
||||
'--size',
|
||||
default=1,
|
||||
type=int,
|
||||
help='''\
|
||||
Size of the tests to run. Scale:
|
||||
|
||||
newline() (
|
||||
echo >> "$common_bench_boot"
|
||||
)
|
||||
* 1: a few seconds and important
|
||||
* 2: < 5 minutes and important or a few seconds and not too important
|
||||
* 3: all
|
||||
'''
|
||||
)
|
||||
|
||||
gem5_insts() (
|
||||
printf "instructions $(./gem5-stat --arch "$1" sim_insts)\n" >> "$common_bench_boot"
|
||||
newline
|
||||
)
|
||||
def _bench(self, **kwargs):
|
||||
self.run(**kwargs)
|
||||
|
||||
qemu_insts() (
|
||||
common_arch="$1"
|
||||
./qemu-trace2txt --arch "$common_arch"
|
||||
common_qemu_trace_txt_file="$("$getvar" --arch "$common_arch" qemu_trace_txt_file)"
|
||||
printf "instructions $(wc -l "${common_qemu_trace_txt_file}" | cut -d' ' -f1)\n" >> "$common_bench_boot"
|
||||
newline
|
||||
)
|
||||
def timed_main(self):
|
||||
#bench() (
|
||||
# "${root_dir}/bench-cmd" "./run --arch ${1}${extra_args}" "$self.env['bench_boot']"
|
||||
#)
|
||||
#
|
||||
#newline() (
|
||||
# echo >> "$self.env['bench_boot']"
|
||||
#)
|
||||
#
|
||||
#gem5_insts() (
|
||||
# printf "instructions $(./gem5-stat --arch "$1" sim_insts)\n" >> "$self.env['bench_boot']"
|
||||
# newline
|
||||
#)
|
||||
#
|
||||
#qemu_insts() (
|
||||
# common_arch="$1"
|
||||
# ./qemu-trace2txt --arch "$common_arch"
|
||||
# common_qemu_trace_txt_file="$("$getvar" --arch "$common_arch" qemu_trace_txt_file)"
|
||||
# printf "instructions $(wc -l "${common_qemu_trace_txt_file}" | cut -d' ' -f1)\n" >> "$self.env['bench_boot']"
|
||||
# newline
|
||||
#)
|
||||
#
|
||||
#rm -f "${self.env['bench_boot']}"
|
||||
|
||||
rm -f "${common_bench_boot}"
|
||||
self.run = self.import_path_main('run')
|
||||
run_args = self.get_common_args()
|
||||
if self.env['emulator'] == 'gem5':
|
||||
run_args['eval'] = 'm5 exit'
|
||||
elif self.env['emulator'] == 'qemu':
|
||||
run_args['eval'] = '/poweroff.out'
|
||||
if (self.env['emulator'] == 'qemu' or
|
||||
(self.env['emulator'] == 'gem5' and self.env['size'] >= 2)):
|
||||
self._bench(**run_args)
|
||||
if self.env['host_arch'] == self.env['arch']:
|
||||
# TODO: find out why it fails.
|
||||
if self.env['emulator'] != 'gem5':
|
||||
self._bench(kvm=True, **run_args)
|
||||
# newline
|
||||
if self.env['emulator'] == 'qemu' and self.env['size'] >= 2:
|
||||
self._bench(trace='exec_tb', **run_args)
|
||||
# qemu_insts "$arch"
|
||||
if self.env['emulator'] == 'gem5' and self.env['size'] >= 3:
|
||||
self._bench(
|
||||
extra_emulator_args=[
|
||||
'--cpu-type',
|
||||
'DerivO3CPU',
|
||||
'--caches',
|
||||
'--l2cache',
|
||||
'--l1d_size=1024kB',
|
||||
'--l1i_size=1024kB',
|
||||
'--l2_size=1024kB',
|
||||
'--l3_size=1024kB',
|
||||
],
|
||||
**run_args
|
||||
)
|
||||
# gem5_insts "$arch"
|
||||
|
||||
arch=x86_64
|
||||
bench "${arch} --eval '/poweroff.out'"
|
||||
newline
|
||||
bench "${arch} --eval '/poweroff.out' --kvm"
|
||||
newline
|
||||
if [ "$test_size" -ge 2 ]; then
|
||||
bench "${arch} --eval '/poweroff.out' --trace exec_tb"
|
||||
qemu_insts "$arch"
|
||||
bench "$arch --eval 'm5 exit' --emulator gem5"
|
||||
gem5_insts "$arch"
|
||||
fi
|
||||
#bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=DerivO3CPU ${caches}"
|
||||
#gem5_insts "$arch"
|
||||
#arch=arm
|
||||
#bench "$arch --eval '/poweroff.out'"
|
||||
#newline
|
||||
#if [ self.env['size'] -ge 2 ]; then
|
||||
# bench "$arch --eval '/poweroff.out' --trace exec_tb"
|
||||
# qemu_insts "$arch"
|
||||
# bench "$arch --eval 'm5 exit' --emulator gem5"
|
||||
# gem5_insts "$arch"
|
||||
#fi
|
||||
#if [ self.env['size'] -ge 3 ]; then
|
||||
# bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}"
|
||||
# gem5_insts "$arch"
|
||||
#fi
|
||||
|
||||
arch=arm
|
||||
bench "$arch --eval '/poweroff.out'"
|
||||
newline
|
||||
if [ "$test_size" -ge 2 ]; then
|
||||
bench "$arch --eval '/poweroff.out' --trace exec_tb"
|
||||
qemu_insts "$arch"
|
||||
bench "$arch --eval 'm5 exit' --emulator gem5"
|
||||
gem5_insts "$arch"
|
||||
fi
|
||||
if [ "$test_size" -ge 3 ]; then
|
||||
bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}"
|
||||
gem5_insts "$arch"
|
||||
fi
|
||||
#arch=aarch64
|
||||
#bench "$arch --eval '/poweroff.out'"
|
||||
#newline
|
||||
#if [ self.env['size'] -ge 2 ]; then
|
||||
# bench "$arch --eval '/poweroff.out' --trace exec_tb"
|
||||
# qemu_insts "$arch"
|
||||
# bench "$arch --eval 'm5 exit' --emulator gem5"
|
||||
# gem5_insts "$arch"
|
||||
#fi
|
||||
#if [ self.env['size'] -ge 3 ]; then
|
||||
# bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}"
|
||||
# gem5_insts "$arch"
|
||||
# #bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-script biglittle"
|
||||
# #gem5_insts "$arch"
|
||||
# bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type fast"
|
||||
# gem5_insts "$arch"
|
||||
# bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type debug"
|
||||
# gem5_insts "$arch"
|
||||
#fi
|
||||
|
||||
if __name__ == '__main__':
|
||||
Main().cli_exit()
|
||||
|
||||
arch=aarch64
|
||||
bench "$arch --eval '/poweroff.out'"
|
||||
newline
|
||||
if [ "$test_size" -ge 2 ]; then
|
||||
bench "$arch --eval '/poweroff.out' --trace exec_tb"
|
||||
qemu_insts "$arch"
|
||||
bench "$arch --eval 'm5 exit' --emulator gem5"
|
||||
gem5_insts "$arch"
|
||||
fi
|
||||
if [ "$test_size" -ge 3 ]; then
|
||||
bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}"
|
||||
gem5_insts "$arch"
|
||||
#bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-script biglittle"
|
||||
#gem5_insts "$arch"
|
||||
bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type fast"
|
||||
gem5_insts "$arch"
|
||||
bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type debug"
|
||||
gem5_insts "$arch"
|
||||
fi
|
||||
|
||||
3
build
3
build
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import platform
|
||||
import re
|
||||
import os
|
||||
|
||||
@@ -368,7 +367,7 @@ Which components to build. Default: qemu-buildroot
|
||||
}
|
||||
# E.g. on an ARM host, the package gcc-arm-linux-gnueabihf
|
||||
# is called just gcc.
|
||||
processor = platform.processor()
|
||||
processor = self.env['host_arch']
|
||||
if processor != 'arm':
|
||||
apt_get_pkgs.update({
|
||||
'gcc-arm-linux-gnueabihf',
|
||||
|
||||
@@ -431,6 +431,8 @@ amazing function!
|
||||
assert one_cli_function.get_cli(pos_mandatory=1, bool=False) == [('--bool',), ('--bool-cli',), ('1',)]
|
||||
assert one_cli_function.get_cli(pos_mandatory=1, pos_optional=2, args_star=['3', '4']) == [('--bool-cli',), ('1',), ('2',), ('3',), ('4',)]
|
||||
assert one_cli_function.get_cli(pos_mandatory=1, append=['2', '3']) == [('--append', '2'), ('--append', '3',), ('--bool-cli',), ('1',)]
|
||||
print(one_cli_function.get_cli(pos_mandatory=1, args_star=['asdf', 'qwer']))
|
||||
assert one_cli_function.get_cli(pos_mandatory=1, args_star=['asdf', 'qwer']) == [('--bool-cli',), ('1',), ('asdf',), ('qwer',),]
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
# CLI call with argv command line arguments.
|
||||
|
||||
@@ -12,6 +12,7 @@ import json
|
||||
import math
|
||||
import multiprocessing
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import signal
|
||||
@@ -105,6 +106,7 @@ consts['emulator_choices'] = set()
|
||||
for key in consts['emulator_short_to_long_dict']:
|
||||
consts['emulator_choices'].add(key)
|
||||
consts['emulator_choices'].add(consts['emulator_short_to_long_dict'][key])
|
||||
consts['host_arch'] = platform.processor()
|
||||
|
||||
class LkmcCliFunction(cli_function.CliFunction):
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user