├── .gitignore ├── .gitlab-ci.yml ├── .gitlab ├── issue_templates │ ├── bug-report.md │ └── feature.md └── merge_request_templates │ └── CONTRIBUTING.md ├── .gitmodules ├── LICENSE ├── README.md ├── ci ├── check_kernel.sh ├── check_module_exist.sh ├── install_deps.sh └── test_net.sh ├── deps └── deps.cmake ├── docs ├── benchmarks │ └── README.md ├── contribution │ └── README.md ├── example.gif ├── mitosis-core.md ├── network-daemon.md ├── roadmap.md ├── setup.md ├── tests-and-benchmarks.md └── unit-test │ └── README.md ├── exp ├── .gitignore ├── CMakeLists.txt ├── Makefile ├── README.md ├── common │ ├── .gitignore │ ├── bench.py │ ├── connector.cc │ ├── criu_wrapper.py │ ├── func_bench_wrapper.py │ ├── mitosis_wrapper.py │ ├── simple_child.cc │ ├── simple_child_socket.cc │ ├── simple_parent.cc │ ├── simple_parent.py │ └── syscall_lib.py ├── compression-0 │ └── linux.json ├── compression-1 │ └── linux.json ├── compression-2 │ └── linux.json ├── criu-micro │ ├── .gitignore │ ├── README.md │ ├── bench_exe_time_parent.py │ ├── copy_env.sh │ ├── host_dump.sh │ ├── lock │ ├── rcopy.sh │ ├── restore.sh │ └── run_benchmark.sh ├── fork-functions │ ├── README.md │ ├── benchmark_lean_container.c │ ├── chameleon │ │ ├── function.py │ │ └── function_bench.py │ ├── compression │ │ ├── compression-0 │ │ │ └── linux.json │ │ ├── compression-1 │ │ │ └── linux.json │ │ ├── compression-2 │ │ │ └── linux.json │ │ ├── function.py │ │ ├── function_bench.py │ │ └── linux.json │ ├── dd │ │ └── function.py │ ├── ffmpeg │ │ ├── function.py │ │ └── test.mp4 │ ├── finra │ │ ├── .gitignore │ │ ├── child_function_wrapper.py │ │ ├── function.py │ │ ├── function_bench.py │ │ ├── function_local_fork.py │ │ ├── master.py │ │ ├── trigger.py │ │ ├── trigger_local_fork.py │ │ ├── util.py │ │ └── yfinance.csv │ ├── helloworld │ │ ├── function.py │ │ └── function_bench.py │ ├── image │ │ ├── function.py │ │ ├── function_bench.py │ │ ├── test.jpeg │ │ └── thumbnail.jpg │ ├── imgresize │ │ ├── function.py │ │ └── test.jpeg │ ├── json │ │ ├── function.py │ │ ├── function_bench.py │ │ └── linux.json │ ├── linpack │ │ ├── function.py │ │ └── function_bench.py │ ├── matmul │ │ ├── function.py │ │ └── function_bench.py │ ├── micro │ │ ├── bench_file_access.cc │ │ ├── empty_function.py │ │ ├── function.py │ │ ├── working_set_bench.cc │ │ ├── workingset.cc │ │ ├── workingset_impl.cc │ │ ├── workingset_py_wrapper.py │ │ └── workingset_v1.py │ ├── pagerank │ │ ├── function.py │ │ └── function_bench.py │ ├── pyaes │ │ ├── function.py │ │ └── function_bench.py │ ├── recognition │ │ ├── function.py │ │ ├── function_bench.py │ │ └── test.jpg │ └── run_lean_container.c ├── fork-micro │ ├── bench_exe_time_parent.cc │ ├── bench_exe_time_parent.py │ ├── bench_prepare_time.cc │ └── bench_prepare_time.py ├── function.py ├── gflags_dir │ ├── gflags-config-install.cmake │ ├── gflags-config-version.cmake │ ├── gflags-config.cmake │ ├── gflags-nonamespace-targets.cmake │ ├── gflags-targets.cmake │ └── include │ │ └── gflags │ │ ├── defines.h │ │ ├── gflags.h │ │ ├── gflags_completions.h │ │ └── gflags_declare.h ├── linux.json ├── os-network │ ├── one-sided-throughput │ │ ├── README.md │ │ ├── compile.sh │ │ ├── dc-clean-or.toml │ │ ├── dc-clean.toml │ │ ├── dc-throughput-or.toml │ │ ├── dc-throughput.toml │ │ ├── rc-clean-or.toml │ │ ├── rc-clean.toml │ │ ├── rc-throughput-or.toml │ │ ├── rc-throughput.toml │ │ └── sync_to_server.sh │ ├── rc-connection │ │ ├── README.md │ │ ├── clean.toml │ │ ├── compile.sh │ │ ├── dual-nic │ │ │ └── run.toml │ │ ├── latency │ │ │ └── run.toml │ │ ├── parse_thpt_log.py │ │ ├── sync_to_server.sh │ │ ├── throughput-machine │ │ │ └── run.toml │ │ └── throughput-thread │ │ │ └── run.toml │ └── rpc │ │ ├── bench_nil_rpc.cc │ │ └── bench_nil_rpc.hh ├── test.jpeg ├── test.mp4 └── yfinance.csv ├── exp_scripts ├── .gitignore ├── README.md ├── bootstrap.py ├── evaluation_runner.py ├── lean_container_log_analyser.py ├── makefile_template ├── mmcount.sh ├── mount_test_tmpfs.sh ├── requirements.txt ├── run_lean_container.sh ├── templates-build │ ├── template-build-exp.toml │ ├── template-build-lean-container.toml │ ├── template-build-mitosis-cache.toml │ ├── template-build-mitosis-cow-profile.toml │ ├── template-build-mitosis-cow.toml │ ├── template-build-mitosis-eager-resume.toml │ ├── template-build-mitosis-prefetch-profile.toml │ ├── template-build-mitosis-prefetch.toml │ ├── template-build-mitosis-use-rc.toml │ ├── template-build-pause-runner.toml │ └── template-clean.toml ├── templates-run │ ├── execution-peak │ │ ├── empty-fork.toml │ │ ├── peak-c-execution.toml │ │ ├── peak-function-execution.toml │ │ └── peak-nil-rpc.toml │ ├── loadspike │ │ └── template-run-mitosis-startup.toml │ ├── many-to-one-c │ │ ├── template-lean-container.toml │ │ └── template-touch-ratio.toml │ ├── many-to-one-func │ │ └── template-lean-container.toml │ ├── micro-c │ │ ├── template-run-micro-execution.toml │ │ ├── template-run-micro-prepare.toml │ │ ├── template-run-micro-startup-execution.toml │ │ ├── template-run-micro-startup.toml │ │ └── template-run-micro-touch-ratio.toml │ └── micro-func │ │ ├── template-run-micro-execution-hanged-cache.toml │ │ ├── template-run-micro-execution-hanged.toml │ │ ├── template-run-micro-execution.toml │ │ ├── template-run-micro-prepare.toml │ │ ├── template-run-micro-startup-execution.toml │ │ ├── template-run-micro-startup.toml │ │ ├── template-run-micro-warm-start-with-pause.toml │ │ ├── template-run-micro-with-trigger-local-fork.toml │ │ └── template-run-micro-with-trigger.toml └── toml_generator.py ├── loop_runner.sh ├── makefile ├── mitosis-kms ├── Kbuild ├── Kbuild-mitosis ├── Kbuild-mitosis-cache ├── Kbuild-mitosis-cow ├── Kbuild-mitosis-cow-profile ├── Kbuild-mitosis-eager-resume ├── Kbuild-mitosis-prefetch ├── Kbuild-mitosis-prefetch-profile ├── Kbuild-mitosis-use-rc ├── Makefile ├── build.py └── fork │ ├── Cargo.lock │ ├── Cargo.toml │ ├── build.rs │ ├── src │ ├── kernel_helper.c │ ├── kernel_helper.h │ └── lib.rs │ └── tests │ └── test.rs ├── mitosis-macros ├── Cargo.toml ├── src │ └── lib.rs └── unitests │ ├── Kbuild │ ├── Makefile │ ├── global_variables │ ├── Cargo.toml │ ├── src │ │ ├── .lib.rs.swp │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── kernel_module_param │ ├── Cargo.toml │ ├── build.rs │ ├── src │ │ ├── config.rs │ │ ├── lib.rs │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ └── tests │ │ └── test.rs │ └── run_tests.py ├── mitosis-user-libs ├── README.md ├── mitosis-c-client │ └── include │ │ ├── common.h │ │ └── syscall.h ├── mitosis-lean-container │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── app │ │ ├── compression │ │ │ ├── Dockerfile │ │ │ ├── compression-0 │ │ │ │ └── linux.json │ │ │ ├── compression-1 │ │ │ │ └── linux.json │ │ │ ├── compression-2 │ │ │ │ └── linux.json │ │ │ ├── function.py │ │ │ └── requirements.txt │ │ ├── criu-base │ │ │ └── Dockerfile │ │ ├── criu │ │ │ ├── .gitignore │ │ │ ├── benchmark.py │ │ │ ├── copy_env.sh │ │ │ ├── host_dump.sh │ │ │ └── restore.sh │ │ ├── hello │ │ │ ├── Dockerfile │ │ │ ├── hello.py │ │ │ └── requirements.txt │ │ ├── pause-bench │ │ │ ├── chameleon │ │ │ │ ├── Dockerfile │ │ │ │ ├── function.py │ │ │ │ └── requirements.txt │ │ │ ├── compression │ │ │ │ ├── Dockerfile │ │ │ │ ├── compression │ │ │ │ │ └── linux.json │ │ │ │ ├── function.py │ │ │ │ └── requirements.txt │ │ │ ├── helloworld │ │ │ │ ├── Dockerfile │ │ │ │ └── hello.py │ │ │ ├── image │ │ │ │ ├── Dockerfile │ │ │ │ ├── function.py │ │ │ │ ├── requirements.txt │ │ │ │ └── test.jpeg │ │ │ ├── json │ │ │ │ ├── Dockerfile │ │ │ │ ├── function.py │ │ │ │ └── linux.json │ │ │ ├── pagerank │ │ │ │ ├── Dockerfile │ │ │ │ ├── function.py │ │ │ │ └── requirements.txt │ │ │ ├── pyaes │ │ │ │ ├── Dockerfile │ │ │ │ ├── function.py │ │ │ │ └── requirements.txt │ │ │ └── recognition │ │ │ │ ├── Dockerfile │ │ │ │ ├── function.py │ │ │ │ ├── requirements.txt │ │ │ │ └── test.jpg │ │ └── simple_child │ │ │ ├── Dockerfile │ │ │ ├── common.h │ │ │ ├── compression-0 │ │ │ └── linux.json │ │ │ ├── compression-1 │ │ │ └── linux.json │ │ │ ├── compression-2 │ │ │ └── linux.json │ │ │ ├── lean_child.cc │ │ │ ├── linux.json │ │ │ ├── nil_rpc.cc │ │ │ ├── requirements.txt │ │ │ ├── syscall.h │ │ │ ├── test.jpeg │ │ │ ├── test.mp4 │ │ │ └── yfinance.csv │ ├── lib │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── benchmark │ │ │ ├── benchmark.cmake │ │ │ ├── benchmark_lean_container.c │ │ │ ├── benchmark_lean_container_pause_w_command.c │ │ │ └── benchmark_lean_container_w_command.c │ │ ├── cli │ │ │ ├── cli.cmake │ │ │ └── start_lean_container.c │ │ ├── core │ │ │ ├── lean_container.c │ │ │ └── lean_container.h │ │ ├── scripts │ │ │ ├── lean_container_scalability.toml │ │ │ └── sync_to_server.sh │ │ └── tests │ │ │ ├── test_cached_namespace.c │ │ │ ├── test_lean_container_pause.c │ │ │ ├── test_lean_container_template.c │ │ │ ├── test_setup_lean_container.c │ │ │ ├── test_setup_lean_container_w_double_fork.c │ │ │ └── tests.cmake │ ├── make_app_rootfs.py │ └── mount_device.py ├── mitosis-protocol │ ├── Cargo.toml │ └── src │ │ └── lib.rs └── mitosis-rust-client │ ├── Cargo.toml │ └── src │ ├── lib.rs │ ├── macros.rs │ └── signatures.rs ├── mitosis-util ├── Cargo.toml ├── bench │ ├── Kbuild │ ├── Makefile │ ├── README.md │ ├── build.py │ └── cpu_binding │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── scripts │ │ ├── build.toml │ │ ├── clean.toml │ │ └── run.toml │ │ └── src │ │ ├── lib.rs │ │ └── native │ │ ├── kernel_helper.c │ │ └── kernel_helper.h ├── src │ ├── bench.rs │ ├── ctx.rs │ ├── lib.rs │ ├── reporter.rs │ └── reporter │ │ └── thpt.rs └── unitests │ ├── Kbuild │ ├── Makefile │ ├── run_tests.py │ └── sample_benchmark │ ├── Cargo.toml │ ├── src │ └── lib.rs │ └── tests │ └── test.rs ├── mitosis ├── Cargo.toml ├── Kbuild ├── Makefile ├── build.rs ├── src │ ├── bindings.rs │ ├── core_syscall_handler.rs │ ├── dc_pool.rs │ ├── descriptors │ │ ├── child.rs │ │ ├── mod.rs │ │ ├── page_table.rs │ │ ├── pair.rs │ │ ├── parent.rs │ │ ├── rdma.rs │ │ ├── reg.rs │ │ └── vma.rs │ ├── kern_wrappers.rs │ ├── kern_wrappers │ │ ├── mm.rs │ │ ├── page.rs │ │ ├── task.rs │ │ ├── vma.rs │ │ └── vma_iters.rs │ ├── lib.rs │ ├── lock_bundler.rs │ ├── mem_pools.rs │ ├── native │ │ ├── kernel_helper.c │ │ └── kernel_helper.h │ ├── prefetcher │ │ ├── executor.rs │ │ ├── mod.rs │ │ └── strategies.rs │ ├── rc_conn_pool.rs │ ├── rdma_context.rs │ ├── remote_mapping │ │ ├── mod.rs │ │ ├── page_structures.rs │ │ └── page_table.rs │ ├── remote_paging.rs │ ├── remote_pt_cache.rs │ ├── rpc_caller_pool.rs │ ├── rpc_handlers.rs │ ├── rpc_service.rs │ ├── shadow_process.rs │ ├── shadow_process │ │ ├── page.rs │ │ ├── page_table.rs │ │ └── vma.rs │ ├── shadow_process_service.rs │ ├── startup.rs │ └── syscalls.rs └── unitests │ ├── .gitignore │ ├── Kbuild │ ├── Makefile │ ├── build.py │ ├── dc_pool │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── fork │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── kern_wrapper │ ├── Cargo.toml │ ├── src │ │ ├── lib.rs │ │ └── my_syscall.rs │ └── tests │ │ └── test.rs │ ├── prefetcher │ ├── Cargo.toml │ ├── src │ │ ├── lib.rs │ │ └── my_syscall.rs │ └── tests │ │ └── test.rs │ ├── rc_conn_pool │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── rdma_context │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── remote_page_table │ ├── Cargo.toml │ ├── src │ │ ├── lib.rs │ │ └── my_syscall.rs │ └── tests │ │ └── test.rs │ ├── run_tests.py │ ├── serializer │ ├── Cargo.toml │ ├── src │ │ ├── lib.rs │ │ └── my_syscall.rs │ └── tests │ │ └── test.rs │ ├── services │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── shadow_process │ ├── Cargo.toml │ ├── src │ │ ├── lib.rs │ │ └── my_syscall.rs │ └── tests │ │ └── test.rs │ └── syscalls │ ├── Cargo.toml │ ├── src │ ├── lib.rs │ └── my_syscall.rs │ └── tests │ └── test.rs ├── os-network ├── Cargo.toml ├── README.md ├── bench │ ├── Kbuild │ ├── Makefile │ ├── build.py │ ├── dc_read_client │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ ├── dc_read_or_client │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ ├── one_sided_read_server │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ ├── rc_conn_client │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ ├── rc_conn_server │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ ├── rc_read_client │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ └── rc_read_or_client │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ ├── lib.rs │ │ └── native │ │ ├── kernel_helper.c │ │ └── kernel_helper.h ├── rust-toolchain.toml ├── src │ ├── bytes.rs │ ├── conn.rs │ ├── datagram.rs │ ├── datagram │ │ ├── msg.rs │ │ ├── ud.rs │ │ └── ud_receiver.rs │ ├── future.rs │ ├── lib.rs │ ├── rdma.rs │ ├── rdma │ │ ├── dc.rs │ │ ├── payload.rs │ │ ├── payload │ │ │ ├── dc.rs │ │ │ ├── rc.rs │ │ │ └── ud.rs │ │ └── rc.rs │ ├── remote_memory.rs │ ├── remote_memory │ │ ├── local.rs │ │ ├── rdma.rs │ │ └── rdma │ │ │ ├── dc.rs │ │ │ └── rc.rs │ ├── rpc.rs │ ├── rpc │ │ ├── analysis.rs │ │ ├── header.rs │ │ ├── header_factory.rs │ │ ├── hook.rs │ │ ├── impls.rs │ │ ├── impls │ │ │ └── ud.rs │ │ └── service.rs │ ├── serialize.rs │ └── timeout.rs └── unitests │ ├── Kbuild │ ├── Makefile │ ├── bytes │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── dc │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── rc │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── remote_memory │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── rpc │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── run_tests.py │ ├── timeout │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── ud │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── ud_session │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ └── wc_err │ ├── Cargo.toml │ ├── src │ └── lib.rs │ └── tests │ └── test.rs ├── samples ├── cpp │ ├── .gitignore │ ├── CMakeLists.txt │ ├── child.cc │ └── parent.cc └── python │ ├── child.py │ ├── parent.py │ └── syscall_lib.py ├── scripts ├── bootstrap_proxy.py ├── log.txt ├── sync.sh └── test.toml └── stress-test ├── .gitignore ├── CMakeLists.txt ├── README.md ├── bootstrap.py ├── evaluation_runner.py ├── fork └── simple_parent.cc ├── makefile_template ├── rpc ├── Kbuild ├── Kbuild-checksum-payload ├── Kbuild-empty-rpc ├── Makefile ├── build_tests.py ├── rpc_client │ ├── Cargo.toml │ ├── build.rs │ ├── src │ │ ├── lib.rs │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ └── tests │ │ └── test.rs ├── rpc_common │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── payload.rs │ │ └── random.rs ├── rpc_server │ ├── Cargo.toml │ ├── build.rs │ ├── src │ │ ├── lib.rs │ │ └── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ └── tests │ │ └── test.rs ├── rpc_single_machine │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs └── run_tests.py ├── templates-build ├── template-build-cpp.toml ├── template-build-lean-container.toml ├── template-build-mitosis.toml ├── template-build-rpc-bench.toml ├── template-build-rpc-checksum.toml └── template-clean.toml ├── templates-run ├── peak-lean-container.toml └── peak-rpc-kernel-module.toml └── toml_generator.py /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/target-test 3 | Cargo.lock 4 | Module.symvers 5 | .cache.mk 6 | .tmp_versions 7 | *.cmd 8 | *.o 9 | *.ko 10 | *.mod.c 11 | modules.order 12 | .idea 13 | scripts/*.sh 14 | scripts/*.py 15 | build/ 16 | .vscode/ 17 | scripts/*.toml 18 | scripts/exp 19 | .DS_Store 20 | -------------------------------------------------------------------------------- /.gitlab/issue_templates/bug-report.md: -------------------------------------------------------------------------------- 1 | ## Summary 2 | 3 | (Summarize the bug encountered concisely) 4 | 5 | ## Steps to reproduce 6 | 7 | (Provide a reproducible test case that is the bare minimum necessary to generate the problem) 8 | 9 | ## What is the current bug behavior? 10 | 11 | (What actually happens) 12 | 13 | ## What is the expected correct behavior? 14 | 15 | (What you should see instead) 16 | 17 | ## Relevant logs and/or screenshots 18 | 19 | (Paste any relevant logs - use code blocks (```) to format console output, logs, and code, as 20 | it's very hard to read otherwise.) 21 | 22 | ## Possible fixes 23 | 24 | (If you can, link to the line of code that might be responsible for the problem) -------------------------------------------------------------------------------- /.gitlab/issue_templates/feature.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | (A clear and concise description of the problem or missing capability.) 4 | 5 | ## Relevant Modules 6 | 7 | (how many modules you use?) 8 | 9 | ## Deliverable 10 | 11 | (After the issue is closed, what we can have?) 12 | 13 | ## Tasks 14 | 15 | (Optional. A list of tasks to complete. ) 16 | 17 | 18 | --- 19 | 20 | 21 | ## Reference 22 | 23 | (Optional. Related issues or links to related resources) 24 | -------------------------------------------------------------------------------- /.gitlab/merge_request_templates/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to Mitosis 2 | 3 | **Check list** 4 | 5 | - [ ] Make sure you fixed all the warnings generated by the rust compile. If not, specific why the warning exists in the merge request. 6 | 7 | - [ ] Add brief comments to describe what you are doing 8 | 9 | - [ ] Each single function should be written in a single `fn test_xxx()`, with comments describing what is testing and what is the pre-request (e.g., `init_ctx`) of this function. 10 | 11 | - [ ] If you update the submodule, be sure to run `git submodule update --init --recursive --remote` to update the references. 12 | 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/gflags"] 2 | path = deps/gflags 3 | url = https://github.com/gflags/gflags.git 4 | [submodule "deps/hashbrown"] 5 | path = deps/hashbrown 6 | url = https://github.com/ProjectMitosisOS/hashbrown.git 7 | [submodule "deps/krcore"] 8 | path = deps/krcore 9 | url = https://github.com/SJTU-IPADS/krcore-artifacts.git 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 distributed-rdma-serverless / mitosis-project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ci/check_kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test_machine=$1 4 | username=$2 5 | password=$3 6 | # show debug information 7 | dmesg 8 | result=$(dmesg | grep "kernel BUG") 9 | if [ "($result)" != "()" ];then 10 | echo "There is a bug in kernel, and we need to reboot the test machine" 11 | sudo ipmitool -I lanplus -H idrac-$test_machine -U $username -P $password chassis power cycle 12 | else 13 | echo "Seems like everything is alright" 14 | fi 15 | -------------------------------------------------------------------------------- /ci/check_module_exist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test_machine=$1 4 | username=$2 5 | password=$3 6 | result=$(lsmod | grep testmodule) 7 | if [ "($result)" != "()" ];then 8 | echo "Kernel module exists, and we need to reboot the test machine" 9 | sudo ipmitool -I lanplus -H idrac-$test_machine -U $username -P $password chassis power cycle 10 | else 11 | echo "Seems like everything is alright" 12 | fi 13 | -------------------------------------------------------------------------------- /ci/install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # verify rust installed or not 4 | if rustc --version; then 5 | echo "rust is already installed" 6 | else 7 | echo "install rust now" 8 | curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y 9 | source $HOME/.cargo/env 10 | fi 11 | 12 | rustup default nightly-2022-02-05-x86_64-unknown-linux-gnu 13 | rustup component add rust-src 14 | -------------------------------------------------------------------------------- /ci/test_net.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/ci/test_net.sh -------------------------------------------------------------------------------- /deps/deps.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | include( ExternalProject ) 3 | 4 | # depend 5 | 6 | ## ggflags 7 | set(ggflags_DIR "${CMAKE_SOURCE_DIR}/../deps/gflags") 8 | add_subdirectory(${CMAKE_SOURCE_DIR}/../deps/r2/deps/gflags gflags_dir) 9 | -------------------------------------------------------------------------------- /docs/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/docs/example.gif -------------------------------------------------------------------------------- /docs/network-daemon.md: -------------------------------------------------------------------------------- 1 | # A short documentation of the network daemon 2 | 3 | ## Module graphs 4 | 5 | ### Network connection 6 | ```mermaid 7 | flowchart LR 8 | A[NetConn] --> B[RDMA] 9 | B-->C[RC] 10 | B-->D[UD] 11 | B-->E[DCT] 12 | ``` 13 | 14 | ### Remote memory 15 | ```mermaid 16 | flowchart LR 17 | A[Device] 18 | A-->B[Local] 19 | A-->C[RDMA] 20 | A-->D[RPC] 21 | ``` 22 | 23 | We may not implement the RPC device, if the time does not permit. 24 | 25 | -------------------------------------------------------------------------------- /docs/roadmap.md: -------------------------------------------------------------------------------- 1 | We will push the forward of MITOSIS as much as possible. 2 | 3 | ## Road map 4 | - [ ] The kernel-space implementation. 5 | - [ ] The user-space shim layer. 6 | - [ ] A example integration to Fn. 7 | - [ ] Be compatiable to other container platforms. 8 | 9 | ## Open questiosn 10 | 11 | TBD 12 | -------------------------------------------------------------------------------- /docs/tests-and-benchmarks.md: -------------------------------------------------------------------------------- 1 | # Testing and Benchmarking 2 | 3 | We have provided unit tests, stress tests, and benchmarks for mitosis. 4 | 5 | ## Unit Tests 6 | 7 | We have provided several unit tests for each module crates. The documents for unit tests can be found [here](unit-test/README.md). 8 | 9 | ## Stress Tests 10 | 11 | We have provided stress tests for the following functionalities in mitosis. 12 | 13 | - RPC 14 | - Remote Fork 15 | 16 | To run the stress tests, you should refer to the [README](../stress-test/README.md) under stress-test directory. 17 | 18 | ## Benchmarks 19 | 20 | The documents of benchmarks of mitosis can be found [here](benchmarks/README.md). -------------------------------------------------------------------------------- /docs/unit-test/README.md: -------------------------------------------------------------------------------- 1 | # Mitosis Unit Tests 2 | 3 | ## Overview 4 | 5 | Each module crate is equipped with several unit tests, including `mitosis/unitests`, `os-network/unitests`, and `mitosis-macros/unitests`. For example, we can run the unit tests under `mitosis/unitests` with the commands below. 6 | 7 | ```bash 8 | cd mitosis/unitests 9 | ls # show all the unit tests 10 | # dc_pool fork prefetch ... 11 | python run_tests.py # run all the unit tests 12 | python run_tests.py fork # run one single unit test, do not include the '/' after the directory name 13 | ``` 14 | 15 | The successful unit tests will end with the following log lines. 16 | 17 | ``` 18 | running 1 test 19 | test test_basic ... ok 20 | 21 | test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.22s 22 | ``` 23 | -------------------------------------------------------------------------------- /exp/.gitignore: -------------------------------------------------------------------------------- 1 | cmake* -------------------------------------------------------------------------------- /exp/common/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | -------------------------------------------------------------------------------- /exp/common/bench.py: -------------------------------------------------------------------------------- 1 | import time 2 | import sys 3 | 4 | def report(name, start, end): 5 | passed_us = (end - start) * 1000000 6 | print("[%s] duration: %.2f ms" % (str(name), passed_us / 1000)) 7 | sys.stdout.flush() 8 | -------------------------------------------------------------------------------- /exp/common/connector.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../../mitosis-user-libs/mitosis-c-client/include/syscall.h" 6 | 7 | 8 | DEFINE_string(gid, "fe80:0000:0000:0000:248a:0703:009c:7c94", "connect gid"); 9 | 10 | DEFINE_int64(mac_id, 1, "machine id"); 11 | DEFINE_int64(nic_id, 0, "nic idx. Should be align with gid"); 12 | 13 | int 14 | main(int argc, char *argv[]) { 15 | gflags::ParseCommandLineFlags(&argc, &argv, true); 16 | int sd = sopen(); 17 | assert(sd != 0); 18 | // target on val08 19 | auto res = call_connect(sd, FLAGS_gid.c_str(), FLAGS_mac_id, FLAGS_nic_id); 20 | std::cout<<"connect res: " << res << std::endl; 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /exp/common/simple_child.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../mitosis-user-libs/mitosis-c-client/include/syscall.h" 5 | 6 | DEFINE_int64(mac_id, 0, "machine id"); 7 | DEFINE_int64(handler_id, 73, "rfork handler id"); 8 | DEFINE_int64(wait_finish_sec, 0, "waiting for parent finish prepare"); 9 | 10 | 11 | int 12 | main(int argc, char *argv[]) { 13 | gflags::ParseCommandLineFlags(&argc, &argv, true); 14 | sleep(FLAGS_wait_finish_sec); 15 | int sd = sopen(); 16 | // printf("mac id:%d\n", FLAGS_mac_id); 17 | assert(sd != 0); 18 | fork_resume_remote(sd, FLAGS_mac_id, FLAGS_handler_id); 19 | assert(false); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /exp/common/simple_parent.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../../mitosis-user-libs/mitosis-c-client/include/syscall.h" 7 | 8 | DEFINE_int64(handler_id, 73, "rfork handler id"); 9 | DEFINE_bool(pin, false, "whether pin in kernel"); 10 | 11 | int 12 | main(int argc, char *argv[]) { 13 | gflags::ParseCommandLineFlags(&argc, &argv, true); 14 | 15 | int sd = sopen(); 16 | int cnt = 0; 17 | assert(sd != 0); 18 | 19 | if (FLAGS_pin) { 20 | fork_prepare_ping(sd, FLAGS_handler_id); 21 | // return immediately 22 | return 0; 23 | } else { 24 | sleep(1); 25 | printf("time %d\n", cnt++); 26 | fork_prepare(sd, FLAGS_handler_id); 27 | } 28 | 29 | while (1) { 30 | printf("time %d\n", cnt++); 31 | sleep(1); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /exp/common/simple_parent.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import syscall_lib 5 | import argparse 6 | import time 7 | 8 | parser = argparse.ArgumentParser() 9 | parser.add_argument("-handler_id", type=int, default=73, 10 | help="rfork handler id") 11 | parser.add_argument("-pin", type=int, default=0, 12 | help="whether pin in kernel") 13 | args = parser.parse_args() 14 | sys.path.append("module_path") 15 | 16 | handler_id = args.handler_id 17 | pin = args.pin 18 | 19 | if __name__ == '__main__': 20 | fd = syscall_lib.open() 21 | 22 | print("open MITOSIS client, fd {}", fd) 23 | time.sleep(1) 24 | counter = 0 25 | if pin != 0: 26 | syscall_lib.call_prepare_ping(fd, handler_id) 27 | for i in range(5): 28 | counter += 1 29 | s = "check counter %d, fd %d" % (counter, fd) 30 | print(s) 31 | time.sleep(1) 32 | os._exit(0) 33 | else: 34 | syscall_lib.call_prepare(fd, handler_id) 35 | while True: 36 | counter += 1 37 | s = "check counter %d, fd %d" % (counter, fd) 38 | print(s) 39 | time.sleep(1) 40 | -------------------------------------------------------------------------------- /exp/common/syscall_lib.py: -------------------------------------------------------------------------------- 1 | import fcntl 2 | import os 3 | 4 | PREPARE = 4 5 | RESUME_LOCAL = 5 6 | RESUME_LOCAL_RPC = 6 7 | PREPARE_PING = 7 8 | 9 | def open(): 10 | fd = os.open('/dev/mitosis-syscalls', os.O_RDWR) 11 | return fd 12 | 13 | def call_prepare(sd, key): 14 | res = fcntl.ioctl(sd, PREPARE, key) 15 | return res 16 | 17 | def call_prepare_ping(sd, key): 18 | res = fcntl.ioctl(sd, PREPARE_PING, key) 19 | return res 20 | 21 | 22 | def call_resume_local(sd,key): 23 | res = fcntl.ioctl(sd, RESUME_LOCAL, key) 24 | return res 25 | 26 | def call_resume_local_rpc(sd,key): 27 | res = fcntl.ioctl(sd, RESUME_LOCAL_RPC, key) 28 | return res 29 | -------------------------------------------------------------------------------- /exp/criu-micro/.gitignore: -------------------------------------------------------------------------------- 1 | imgs/ 2 | .base/ 3 | *.log 4 | -------------------------------------------------------------------------------- /exp/criu-micro/bench_exe_time_parent.py: -------------------------------------------------------------------------------- 1 | import mmap 2 | import os 3 | import sys 4 | from ctypes import sizeof 5 | 6 | sys.path.append("../common") # include outer path 7 | from criu_wrapper import * 8 | 9 | import syscall_lib 10 | import argparse 11 | import time 12 | 13 | parser = argparse.ArgumentParser() 14 | parser.add_argument("-working_set", type=int, default=16777216, 15 | help="working set size") 16 | parser.add_argument("-touch_ratio", type=int, default=100, help="child touch ratio") 17 | 18 | args, _ = parser.parse_known_args() 19 | 20 | touch_ratio = args.touch_ratio 21 | working_set = args.working_set 22 | 23 | mm = '1' * working_set 24 | 25 | @tick_execution_time 26 | def touch_working_set(working_sz): 27 | mm[0:working_sz-1] 28 | 29 | @criu_bench 30 | def bench(): 31 | touch_working_set(working_sz=(working_set * touch_ratio // 100)) 32 | 33 | if __name__ == '__main__': 34 | bench() 35 | -------------------------------------------------------------------------------- /exp/criu-micro/copy_env.sh: -------------------------------------------------------------------------------- 1 | if [ "$#" -ne 1 ]; then 2 | echo "Usage: $0 rootfs_path" 3 | exit 1 4 | fi 5 | 6 | # copy images to the rootfs 7 | rm -rf $1/imgs 8 | cp -r imgs $1/imgs 9 | 10 | # make directory for the lock file and copy to specific location 11 | rm -rf $1/${PWD} 12 | mkdir -p -m775 $1/${PWD} 13 | cp -r *.py $1/${PWD}/ 14 | cp -a -r lock $1/${PWD}/ && echo -n 1 > $1/${PWD}/lock 15 | cp -a -r execution.log $1/${PWD}/ 16 | 17 | # copy share libraries 18 | cp -r /usr/bin/python3.5 $1/usr/bin/python3.5 19 | cp -r /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so $1/usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so 20 | cp -r /usr/lib/python3.5/lib-dynload/mmap.cpython-35m-x86_64-linux-gnu.so $1/usr/lib/python3.5/lib-dynload/mmap.cpython-35m-x86_64-linux-gnu.so 21 | cp -r /usr/lib/locale/locale-archive $1/usr/lib/locale/locale-archive 22 | cp -r /lib/x86_64-linux-gnu/* $1/lib/x86_64-linux-gnu 23 | 24 | # copy restore scripts 25 | cp restore.sh $1/restore.sh 26 | 27 | # chmod 28 | sudo chmod 666 $1/dev/null 29 | sudo chmod 755 $1 30 | -------------------------------------------------------------------------------- /exp/criu-micro/host_dump.sh: -------------------------------------------------------------------------------- 1 | if [ "$#" -ne 1 ]; then 2 | echo "Usage: $0 working_set_size" 3 | exit 1 4 | fi 5 | 6 | echo -n 0 > lock 7 | setsid python3 bench_exe_time_parent.py -working_set $1 -profile 1 < /dev/null > execution.log 2>&1 & 8 | export TARGET_PID=$(pgrep python3) 9 | echo "TARGET_PID=${TARGET_PID}" 10 | rm -rf imgs && mkdir imgs 11 | sleep 3 12 | LD_LIBRARY_PATH=/home/wtx/criu/.deps-install/lib /home/wtx/criu/criu-3.15/criu/criu dump --images-dir=./imgs -t ${TARGET_PID} -vvvv -o dump.log 13 | tail -n 1 imgs/dump.log 14 | -------------------------------------------------------------------------------- /exp/criu-micro/lock: -------------------------------------------------------------------------------- 1 | 0 -------------------------------------------------------------------------------- /exp/criu-micro/rcopy.sh: -------------------------------------------------------------------------------- 1 | if [ "$#" -ne 2 ]; then 2 | echo "Usage: $0 directory_path ipoib_ip" 3 | exit 1 4 | fi 5 | 6 | for f in $(ls $1) 7 | do 8 | rcopy $1/$f $2 9 | done 10 | -------------------------------------------------------------------------------- /exp/criu-micro/restore.sh: -------------------------------------------------------------------------------- 1 | START=$(date +%s.%N) 2 | echo "before criu restore: $START" 3 | /criu/criu/criu restore --images-dir=./imgs -vvvv -o restore.log 4 | END=$(date +%s.%N) 5 | # TOTAL_TIME=$(echo "($END-$START)*1000" | bc) # uncomment this to calculate the full end-to-end time 6 | -------------------------------------------------------------------------------- /exp/criu-micro/run_benchmark.sh: -------------------------------------------------------------------------------- 1 | START=$(date +%s.%N) 2 | echo "before start lean container: $START" 3 | ../../mitosis-user-libs/mitosis-lean-container/lib/build/start_lean_container $1 $2 /bin/bash /restore.sh 4 | END=$(date +%s.%N) 5 | # TOTAL_TIME=$(echo "($END-$START)*1000" | bc) # uncomment this to calculate the full end-to-end time 6 | tail -n 2 $2/$(pwd)/execution.log 7 | -------------------------------------------------------------------------------- /exp/fork-functions/chameleon/function_bench.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | sys.path.append("../../common") # include outer path 5 | from func_bench_wrapper import * 6 | 7 | import six 8 | from chameleon import PageTemplate 9 | 10 | BIGTABLE_ZPT = """\ 11 | 13 | 14 | 19 | 20 |
15 | 18 |
""" % six.text_type.__name__ 21 | 22 | 23 | def handler(): 24 | """ 25 | "params": [ 26 | "{\"num_of_rows\":\"200\", \"num_of_cols\":\"200\"}" 27 | ] 28 | """ 29 | num_of_rows = 200 30 | num_of_cols = 200 31 | 32 | tmpl = PageTemplate(BIGTABLE_ZPT) 33 | data = {} 34 | for i in range(num_of_cols): 35 | data[str(i)] = i 36 | 37 | table = [data for x in range(num_of_rows)] 38 | options = {'table': table} 39 | data = tmpl.render(options=options) 40 | 41 | 42 | @func_exec_bench 43 | def bench(): 44 | handler() 45 | 46 | 47 | if __name__ == '__main__': 48 | bench() 49 | -------------------------------------------------------------------------------- /exp/fork-functions/compression/function.py: -------------------------------------------------------------------------------- 1 | import gzip 2 | import os 3 | import shutil 4 | import sys 5 | 6 | sys.path.append("../../common") # include outer path 7 | from mitosis_wrapper import * 8 | 9 | time = 0 10 | 11 | @tick_execution_time 12 | def lambda_handler(): 13 | global time 14 | dst = 'result-' + str(time) 15 | src = 'compression-' + str(time) 16 | shutil.make_archive(dst, 'zip', src) 17 | time += 1 18 | 19 | @mitosis_bench 20 | def bench(): 21 | lambda_handler() 22 | 23 | if __name__ == '__main__': 24 | bench() 25 | -------------------------------------------------------------------------------- /exp/fork-functions/compression/function_bench.py: -------------------------------------------------------------------------------- 1 | import gzip 2 | import os 3 | import shutil 4 | import sys 5 | import time 6 | 7 | sys.path.append("../../common") # include outer path 8 | from func_bench_wrapper import * 9 | 10 | 11 | def handler(): 12 | dst = 'result-0' 13 | src = 'compression-0' 14 | shutil.make_archive(dst, 'zip', src) 15 | @func_exec_bench 16 | def bench(): 17 | handler() 18 | 19 | if __name__ == '__main__': 20 | bench() 21 | -------------------------------------------------------------------------------- /exp/fork-functions/dd/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import subprocess 4 | import sys 5 | # import numpy as np 6 | 7 | sys.path.append("../../common") # include outer path 8 | from mitosis_wrapper import * 9 | 10 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 11 | os.environ['MKL_NUM_THREADS'] = '1' 12 | 13 | tmp = '/tmp/' 14 | bs = 'bs=4M' 15 | count = 'count=100' 16 | 17 | @tick_execution_time 18 | def handler(): 19 | global start, end 20 | 21 | out_fd = open(tmp + 'io_write_logs', 'w') 22 | dd = subprocess.Popen(['dd', 'if=/dev/zero', 'of=/dev/zero', bs, count], stderr=out_fd) 23 | dd.communicate() 24 | 25 | subprocess.check_output(['ls', '-alh', tmp]) 26 | 27 | @mitosis_bench 28 | def bench(): 29 | handler() 30 | 31 | 32 | if __name__ == '__main__': 33 | bench() 34 | -------------------------------------------------------------------------------- /exp/fork-functions/ffmpeg/function.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import subprocess 4 | import sys 5 | 6 | sys.path.append("../../common") # include outer path 7 | from mitosis_wrapper import * 8 | 9 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 10 | os.environ['MKL_NUM_THREADS'] = '1' 11 | 12 | cleanup_re = re.compile('[^a-z]+') 13 | tmp = '/dev/shm/' 14 | 15 | 16 | @tick_execution_time 17 | def lambda_handler(): 18 | subprocess.check_output(['/usr/local/ffmpeg/bin/ffmpeg', '-y', 19 | '-i', '/tmp/test.mp4', 20 | '-vf', 'hflip', '/tmp/out.mp4']) 21 | 22 | 23 | @mitosis_bench 24 | def bench(): 25 | lambda_handler() 26 | 27 | 28 | if __name__ == '__main__': 29 | bench() 30 | -------------------------------------------------------------------------------- /exp/fork-functions/ffmpeg/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/exp/fork-functions/ffmpeg/test.mp4 -------------------------------------------------------------------------------- /exp/fork-functions/finra/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ -------------------------------------------------------------------------------- /exp/fork-functions/finra/child_function_wrapper.py: -------------------------------------------------------------------------------- 1 | import os 2 | import socket 3 | import subprocess 4 | import argparse 5 | 6 | import zerorpc 7 | 8 | parser = argparse.ArgumentParser() 9 | parser.add_argument("-command", type=str, default="ls", help="running cmd") 10 | parser.add_argument("-master_host", type=str, default="localhost", help="host name of master") 11 | parser.add_argument("-loop", type=int, default=0, help="loop num") 12 | args = parser.parse_args() 13 | 14 | cmd = args.command 15 | master_host = args.master_host 16 | loop = args.loop 17 | 18 | master_cli = zerorpc.Client() 19 | master_cli.connect("tcp://%s:%d" % (master_host, 8090)) 20 | 21 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 22 | s.bind(("0.0.0.0", 8080 + loop)) 23 | data, addr = s.recvfrom(1024) 24 | 25 | 26 | def runcmd(command): 27 | cmd = command 28 | proc = subprocess.Popen(cmd, shell=True) 29 | proc.wait() 30 | master_cli.report_finish_event() 31 | 32 | 33 | if __name__ == '__main__': 34 | runcmd(command=cmd) 35 | -------------------------------------------------------------------------------- /exp/fork-functions/finra/master.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import sys 3 | import time 4 | 5 | master_port = 7000 6 | trigger_port = 9000 7 | 8 | FINISH = "finish" 9 | ALL_DONE = "all done" 10 | 11 | host = '' 12 | start = time.time() 13 | 14 | 15 | def report(name, start, end): 16 | passed_us = (end - start) * 1000000 17 | print("[%s] duration: %.2f ms" % (str(name), passed_us / 1000)) 18 | sys.stdout.flush() 19 | 20 | 21 | def server(): 22 | global start, end 23 | ip_port = (host, master_port) 24 | server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # udp协议 25 | server.bind(ip_port) 26 | process_cnt = 0 27 | cnt = 0 28 | 29 | while True: 30 | data, client_addr = server.recvfrom(4096) 31 | data = data.decode() 32 | if data == FINISH: 33 | cnt += 1 34 | else: 35 | cnt = 0 36 | process_cnt = int(data) 37 | start = time.time() 38 | if process_cnt <= cnt: 39 | end = time.time() 40 | report("rule %d" % (cnt - 1), start, end) 41 | 42 | 43 | server() 44 | -------------------------------------------------------------------------------- /exp/fork-functions/finra/trigger.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import socket 3 | 4 | # python trigger.py -child_hosts=val04 -process=2 5 | import time 6 | 7 | parser = argparse.ArgumentParser() 8 | parser.add_argument("-child_hosts", type=str, default="", help="rpc server host") 9 | parser.add_argument("-parent_host", type=str, default="localhost", help="parent host") 10 | parser.add_argument("-process", type=int, default=1, help="rpc parallel num") 11 | args = parser.parse_args() 12 | process = args.process 13 | parent_host = args.parent_host 14 | child_hosts = str(args.child_hosts).split(' ') 15 | master_port = 7000 16 | parent_port = 8000 17 | trigger_port = 9000 18 | 19 | s_tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 20 | s_udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 21 | s_udp.sendto(str(1 + len(child_hosts) * process).encode(), ('', master_port)) 22 | 23 | s_tcp.connect((parent_host, parent_port)) 24 | s_tcp.sendall(parent_host.encode()) 25 | 26 | s_tcp.recv(1024).decode() 27 | 28 | for host in child_hosts: 29 | # Trigger without waiting 30 | for i in range(process): 31 | s_udp.sendto(b"data", (host, parent_port + i)) 32 | s_tcp.close() 33 | s_udp.close() 34 | -------------------------------------------------------------------------------- /exp/fork-functions/helloworld/function.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import time 4 | import mmap 5 | 6 | sys.path.append("../../common") # include outer path 7 | from mitosis_wrapper import * 8 | 9 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 10 | os.environ['MKL_NUM_THREADS'] = '1' 11 | 12 | 13 | @tick_execution_time 14 | def handler(): 15 | if profile == 1: 16 | print("hello world") 17 | else: 18 | s = "hello world" 19 | t = s.find('d') 20 | 21 | 22 | @mitosis_bench 23 | def bench(): 24 | handler() 25 | 26 | 27 | if __name__ == '__main__': 28 | bench() 29 | -------------------------------------------------------------------------------- /exp/fork-functions/helloworld/function_bench.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import time 4 | import mmap 5 | 6 | sys.path.append("../../common") # include outer path 7 | from func_bench_wrapper import * 8 | 9 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 10 | os.environ['MKL_NUM_THREADS'] = '1' 11 | 12 | 13 | def handler(): 14 | s = "hello world" 15 | s.find("d") 16 | 17 | @func_exec_bench 18 | def bench(): 19 | handler() 20 | 21 | 22 | if __name__ == '__main__': 23 | bench() 24 | -------------------------------------------------------------------------------- /exp/fork-functions/image/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/exp/fork-functions/image/test.jpeg -------------------------------------------------------------------------------- /exp/fork-functions/image/thumbnail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/exp/fork-functions/image/thumbnail.jpg -------------------------------------------------------------------------------- /exp/fork-functions/imgresize/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/exp/fork-functions/imgresize/test.jpeg -------------------------------------------------------------------------------- /exp/fork-functions/json/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import sys 4 | 5 | sys.path.append("../../common") # include outer path 6 | from mitosis_wrapper import * 7 | 8 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 9 | os.environ['MKL_NUM_THREADS'] = '1' 10 | 11 | f = open('linux.json') 12 | content = f.read() 13 | 14 | 15 | @tick_execution_time 16 | def lambda_handler(): 17 | json_data = json.loads(content) 18 | str_json = json.dumps(json_data, indent=4) 19 | 20 | 21 | @mitosis_bench 22 | def bench(): 23 | lambda_handler() 24 | 25 | 26 | if __name__ == '__main__': 27 | bench() 28 | -------------------------------------------------------------------------------- /exp/fork-functions/json/function_bench.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import sys 4 | 5 | sys.path.append("../../common") # include outer path 6 | from func_bench_wrapper import * 7 | 8 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 9 | os.environ['MKL_NUM_THREADS'] = '1' 10 | 11 | f = open('linux.json') 12 | content = f.read() 13 | 14 | 15 | def lambda_handler(): 16 | json_data = json.loads(content) 17 | str_json = json.dumps(json_data, indent=4) 18 | 19 | @func_exec_bench 20 | def bench(): 21 | lambda_handler() 22 | 23 | 24 | if __name__ == '__main__': 25 | bench() 26 | -------------------------------------------------------------------------------- /exp/fork-functions/linpack/function.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | import random 3 | import string 4 | import pyaes 5 | import json 6 | import os 7 | import sys 8 | from numpy import matrix, linalg, random 9 | 10 | sys.path.append("../../common") # include outer path 11 | from mitosis_wrapper import * 12 | 13 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 14 | os.environ['MKL_NUM_THREADS'] = '1' 15 | 16 | @tick_execution_time 17 | def handler(): 18 | n = 4 # FIXME: stuck when n is large 19 | # LINPACK benchmarks 20 | ops = (2.0 * n) * n * n / 3.0 + (2.0 * n) * n 21 | 22 | # Create AxA array of random numbers -0.5 to 0.5 23 | A = random.random_sample((n, n)) - 0.5 24 | B = A.sum(axis=1) 25 | 26 | # Convert to matrices 27 | A = matrix(A) 28 | B = matrix(B.reshape((n, 1))) 29 | 30 | # Ax = B 31 | x = linalg.solve(A, B) 32 | 33 | @mitosis_bench 34 | def bench(): 35 | handler() 36 | 37 | 38 | if __name__ == '__main__': 39 | bench() 40 | -------------------------------------------------------------------------------- /exp/fork-functions/linpack/function_bench.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | import random 3 | import string 4 | import pyaes 5 | import json 6 | import os 7 | import sys 8 | from numpy import matrix, linalg, random 9 | 10 | sys.path.append("../../common") # include outer path 11 | from func_bench_wrapper import * 12 | 13 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 14 | os.environ['MKL_NUM_THREADS'] = '1' 15 | 16 | def handler(): 17 | n = 4 # FIXME: stuck when n is large 18 | # LINPACK benchmarks 19 | ops = (2.0 * n) * n * n / 3.0 + (2.0 * n) * n 20 | 21 | # Create AxA array of random numbers -0.5 to 0.5 22 | A = random.random_sample((n, n)) - 0.5 23 | B = A.sum(axis=1) 24 | 25 | # Convert to matrices 26 | A = matrix(A) 27 | B = matrix(B.reshape((n, 1))) 28 | 29 | # Ax = B 30 | x = linalg.solve(A, B) 31 | 32 | @func_exec_bench 33 | def bench(): 34 | handler() 35 | 36 | 37 | if __name__ == '__main__': 38 | bench() 39 | -------------------------------------------------------------------------------- /exp/fork-functions/matmul/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import sys 4 | import numpy as np 5 | 6 | sys.path.append("../../common") # include outer path 7 | from mitosis_wrapper import * 8 | 9 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 10 | os.environ['MKL_NUM_THREADS'] = '1' 11 | 12 | 13 | def handler(): 14 | n = 64 15 | A = np.random.rand(n, n) 16 | B = np.random.rand(n, n) 17 | C = np.matmul(A, B) 18 | 19 | 20 | @mitosis_bench 21 | def bench(): 22 | handler() 23 | 24 | 25 | if __name__ == '__main__': 26 | bench() 27 | -------------------------------------------------------------------------------- /exp/fork-functions/matmul/function_bench.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import sys 4 | import numpy as np 5 | 6 | sys.path.append("../../common") # include outer path 7 | from func_bench_wrapper import * 8 | 9 | def handler(): 10 | n = 64 11 | A = np.random.rand(n, n) 12 | B = np.random.rand(n, n) 13 | C = np.matmul(A, B) 14 | 15 | @func_exec_bench 16 | def bench(): 17 | handler() 18 | 19 | 20 | if __name__ == '__main__': 21 | bench() 22 | -------------------------------------------------------------------------------- /exp/fork-functions/micro/empty_function.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import time 4 | 5 | sys.path.append("../../common") # include outer path 6 | 7 | import syscall_lib 8 | import bench 9 | from mitosis_wrapper import * 10 | 11 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 12 | os.environ['MKL_NUM_THREADS'] = '1' 13 | 14 | 15 | @tick_execution_time 16 | def handler(working_sz): 17 | pass 18 | 19 | 20 | @mitosis_bench 21 | def bench(): 22 | handler(working_sz=working_set) 23 | 24 | 25 | if __name__ == '__main__': 26 | bench() 27 | -------------------------------------------------------------------------------- /exp/fork-functions/micro/workingset_py_wrapper.py: -------------------------------------------------------------------------------- 1 | from ctypes import * 2 | 3 | import os 4 | import argparse 5 | 6 | def get_args(): 7 | parser = argparse.ArgumentParser() 8 | parser.add_argument("-working_set", type=int, default=16777216, 9 | help="working set size") 10 | parser.add_argument("-app_name", type=str, default="micro", help="application name") 11 | args = parser.parse_args() 12 | return args 13 | 14 | def main_micro(): 15 | args = get_args() 16 | 17 | print("start testing, ",args.working_set) 18 | so_workingset = cdll.LoadLibrary(os.getcwd()+ "/libmicro_function.so") 19 | so_workingset.init_buffer(args.working_set) 20 | so_workingset.handler("Cold", args.working_set) 21 | 22 | def main_hello(): 23 | args = get_args() 24 | print("hello world") 25 | 26 | if __name__ == "__main__": 27 | main_micro() 28 | # main_hello() 29 | 30 | -------------------------------------------------------------------------------- /exp/fork-functions/pagerank/function.py: -------------------------------------------------------------------------------- 1 | import igraph 2 | import os 3 | import sys 4 | 5 | sys.path.append("../../common") # include outer path 6 | from mitosis_wrapper import * 7 | 8 | size = 100000 9 | 10 | graph = igraph.Graph.Barabasi(size, 10) 11 | 12 | @tick_execution_time 13 | def lambda_handler(): 14 | """ 15 | "{\"size\":\"100000\"}" 16 | 17 | :return: 18 | """ 19 | # print("start page rank") 20 | # result = graph.pagerank(implementation="power",niter=1000) 21 | result = graph.pagerank() 22 | print(result[0]) 23 | # print(graph) 24 | #print(graph.is_dag()) 25 | 26 | @mitosis_bench 27 | def bench(): 28 | lambda_handler() 29 | 30 | 31 | if __name__ == '__main__': 32 | bench() -------------------------------------------------------------------------------- /exp/fork-functions/pagerank/function_bench.py: -------------------------------------------------------------------------------- 1 | import igraph 2 | import os 3 | import sys 4 | 5 | sys.path.append("../../common") # include outer path 6 | from func_bench_wrapper import * 7 | 8 | size = 100000 9 | 10 | graph = igraph.Graph.Barabasi(size, 10) 11 | 12 | def lambda_handler(): 13 | """ 14 | "{\"size\":\"100000\"}" 15 | 16 | :return: 17 | """ 18 | # print("start page rank") 19 | # result = graph.pagerank(implementation="power",niter=1000) 20 | graph.pagerank() 21 | # print(graph) 22 | #print(graph.is_dag()) 23 | @func_exec_bench 24 | def bench(): 25 | lambda_handler() 26 | 27 | 28 | if __name__ == '__main__': 29 | bench() -------------------------------------------------------------------------------- /exp/fork-functions/pyaes/function.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | import random 3 | import string 4 | import pyaes 5 | import json 6 | import os 7 | import sys 8 | 9 | sys.path.append("../../common") # include outer path 10 | from mitosis_wrapper import * 11 | 12 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 13 | os.environ['MKL_NUM_THREADS'] = '1' 14 | 15 | def generate(length): 16 | letters = string.ascii_lowercase + string.digits 17 | return ''.join(random.choice(letters) for i in range(length)) 18 | 19 | @tick_execution_time 20 | def handler(): 21 | """ 22 | "params": [ 23 | "{\"length_of_message\":\"22000\", \"num_of_iterations\":\"1\"}" 24 | ] 25 | :return: 26 | """ 27 | length_of_message = 22000 28 | num_of_iterations = 1 29 | 30 | message = generate(length_of_message) 31 | 32 | # 128-bit key (16 bytes) 33 | KEY = b'\xa1\xf6%\x8c\x87}_\xcd\x89dHE8\xbf\xc9,' 34 | 35 | for loops in range(num_of_iterations): 36 | aes = pyaes.AESModeOfOperationCTR(KEY) 37 | ciphertext = aes.encrypt(message) 38 | 39 | aes = pyaes.AESModeOfOperationCTR(KEY) 40 | plaintext = aes.decrypt(ciphertext) 41 | aes = None 42 | 43 | 44 | @mitosis_bench 45 | def bench(): 46 | handler() 47 | 48 | 49 | if __name__ == '__main__': 50 | bench() 51 | -------------------------------------------------------------------------------- /exp/fork-functions/pyaes/function_bench.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | import random 3 | import string 4 | import pyaes 5 | import json 6 | import os 7 | import sys 8 | 9 | sys.path.append("../../common") # include outer path 10 | from func_bench_wrapper import * 11 | 12 | os.environ['OPENBLAS_NUM_THREADS'] = '1' 13 | os.environ['MKL_NUM_THREADS'] = '1' 14 | 15 | def generate(length): 16 | letters = string.ascii_lowercase + string.digits 17 | return ''.join(random.choice(letters) for i in range(length)) 18 | 19 | def handler(): 20 | """ 21 | "params": [ 22 | "{\"length_of_message\":\"22000\", \"num_of_iterations\":\"1\"}" 23 | ] 24 | :return: 25 | """ 26 | length_of_message = 22000 27 | num_of_iterations = 1 28 | 29 | message = generate(length_of_message) 30 | 31 | # 128-bit key (16 bytes) 32 | KEY = b'\xa1\xf6%\x8c\x87}_\xcd\x89dHE8\xbf\xc9,' 33 | 34 | for loops in range(num_of_iterations): 35 | aes = pyaes.AESModeOfOperationCTR(KEY) 36 | ciphertext = aes.encrypt(message) 37 | 38 | aes = pyaes.AESModeOfOperationCTR(KEY) 39 | plaintext = aes.decrypt(ciphertext) 40 | aes = None 41 | 42 | @func_exec_bench 43 | def bench(): 44 | handler() 45 | 46 | 47 | if __name__ == '__main__': 48 | bench() 49 | -------------------------------------------------------------------------------- /exp/fork-functions/recognition/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/exp/fork-functions/recognition/test.jpg -------------------------------------------------------------------------------- /exp/function.py: -------------------------------------------------------------------------------- 1 | import gzip 2 | import os 3 | import shutil 4 | import sys 5 | 6 | sys.path.append("../../common") # include outer path 7 | from mitosis_wrapper import * 8 | 9 | time = 0 10 | 11 | @tick_execution_time 12 | def lambda_handler(): 13 | global time 14 | dst = 'result-' + str(time) 15 | src = 'compression-' + str(time) 16 | shutil.make_archive(dst, 'zip', src) 17 | time += 1 18 | 19 | @mitosis_bench 20 | def bench(): 21 | lambda_handler() 22 | 23 | if __name__ == '__main__': 24 | bench() 25 | -------------------------------------------------------------------------------- /exp/gflags_dir/gflags-config-version.cmake: -------------------------------------------------------------------------------- 1 | ## gflags CMake configuration version file 2 | 3 | # ----------------------------------------------------------------------------- 4 | # library version 5 | set (PACKAGE_VERSION "2.2.2") 6 | 7 | # ----------------------------------------------------------------------------- 8 | # check compatibility 9 | 10 | # Perform compatibility check here using the input CMake variables. 11 | # See example in http://www.cmake.org/Wiki/CMake_2.6_Notes. 12 | 13 | set (PACKAGE_VERSION_COMPATIBLE TRUE) 14 | set (PACKAGE_VERSION_UNSUITABLE FALSE) 15 | 16 | if ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "2" AND 17 | "${PACKAGE_FIND_VERSION_MINOR}" EQUAL "2") 18 | set (PACKAGE_VERSION_EXACT TRUE) 19 | else () 20 | set (PACKAGE_VERSION_EXACT FALSE) 21 | endif () 22 | -------------------------------------------------------------------------------- /exp/os-network/one-sided-throughput/compile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | pushd ../../../os-network/bench \ 3 | && python3 build.py one_sided_read_server \ 4 | && python3 build.py dc_read_client \ 5 | && python3 build.py dc_read_or_client \ 6 | && python3 build.py rc_read_client \ 7 | && python3 build.py rc_read_or_client \ 8 | && popd \ 9 | && cp ../../../os-network/bench/one_sided_read_server_tests.ko . \ 10 | && cp ../../../os-network/bench/dc_read_client_tests.ko . \ 11 | && cp ../../../os-network/bench/dc_read_or_client_tests.ko . \ 12 | && cp ../../../os-network/bench/rc_read_or_client_tests.ko . \ 13 | && cp ../../../os-network/bench/rc_read_client_tests.ko . 14 | -------------------------------------------------------------------------------- /exp/os-network/one-sided-throughput/sync_to_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # this script will sync the project to the remote server 3 | 4 | user="wtx" 5 | target=("val00" "val01" "val02" "val03" "val04" "val05" "val06" "val07" "val08" "val09" "val10" "val11" "val12" "val13" "val14") 6 | 7 | for machine in ${target[*]} 8 | do 9 | rsync -i -rtuv \ 10 | $PWD/*.ko \ 11 | ${user}@${machine}:/home/${user} 12 | done 13 | -------------------------------------------------------------------------------- /exp/os-network/rc-connection/compile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | pushd ../../../os-network/bench \ 3 | && python3 build.py rc_conn_server \ 4 | && python3 build.py rc_conn_client \ 5 | && popd \ 6 | && cp ../../../os-network/bench/rc_conn_server_tests.ko . \ 7 | && cp ../../../os-network/bench/rc_conn_client_tests.ko . 8 | -------------------------------------------------------------------------------- /exp/os-network/rc-connection/dual-nic/run.toml: -------------------------------------------------------------------------------- 1 | global_configs = 'remote_service_id_base=50 nic_count=2 running_secs=30 report_interval=1 thread_count=4 gids="fe80:0000:0000:0000:ec0d:9a03:00ca:2f4c,fe80:0000:0000:0000:ec0d:9a03:0078:6376"' 2 | 3 | [[pass]] 4 | host = 'val01' 5 | path = '' 6 | cmd = 'sudo rmmod rc_conn_server_tests.ko > /dev/null 2>&1; sudo dmesg -c > /dev/null && sudo insmod rc_conn_server_tests.ko nic_count=2 service_id_base=50' 7 | 8 | [[pass]] 9 | host = 'val04' 10 | path = '' 11 | cmd = 'sudo rmmod rc_conn_client_tests.ko > /dev/null 2>&1; sudo dmesg -c > /dev/null && sudo insmod rc_conn_client_tests.ko {} & dmesg -wH' 12 | -------------------------------------------------------------------------------- /exp/os-network/rc-connection/latency/run.toml: -------------------------------------------------------------------------------- 1 | global_configs = 'remote_service_id_base=50 nic_count=1 running_secs=30 report_interval=1 thread_count=1 gids="fe80:0000:0000:0000:ec0d:9a03:00ca:2f4c"' 2 | 3 | [[pass]] 4 | host = 'val01' 5 | path = '' 6 | cmd = 'sudo rmmod rc_conn_server_tests.ko > /dev/null 2>&1; sudo dmesg -c > /dev/null && sudo insmod rc_conn_server_tests.ko nic_count=1 service_id_base=50' 7 | 8 | [[pass]] 9 | host = 'val04' 10 | path = '' 11 | cmd = 'sudo rmmod rc_conn_client_tests.ko > /dev/null 2>&1; sudo dmesg -c > /dev/null && sudo insmod rc_conn_client_tests.ko {} & dmesg -wH' 12 | -------------------------------------------------------------------------------- /exp/os-network/rc-connection/parse_thpt_log.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | 4 | thpt = [] 5 | 6 | def avg(thpt): 7 | sum = 0 8 | for i in thpt: 9 | sum += i 10 | return sum/len(thpt) 11 | 12 | def main(): 13 | with open(sys.argv[1], 'r') as f: 14 | while True: 15 | line = f.readline() 16 | if not line: 17 | break 18 | res = re.search(r'thpt *: (.*)', line) 19 | if res: 20 | thpt.append(float(res.group(1))) 21 | print(avg(thpt)) 22 | 23 | if __name__ == '__main__': 24 | main() 25 | -------------------------------------------------------------------------------- /exp/os-network/rc-connection/sync_to_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # this script will sync the project to the remote server 3 | 4 | user="wtx" 5 | target=("val00" "val01" "val02" "val03" "val04" "val05" "val06" "val07" "val08" "val09" "val10" "val11" "val12" "val13" "val14") 6 | 7 | for machine in ${target[*]} 8 | do 9 | rsync -i -rtuv \ 10 | $PWD/*.ko \ 11 | ${user}@${machine}:/home/${user} 12 | done 13 | -------------------------------------------------------------------------------- /exp/os-network/rc-connection/throughput-thread/run.toml: -------------------------------------------------------------------------------- 1 | global_configs = 'remote_service_id_base=50 nic_count=1 running_secs=30 report_interval=1 thread_count=8 gids="fe80:0000:0000:0000:ec0d:9a03:00ca:2f4c"' 2 | 3 | [[pass]] 4 | host = 'val01' 5 | path = '' 6 | cmd = 'sudo rmmod rc_conn_server_tests.ko > /dev/null 2>&1; sudo dmesg -c > /dev/null && sudo insmod rc_conn_server_tests.ko nic_count=1 service_id_base=50' 7 | 8 | [[pass]] 9 | host = 'val04' 10 | path = '' 11 | cmd = 'sudo rmmod rc_conn_client_tests.ko > /dev/null 2>&1; sudo dmesg -c > /dev/null && sudo insmod rc_conn_client_tests.ko {} & dmesg -wH' 12 | -------------------------------------------------------------------------------- /exp/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/exp/test.jpeg -------------------------------------------------------------------------------- /exp/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/exp/test.mp4 -------------------------------------------------------------------------------- /exp_scripts/.gitignore: -------------------------------------------------------------------------------- 1 | copy*.sh 2 | run*.toml 3 | out* 4 | makefile -------------------------------------------------------------------------------- /exp_scripts/mmcount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pids=$(pgrep -f "simple_child") 3 | 4 | echo Detail Logs Begin: 5 | for pid in $pids 6 | do 7 | echo PID: $pid 8 | sudo cat /proc/$pid/smaps | grep -i rss | awk '{Total+=$2} END {print Total/1024" MB-RSS"}' 9 | sudo cat /proc/$pid/smaps | grep -i pss | awk '{Total+=$2} END {print Total/1024" MB-PSS"}' 10 | echo -n Private_Dirty 11 | sudo cat /proc/$pid/smaps | grep -i Private_Dirty | awk '{Total+=$2} END {print Total/1024" MB"}' 12 | done 13 | 14 | echo Memory Usage Fork End 15 | -------------------------------------------------------------------------------- /exp_scripts/mount_test_tmpfs.sh: -------------------------------------------------------------------------------- 1 | fs_path=./testfs 2 | 3 | mkdir ${fs_path} 4 | 5 | ## mount the tmpfs 6 | sudo mount -t tmpfs tmpfs -o size=4G ${fs_path} ; 7 | 8 | ## generate a test file 9 | head -c 1G ./${fs_path}/test 10 | 11 | 12 | -------------------------------------------------------------------------------- /exp_scripts/requirements.txt: -------------------------------------------------------------------------------- 1 | toml 2 | paramiko 3 | numpy 4 | zerorpc 5 | pandas 6 | chameleon==3.10.1 7 | six==1.10.0 8 | pyaes==1.6.1 9 | Pillow==6.2.2 10 | opencv-python==4.2.0.32 11 | requests==2.27.1 12 | future==0.18.2 13 | torch==1.4.0 14 | torchvision==0.5.0 15 | python-igraph==0.8.0 -------------------------------------------------------------------------------- /exp_scripts/run_lean_container.sh: -------------------------------------------------------------------------------- 1 | exe_path=../exp/bench_lean_container 2 | 3 | bench_sec=8 4 | name=bench_lean_container 5 | rootfs_path=/home/lfm/projects/mos/mitosis-user-libs/mitosis-lean-container/.base/hello/rootfs 6 | 7 | 8 | command="lean_child" 9 | 10 | sudo $exe_path $bench_sec $name $rootfs_path $command 1 73 11 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-exp.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'exp' 7 | cmd = 'cmake . ; make -j' 8 | 9 | #[[template.pass]] 10 | #role = 'builder' 11 | #path = 'exp' 12 | #cmd = 'sudo umount ${tmp_dir} ;mkdir -p ${tmp_dir} ; sudo mount -t tmpfs tmpfs -o size=2G ${tmp_dir} ; cp -r compression* ${tmp_dir}/. ; cp test* ${tmp_dir}/. ; cp *.json ${tmp_dir}/.' 13 | 14 | [template.placeholder] 15 | name = ["build"] 16 | tmp_dir="/tmp-mitosis" 17 | 18 | 19 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-lean-container.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'child' 6 | path = '' 7 | cmd = 'make clean_fs; make export mount_dev LEAN_APP_NAME=simple_child' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | 12 | 13 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-mitosis-cache.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km ; make insmod' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | Kbuild = "Kbuild-mitosis-cache" 12 | 13 | 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-mitosis-cow-profile.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km ; make insmod' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | Kbuild = "Kbuild-mitosis-cow-profile" 12 | 13 | 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-mitosis-cow.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km ; make insmod' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | Kbuild = "Kbuild-mitosis-cow" 12 | 13 | 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-mitosis-eager-resume.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km ; make insmod' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | Kbuild = "Kbuild-mitosis-eager-resume" 12 | 13 | 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-mitosis-prefetch-profile.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km ; make insmod' 8 | order = 0 9 | 10 | [template.placeholder] 11 | name = ["build"] 12 | Kbuild = "Kbuild-mitosis-prefetch-profile" 13 | 14 | 15 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-mitosis-prefetch.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km ; make insmod' 8 | order = 0 9 | 10 | [template.placeholder] 11 | name = ["build"] 12 | Kbuild = "Kbuild-mitosis-prefetch" 13 | 14 | 15 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-mitosis-use-rc.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km ; make insmod' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | Kbuild = "Kbuild-mitosis-use-rc" -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-pause-runner.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'mitosis-user-libs/mitosis-lean-container/lib' 7 | cmd = 'mkdir -p build && cd build && cmake .. && make benchmark_lean_container_pause_w_command' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-clean.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'child' 6 | path = '' 7 | cmd = 'make clean_fs LEAN_APP_NAME=simple_child' 8 | 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'source $HOME/.cargo/env; rm -rf mitosis-kms/target ; make rmmod' 14 | 15 | [[template.pass]] 16 | role = 'parent' 17 | path = '' 18 | cmd = 'source $HOME/.cargo/env; rm -rf mitosis-kms/target ; sleep 10 && make rmmod' 19 | 20 | #[[template.pass]] 21 | #role = 'builder' 22 | #path = '' 23 | #cmd = 'sudo umount ${tmp_dir}' 24 | # 25 | 26 | [template.placeholder] 27 | name = ["build"] 28 | tmp_dir="/tmp-mitosis" 29 | 30 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/execution-peak/empty-fork.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'child' 6 | path = '' 7 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_APP_NAME=simple_child BENCH_SEC=${run_sec} LEAN_BENCH_EXE_PATH=${exe_name} empty_process=1' 8 | order = 0 9 | loop = 16 10 | 11 | [template.placeholder] 12 | exe_name = ["exp/bench_process_fork", "exp/bench_lean_container"] 13 | run_sec = 15 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/execution-peak/peak-c-execution.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = 'exp/' 7 | cmd = "./bench_workingset_exe -run_sec=${run_sec} -working_set=${working_set}" 8 | order=0 9 | loop=16 10 | 11 | [template.placeholder] 12 | working_set = [ 13 | 1048576, 14 | 4194304, 15 | 8388608, 16 | 16777216, 17 | 33554432, 18 | 67108864, 19 | 134217728, 20 | 268435456, 21 | 536870912, 22 | 1073741824, 23 | ] 24 | run_sec=20 -------------------------------------------------------------------------------- /exp_scripts/templates-run/execution-peak/peak-function-execution.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = 'exp/fork-functions' 7 | cmd = 'cd ${micro_func_name} && python function_bench.py -run_sec=${run_sec}' 8 | order=0 9 | loop=16 10 | 11 | [template.placeholder] 12 | micro_func_name = ["json", "chameleon", "compression", "helloworld", "image", "pagerank", "pyaes", "recognition"] 13 | run_sec=30 -------------------------------------------------------------------------------- /exp_scripts/templates-run/execution-peak/peak-nil-rpc.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './bench_nil_rpc -mac_id=0 -gid=${parent_gid} -nic_id=0 -threads=${thread_num} -run_sec=${run_sec} ' 20 | order = 1 21 | 22 | [template.placeholder] 23 | name = ["nil_rpc"] 24 | micro_func_name = "micro" 25 | run_sec = 30 26 | thread_num = 12 -------------------------------------------------------------------------------- /exp_scripts/templates-run/loadspike/template-run-mitosis-startup.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | # insmod for parent and children 5 | [[template.pass]] 6 | role = 'parent' 7 | path = '' 8 | cmd = 'make insmod ID=0' 9 | order = 0 10 | 11 | [[template.pass]] 12 | role = 'child' 13 | path = '' 14 | cmd = 'make insmod ID=${@incr}' 15 | order = 0 16 | 17 | # for children to connect 18 | [[template.pass]] 19 | role = 'child' 20 | path = 'exp' 21 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 22 | order = 1 23 | 24 | # here is the prepare part 25 | [[template.pass]] 26 | role = 'parent' 27 | path = 'exp/fork-functions' 28 | cmd = 'cd ${micro_func_name} && python function.py' 29 | order = 2 30 | 31 | # for parent, here we should do nothing? Because we just need another lb to send rpc requests 32 | # just wait here 33 | [[template.pass]] 34 | role = 'parent' 35 | path = 'exp' 36 | cmd = 'sleep 800' 37 | order= 3 38 | 39 | [[template.pass]] 40 | role = 'child' 41 | path = '' 42 | cmd = 'TBD: run client w/ rpc worker' 43 | order = 3 44 | 45 | # maybe we can add a more lb role to run load spike 46 | 47 | [template.placeholder] 48 | micro_func_name = ["image"] 49 | parent_gid = "TBD" 50 | # loop_cmd = "./simple_child -mac_id=0" 51 | #loop_cmd="echo 3 | sudo tee /proc/sys/vm/drop_caches;./simple_child -mac_id=0" 52 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/many-to-one-c/template-lean-container.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp' ## c-version 25 | cmd = './bench_workingset --working_set=${working_set} -random=0 --whether_prepare=1 -exclude_execution=0 -profile=0' 26 | order = 2 27 | 28 | 29 | [[template.pass]] 30 | role = 'child' 31 | path = '' 32 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_BENCH_EXE_PATH=${exe_name} LEAN_APP_NAME=simple_child BENCH_SEC=${run_sec}' 33 | order = 3 34 | loop = 16 35 | 36 | [template.placeholder] 37 | working_set = [ 38 | 1048576, 39 | # 4194304, 40 | # 8388608, 41 | # 16777216, 42 | # 33554432, 43 | # 67108864, 44 | # 134217728, 45 | # 268435456, 46 | # 536870912, 47 | # 1073741824, 48 | ] 49 | exe_name = "exp/bench_lean_container" 50 | run_sec = 60 -------------------------------------------------------------------------------- /exp_scripts/templates-run/many-to-one-c/template-touch-ratio.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp' ## c-version 25 | cmd = "./bench_workingset --working_set=${working_set} -random=0 -profile=0 -whether_prepare=1 -exclude_execution=0 -touch_ratio=${touch_ratio}" 26 | order = 2 27 | 28 | 29 | [[template.pass]] 30 | role = 'child' 31 | path = '' 32 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_BENCH_EXE_PATH=${exe_name} LEAN_APP_NAME=simple_child BENCH_SEC=${run_sec}' 33 | order = 3 34 | loop = 16 35 | 36 | [template.placeholder] 37 | working_set = 67108864 38 | touch_ratio = [100] 39 | #touch_ratio = [0, 20, 40, 50, 55, 60, 65, 70, 80, 85, 90, 95, 100] 40 | exe_name = "exp/bench_lean_container" 41 | run_sec = 30 -------------------------------------------------------------------------------- /exp_scripts/templates-run/many-to-one-func/template-lean-container.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'sleep 5 && make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = 'sleep 10 && ./connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp/fork-functions' 25 | cmd = 'sleep 10 && cd ${micro_func_name} && python function.py -exclude_execution=0 -pin=1 -profile=0 -handler_id=73' 26 | order = 2 27 | 28 | 29 | [[template.pass]] 30 | role = 'child' 31 | path = '' 32 | cmd = 'sleep 10 && make bench_lean_mitosis mac_id=0 LEAN_BENCH_EXE_PATH=${exe_name} LEAN_APP_NAME=simple_child BENCH_SEC=${run_sec}' 33 | #path = 'exp' 34 | #cmd = './simple_child' 35 | order = 3 36 | loop = 24 37 | 38 | [template.placeholder] 39 | micro_func_name = [ 40 | "micro", 41 | "json", 42 | "chameleon", 43 | "compression", 44 | "helloworld", 45 | "image", 46 | "pagerank", 47 | "pyaes", 48 | "recognition" 49 | ] 50 | exe_name = "exp/bench_lean_container" 51 | run_sec = 30 52 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-c/template-run-micro-execution.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'parent' 12 | path = 'exp' ## c-version 13 | cmd = './bench_workingset --working_set=${working_set} --whether_prepare=1 -exclude_execution=0' 14 | order = 1 15 | 16 | [[template.pass]] 17 | role = 'parent' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp' 25 | cmd = './simple_child -mac_id=0 -wait_finish_sec=0; for i in seq 1 ${time} ;do ./simple_child -mac_id=0 ;done; for i in seq 1 ${time} ;do ./simple_child -mac_id=0 ;done' 26 | order = 2 27 | 28 | [template.placeholder] 29 | working_set = [ 30 | 1048576, 31 | 4194304, 32 | 8388608, 33 | 16777216, 34 | 33554432, 35 | 67108864, 36 | 134217728, 37 | 268435456, 38 | 536870912, 39 | 1073741824, 40 | ] 41 | micro_func_name = "micro" 42 | time = 1 43 | 44 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-c/template-run-micro-prepare.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod' 8 | order = 0 9 | 10 | 11 | [[template.pass]] 12 | role = 'parent' 13 | path='exp' ## c-version 14 | cmd = 'for i in seq 1 3; do for i in seq 1 3 ;do ./bench_workingset --working_set=${working_set} -exclude_execution=0 --whether_prepare=1;cd ../;make insmod;cd exp ;done; done' 15 | order = 1 16 | 17 | [template.placeholder] 18 | working_set = [ 19 | 1048576, 20 | 4194304, 21 | 8388608, 22 | 16777216, 23 | 33554432, 24 | 67108864, 25 | 134217728, 26 | 268435456, 27 | 536870912, 28 | 1073741824, 29 | ] 30 | micro_func_name = "micro" 31 | 32 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-c/template-run-micro-startup-execution.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp/fork-functions' 25 | #cmd = 'sleep 1 && ./bench_workingset --working_set=${working_set} --whether_prepare=1 -exclude_execution=1 --profile=0 --touch_ratio=${touch_ratio}' 26 | cmd = 'cd ${micro_func_name} && python function.py -working_set=${working_set} -pin=1 -profile=0 -handler_id=73 -exclude_execution=0' 27 | order = 2 28 | 29 | [[template.pass]] 30 | role = 'child' 31 | path = '' 32 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_APP_NAME=simple_child' 33 | order = 3 34 | 35 | [template.placeholder] 36 | working_set = [1048576, 37 | 4194304, 38 | 8388608, 39 | 16777216, 40 | 33554432, 41 | 67108864, 42 | 134217728, 43 | 268435456, 44 | 536870912, 45 | 1073741824, 46 | ] 47 | micro_func_name = "micro" 48 | touch_ratio=100 49 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-c/template-run-micro-startup.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp/fork-functions' 25 | #cmd = 'sleep 1 && ./bench_workingset --working_set=${working_set} --whether_prepare=1 -exclude_execution=1 --profile=0 --touch_ratio=${touch_ratio}' 26 | cmd = 'cd ${micro_func_name} && python function.py -working_set=${working_set} -pin=1 -profile=0 -handler_id=73 -exclude_execution=1' 27 | order = 2 28 | 29 | [[template.pass]] 30 | role = 'child' 31 | path = '' 32 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_APP_NAME=simple_child' 33 | order = 3 34 | 35 | [template.placeholder] 36 | working_set = [1048576, 37 | 4194304, 38 | 8388608, 39 | 16777216, 40 | 33554432, 41 | 67108864, 42 | 134217728, 43 | 268435456, 44 | 536870912, 45 | 1073741824, 46 | ] 47 | micro_func_name = "micro" 48 | touch_ratio=100 49 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-c/template-run-micro-touch-ratio.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = 'sleep 1 && ./connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp' 25 | cmd = "./bench_workingset --working_set=${working_set} -profile=0 -whether_prepare=1 -exclude_execution=0 -touch_ratio=${touch_ratio}" 26 | order = 2 27 | 28 | [[template.pass]] 29 | role = 'child' 30 | path = '' 31 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_APP_NAME=simple_child' 32 | order = 3 33 | 34 | [template.placeholder] 35 | #touch_ratio = [85, 90, 95] 36 | touch_ratio = [0, 20, 40, 50, 55, 60, 65, 70, 80, 85, 90, 95, 100] 37 | working_set = 67108864 38 | micro_func_name = "micro" 39 | 40 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-execution-hanged-cache.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'parent' 18 | path = 'exp/fork-functions' 19 | cmd = 'cd ${micro_func_name} && python function.py -exclude_execution=0 -handler_id=73 -pin=1 -hang=1 -profile=1 -app_name="${micro_func_name}" ' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'child' 24 | path = 'exp' 25 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0; sleep 5' 26 | order = 2 27 | 28 | [[template.pass]] 29 | role = 'child' 30 | path = 'exp' 31 | cmd = './simple_child -mac_id=0; sleep 5; free -m; ./simple_child -mac_id=0' 32 | order=3 33 | 34 | [[template.pass]] 35 | role = 'child' 36 | path = 'exp_scripts' 37 | cmd = 'sleep 25; free -m;' 38 | order=3 39 | 40 | [template.placeholder] 41 | micro_func_name = ["json", "chameleon", "compression", "helloworld", "image", "pagerank", "pyaes", "recognition"] 42 | #loop_cmd="echo 3 | sudo tee /proc/sys/vm/drop_caches;./simple_child -mac_id=0" 43 | 44 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-execution-hanged.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'parent' 18 | path = 'exp/fork-functions' 19 | cmd = 'cd ${micro_func_name} && python function.py -exclude_execution=0 -handler_id=73 -pin=1 -hang=1 -profile=1 -app_name="${micro_func_name}" ' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'child' 24 | path = 'exp' 25 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0;' 26 | order = 2 27 | 28 | [[template.pass]] 29 | role = 'child' 30 | path = 'exp' 31 | cmd = 'free -m; ./simple_child -mac_id=0' 32 | order=3 33 | 34 | [[template.pass]] 35 | role = 'child' 36 | path = 'exp_scripts' 37 | cmd = 'sleep 2; free -m;' 38 | order=3 39 | 40 | [template.placeholder] 41 | micro_func_name = ["json", "chameleon", "compression", "helloworld", "image", "pagerank", "pyaes", "recognition"] 42 | # micro_func_name = ["recognition"] 43 | #loop_cmd="echo 3 | sudo tee /proc/sys/vm/drop_caches;./simple_child -mac_id=0" 44 | 45 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-execution.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'parent' 12 | path = 'exp/fork-functions' 13 | cmd = 'cd ${micro_func_name} && python function.py -exclude_execution=0 -handler_id=73 -pin=1 -profile=1 -app_name="${micro_func_name}" ' 14 | order = 1 15 | 16 | [[template.pass]] 17 | role = 'parent' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp' 25 | cmd = 'for i in seq 1 3; do for i in seq 1 3 ;do ${loop_cmd} ;done; done' 26 | order=2 27 | 28 | [template.placeholder] 29 | micro_func_name = ["micro", "json", "chameleon", "compression", "helloworld", "image", "pagerank", "pyaes", "recognition"] 30 | loop_cmd = "./simple_child -mac_id=0" 31 | #loop_cmd="echo 3 | sudo tee /proc/sys/vm/drop_caches;./simple_child -mac_id=0" 32 | 33 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-prepare.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'parent' 12 | path = 'exp/fork-functions' 13 | cmd = 'for i in seq 1 3; do for i in seq 1 3 ;do cd ${micro_func_name} && python function.py -exclude_execution=0 -handler_id=73 -pin=1 -profile=1 -app_name="${micro_func_name}";cd ../../../;make insmod;cd exp/fork-functions ;done; done' 14 | order = 1 15 | 16 | [template.placeholder] 17 | micro_func_name = ["micro", "json", "chameleon", "compression", "helloworld", "image", "pagerank", "pyaes", "recognition"] 18 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-startup-execution.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp/fork-functions' 25 | cmd = 'cd ${micro_func_name} && python function.py -exclude_execution=0 -pin=1 -profile=0 -handler_id=73' 26 | order= 2 27 | 28 | [[template.pass]] 29 | role = 'child' 30 | path = '' 31 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_APP_NAME=simple_child BENCH_SEC=${run_sec}' 32 | order=3 33 | 34 | [template.placeholder] 35 | micro_func_name = [ 36 | "micro", 37 | "json", 38 | "chameleon", 39 | "compression", 40 | "helloworld", 41 | "image", 42 | "pagerank", 43 | "pyaes", 44 | "recognition" 45 | ] 46 | run_sec=8 -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-startup.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp/fork-functions' 25 | cmd = 'cd ${micro_func_name} && python function.py -exclude_execution=1 -pin=1 -profile=0 -handler_id=73' 26 | order =2 27 | 28 | [[template.pass]] 29 | role = 'child' 30 | path = '' 31 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_APP_NAME=simple_child' 32 | order=3 33 | 34 | [template.placeholder] 35 | micro_func_name = [ 36 | "micro", 37 | "json", 38 | "chameleon", 39 | "compression", 40 | "helloworld", 41 | "image", 42 | "pagerank", 43 | "pyaes", 44 | "recognition" 45 | ] 46 | 47 | 48 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-with-trigger-local-fork.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'parent' 12 | path = 'exp/fork-functions' 13 | cmd = 'cd ${micro_func_name} && python function_local_fork.py ' 14 | order = 1 15 | loop = 1 16 | 17 | # 18 | #[[template.pass]] 19 | #role = 'parent' 20 | #path = 'exp/fork-functions/finra' 21 | #cmd = "python trigger_local_fork.py -process=1" 22 | #order = 2 23 | #loop = 1 24 | 25 | 26 | [template.placeholder] 27 | micro_func_name = ["finra"] 28 | 29 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/micro-func/template-run-micro-with-trigger.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'echo 3 | sudo tee /proc/sys/vm/drop_caches; make insmod ID=${@incr}' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'exp/fork-functions' 25 | cmd = 'cd ${micro_func_name} && python function.py -exclude_execution=0 -handler_id=73 -pin=1 -profile=0 -app_name="${micro_func_name}" ' 26 | order = 2 27 | 28 | [[template.pass]] 29 | role = 'child' 30 | path = 'exp' 31 | cmd = "./simple_child_socket -mac_id=0" 32 | #cmd = "python fork-functions/finra/child_function_wrapper.py -master_host=${parent_host} -command='./simple_child -mac_id=0' " 33 | order = 2 34 | loop = 1 35 | 36 | # 37 | [[template.pass]] 38 | role = 'parent' 39 | path = 'exp/fork-functions/finra' 40 | cmd = "python trigger.py -child_hosts='${child_hosts}' -parent_host=${parent_host} -process=1" 41 | order = 3 42 | loop = 1 43 | 44 | 45 | [template.placeholder] 46 | micro_func_name = ["finra"] 47 | 48 | -------------------------------------------------------------------------------- /loop_runner.sh: -------------------------------------------------------------------------------- 1 | # 2 | # /bin/bash 3 | 4 | for i in $(seq "$1"); do $2; done 5 | 6 | wait 7 | echo 'end of loop runner' -------------------------------------------------------------------------------- /mitosis-kms/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow use_rc" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow prefetch" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis-cache: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow page-cache" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis-cow: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis-cow-profile: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow resume-profile" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis-eager-resume: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow prefetch eager-resume" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis-prefetch: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow prefetch" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis-prefetch-profile: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow prefetch resume-profile" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< 18 | -------------------------------------------------------------------------------- /mitosis-kms/Kbuild-mitosis-use-rc: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "mitosis krdma-test cow use_rc" --no-default-features 12 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) doc --quiet -Z build-std=core,alloc --target=$(TARGET) 13 | 14 | .PHONY: cargo_will_determine_dependencies 15 | 16 | %.rust.o: target/$(TARGET)/debug/lib%.a 17 | $(LD) -r -o $@ --whole-archive $< -------------------------------------------------------------------------------- /mitosis-kms/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | BASE_DIR = os.path.realpath(os.path.dirname(__file__)) 8 | 9 | def run(*args, **kwargs): 10 | cwd = kwargs.pop("cwd", None) 11 | environ = kwargs.pop("environ", os.environ) 12 | assert not kwargs 13 | 14 | print("+ [RUNNING] {}".format(list(args))) 15 | subprocess.check_call(list(args), cwd=cwd, env=environ) 16 | 17 | 18 | def main(argv): 19 | for path in argv[1:] or os.listdir(BASE_DIR): 20 | if ( 21 | not os.path.isdir(os.path.join(BASE_DIR, path)) or 22 | not os.path.exists(os.path.join(BASE_DIR, path, "tests")) 23 | ): 24 | continue 25 | 26 | print("+ [{}]".format(path)) 27 | 28 | run( 29 | "make", "-C", BASE_DIR, 30 | "TEST_NAME={}".format(path.replace("-", "_")), 31 | "TEST_PATH={}".format(path), 32 | ) 33 | 34 | 35 | if __name__ == "__main__": 36 | main(sys.argv) 37 | -------------------------------------------------------------------------------- /mitosis-kms/fork/src/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define DEFAULT_PERMISSION S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH 4 | 5 | long mac_id = 0; 6 | module_param(mac_id, long, DEFAULT_PERMISSION); 7 | -------------------------------------------------------------------------------- /mitosis-kms/fork/src/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /mitosis-kms/fork/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | use mitosis_rust_client::*; 3 | 4 | #[test] 5 | fn test_basic() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | let mut client = MClientOptions::new() 9 | .set_device_name(DEFAULT_SYSCALL_PATH.to_string()) 10 | .open() 11 | .unwrap(); 12 | 13 | client.test(0).unwrap(); // basic 14 | 15 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 16 | }); 17 | } -------------------------------------------------------------------------------- /mitosis-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mitosis-macros" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | quote = "1.0" 10 | syn = { version = "1.0.56", features = ["full"] } 11 | proc-macro2 = "1.0.36" 12 | 13 | [lib] 14 | proc-macro = true 15 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/global_variables/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "global_variables_tests" 5 | version = "0.1.0" 6 | authors = ["xmm , wtx "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path="../../../mitosis", optional = true} 20 | mitosis-macros = {path = "../../../mitosis-macros"} 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | 37 | [build-dependencies] 38 | bindgen = "0.54" 39 | cc = "1.0" 40 | shlex = "0.1" 41 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/global_variables/src/.lib.rs.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-macros/unitests/global_variables/src/.lib.rs.swp -------------------------------------------------------------------------------- /mitosis-macros/unitests/global_variables/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use krdma_test::krdma_main; 6 | use mitosis_macros::declare_global; 7 | 8 | use mitosis::linux_kernel_module; 9 | use mitosis::log; 10 | 11 | declare_global!(test_var,u64); 12 | 13 | #[krdma_main] 14 | fn main() { 15 | log::info!("in test global variables"); 16 | unsafe { crate::test_var::init(73) }; 17 | log::info!("test the global variables TEST {}", unsafe { *crate::test_var::get_ref()}); 18 | unsafe { *crate::test_var::get_mut() = 12 }; 19 | log::info!("test the global variables again: TEST {}", unsafe { *crate::test_var::get_ref()}); 20 | } 21 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/global_variables/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_global() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/kernel_module_param/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "kernel_module_param_tests" 5 | version = "0.1.0" 6 | authors = ["xmm , wtx "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path="../../../mitosis", optional = true} 20 | mitosis-macros = {path = "../../../mitosis-macros"} 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | 37 | [build-dependencies] 38 | bindgen = "0.54" 39 | cc = "1.0" 40 | shlex = "0.1" 41 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/kernel_module_param/src/config.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-macros/unitests/kernel_module_param/src/config.rs -------------------------------------------------------------------------------- /mitosis-macros/unitests/kernel_module_param/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use krdma_test::krdma_main; 6 | use mitosis_macros::declare_module_param; 7 | 8 | declare_module_param!(sample_long, u64); 9 | declare_module_param!(sample_int, u32); 10 | declare_module_param!(sample_str, *mut u8); 11 | 12 | use mitosis::linux_kernel_module; 13 | use mitosis::log; 14 | 15 | #[krdma_main] 16 | fn ctx_init() { 17 | log::info!("context init"); 18 | log::info!("sample_int: {}", sample_int::read()); 19 | log::info!("sample_long: {}", sample_long::read()); 20 | log::info!("sample_str: 0x{:x}", sample_str::read() as u64); 21 | log::info!("first charactor in str: {}", unsafe { *sample_str::read() as char }); 22 | } 23 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/kernel_module_param/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | long sample_long = 2; 7 | module_param(sample_long, long, DEFAULT_PERMISSION); 8 | 9 | int sample_int = 3; 10 | module_param(sample_int, int, DEFAULT_PERMISSION); 11 | 12 | char sample_arr[BUF_LENGTH] = {'I', 'P', 'A', 'D', 'S', '\0'}; 13 | char* sample_str = sample_arr; 14 | module_param_string(sample_str, sample_arr, BUF_LENGTH, DEFAULT_PERMISSION); 15 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/kernel_module_param/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /mitosis-macros/unitests/kernel_module_param/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_params() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("error")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /mitosis-user-libs/README.md: -------------------------------------------------------------------------------- 1 | # User-space libraries of MITOSIS 2 | 3 | The user-space libraries includes wrappers to `ioctrol`-based system calls, 4 | and user-space lean containers. 5 | Though in principle should implement the lean containers in the kernel, 6 | a user-space implementation is simpler, with some little costs for additional `fork`. 7 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-c-client/include/common.h: -------------------------------------------------------------------------------- 1 | //#include 2 | 3 | enum LibMITOSISCmd { 4 | Nil = 0, // for test only 5 | Connect = 3, // connect to remote session 6 | Prepare = 4, // prepare the memory mapping of this process 7 | ResumeLocal = 5, // resume to another process 8 | ResumeRemote = 6, // resume to another process of remote via RPC 9 | PreparePing = 7, // Prepare the memory mapping of this process (and ping it in kernel) 10 | NilRPC = 8, // Call the nil RPC function 11 | }; 12 | 13 | typedef struct { 14 | unsigned int machine_id; // should not be zero! 15 | unsigned int nic_id; // nic idx according to gid 16 | const char *gid; 17 | } connect_req_t; 18 | 19 | typedef struct { 20 | unsigned int machine_id; // keep `machine_id` the same as that in `connect_req_t` 21 | unsigned int handler_id; 22 | } resume_remote_req_t; -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/.gitignore: -------------------------------------------------------------------------------- 1 | .base/ 2 | scripts -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE_NAME=hello 2 | PATH_TO_APP=app/hello/ 3 | 4 | ROOTFS_DIR=.base/hello/rootfs 5 | ROOTFS_ABS_PATH=${PWD}/${ROOTFS_DIR} 6 | 7 | DEVICE=/dev/mitosis-syscalls 8 | 9 | export: 10 | sudo python3 make_app_rootfs.py --app ${PATH_TO_APP} --name ${IMAGE_NAME} --export ${ROOTFS_DIR} 11 | 12 | 13 | mount_dev: 14 | sudo python3 mount_device.py --rootfs ${ROOTFS_DIR} --device ${DEVICE} 15 | 16 | unmount_dev: 17 | sudo python3 mount_device.py --rootfs ${ROOTFS_DIR} --device ${DEVICE} --unmount 18 | 19 | 20 | clean_fs: unmount_dev 21 | sudo rm -r ${ROOTFS_DIR} 22 | 23 | CONTAINER_NAME=my_test_container 24 | 25 | COMMAND_ABS_PATH=/usr/local/bin/python 26 | ARGS1=main.py 27 | ARGS2= 28 | 29 | run: 30 | sudo ./lib/build/start_lean_container ${CONTAINER_NAME} ${ROOTFS_ABS_PATH} ${COMMAND_ABS_PATH} ${ARGS1} ${ARGS2} 31 | 32 | child: 33 | sudo ./lib/build/start_lean_container ${CONTAINER_NAME} ${ROOTFS_ABS_PATH} ${COMMAND_ABS_PATH} ${ARGS1} ${ARGS2} 34 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/compression/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8 2 | COPY . ./ 3 | 4 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 5 | 6 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/compression/function.py: -------------------------------------------------------------------------------- 1 | import shutil 2 | 3 | time = 0 4 | 5 | 6 | def lambda_handler(): 7 | global time 8 | dst = 'result-' + str(time) 9 | src = 'compression-' + str(time) 10 | shutil.make_archive(dst, 'zip', src) 11 | time += 1 12 | 13 | 14 | if __name__ == '__main__': 15 | lambda_handler() 16 | lambda_handler() 17 | lambda_handler() 18 | 19 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/compression/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-user-libs/mitosis-lean-container/app/compression/requirements.txt -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/criu-base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | RUN sed -i s/archive.ubuntu.com/mirror.sjtu.edu.cn/g /etc/apt/sources.list && \ 4 | sed -i s/security.ubuntu.com/mirror.sjtu.edu.cn/g /etc/apt/sources.list 5 | 6 | RUN chmod 777 /tmp 7 | 8 | RUN apt update && apt install -y libcap-dev libnl-3-dev libnet1-dev pkg-config libbsd-dev flex bison libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python-protobuf build-essential git libmount-dev 9 | 10 | RUN rm -rf /var/lib/apt/lists/* 11 | 12 | RUN GIT_SSL_NO_VERIFY=1 git clone --branch no_error_for_restore https://criu:oDqEoN-nC65FpiYKyC4w@ipads.se.sjtu.edu.cn:1312/distributed-rdma-serverless/mitosis-project/criu.git 13 | 14 | RUN cd criu && rm images/google/protobuf/descriptor.proto && ln -s /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto && make -j $(nproc) 15 | 16 | RUN apt update && apt install -y python3 wget && wget https://bootstrap.pypa.io/pip/3.5/get-pip.py && python3 get-pip.py && rm -rf /var/lib/apt/lists/* 17 | 18 | RUN apt update && apt install -y bc && rm -rf /var/lib/apt/lists/* 19 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/criu/.gitignore: -------------------------------------------------------------------------------- 1 | imgs/ 2 | lock 3 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/criu/copy_env.sh: -------------------------------------------------------------------------------- 1 | if [ "$#" -ne 1 ]; then 2 | echo "Usage: $0 rootfs_path" 3 | exit 1 4 | fi 5 | 6 | # copy images to the rootfs 7 | rm -rf $1/imgs 8 | cp -r imgs $1/imgs 9 | 10 | # make directory for the lock file and copy to specific location 11 | rm -rf $1/${PWD} 12 | mkdir -p -m775 $1/${PWD} 13 | cp -r benchmark.py $1/${PWD}/ 14 | cp -r lock $1/${PWD}/ && echo -n 1 > $1/${PWD}/lock 15 | 16 | # copy share libraries 17 | cp -r /usr/bin/python3.5 $1/usr/bin/python3.5 18 | cp -r /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so $1/usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so 19 | cp -r /usr/lib/python3.5/lib-dynload/mmap.cpython-35m-x86_64-linux-gnu.so $1/usr/lib/python3.5/lib-dynload/mmap.cpython-35m-x86_64-linux-gnu.so 20 | cp -r /usr/lib/locale/locale-archive $1/usr/lib/locale/locale-archive 21 | cp -r /lib/x86_64-linux-gnu/* $1/lib/x86_64-linux-gnu 22 | 23 | # copy restore scripts 24 | cp restore.sh $1/restore.sh 25 | 26 | # chmod 27 | sudo chmod 666 $1/dev/null 28 | sudo chmod 755 $1 29 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/criu/host_dump.sh: -------------------------------------------------------------------------------- 1 | echo -n 0 > lock 2 | setsid python3 benchmark.py -run_sec 10 -lock_string 0 -working_set 16777216 -lock_file lock -lock_string 0 < /dev/null > /dev/null 2>&1 & 3 | export TARGET_PID=$(pgrep python3) 4 | echo "TARGET_PID=${TARGET_PID}" 5 | rm -rf imgs && mkdir imgs 6 | LD_LIBRARY_PATH=/home/wtx/criu/.deps-install/lib /home/wtx/criu/criu-3.15/criu/criu dump --images-dir=./imgs -t ${TARGET_PID} -vvvv -o dump.log 7 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/criu/restore.sh: -------------------------------------------------------------------------------- 1 | echo "restore!" 2 | /criu/criu/criu restore --images-dir=./imgs -vvvv -o restore.log 3 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/hello/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8 2 | 3 | COPY requirements.txt . 4 | 5 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 6 | 7 | COPY *.py . 8 | COPY hello.py main.py 9 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/hello/hello.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def main(): 4 | print("hello from python: pid: %d ppid: %d" % (os.getpid(), os.getppid())) 5 | 6 | if __name__ == '__main__': 7 | main() 8 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/hello/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-user-libs/mitosis-lean-container/app/hello/requirements.txt -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/chameleon/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY requirements.txt . 4 | 5 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 6 | 7 | COPY function.py main.py 8 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/chameleon/requirements.txt: -------------------------------------------------------------------------------- 1 | chameleon 2 | six 3 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/compression/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY requirements.txt . 4 | 5 | COPY compression /compression 6 | 7 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 8 | 9 | COPY function.py main.py 10 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/compression/function.py: -------------------------------------------------------------------------------- 1 | import os 2 | import socket 3 | 4 | server_addr = 'uds.socket' 5 | socket_family = socket.AF_UNIX 6 | socket_type = socket.SOCK_STREAM 7 | 8 | import shutil 9 | import gzip 10 | 11 | try: 12 | os.remove(server_addr) 13 | except: 14 | pass 15 | 16 | my_socket = socket.socket(socket_family, socket_type) 17 | my_socket.bind(server_addr) 18 | my_socket.listen(1) 19 | 20 | connection, client_address = my_socket.accept() 21 | 22 | def handler(): 23 | dst = 'result' 24 | src = 'compression' 25 | shutil.make_archive(dst, 'zip', src) 26 | 27 | while True: 28 | connection.recv(1) 29 | handler() 30 | connection.sendall('\0') 31 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/compression/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-user-libs/mitosis-lean-container/app/pause-bench/compression/requirements.txt -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/helloworld/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY hello.py main.py 4 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/helloworld/hello.py: -------------------------------------------------------------------------------- 1 | import os 2 | import socket 3 | 4 | server_addr = 'uds.socket' 5 | socket_family = socket.AF_UNIX 6 | socket_type = socket.SOCK_STREAM 7 | 8 | try: 9 | os.remove(server_addr) 10 | except: 11 | pass 12 | 13 | my_socket = socket.socket(socket_family, socket_type) 14 | my_socket.bind(server_addr) 15 | my_socket.listen(1) 16 | 17 | connection, client_address = my_socket.accept() 18 | 19 | def handler(): 20 | s = 'hello world' 21 | s.find('d') 22 | 23 | while True: 24 | connection.recv(1) 25 | handler() 26 | connection.sendall('\0') 27 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/image/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY requirements.txt . 4 | 5 | COPY test.jpeg . 6 | 7 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 8 | 9 | COPY function.py main.py 10 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/image/requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow 2 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/image/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-user-libs/mitosis-lean-container/app/pause-bench/image/test.jpeg -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/json/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY linux.json linux.json 4 | 5 | COPY function.py main.py 6 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/json/function.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import socket 4 | 5 | server_addr = 'uds.socket' 6 | socket_family = socket.AF_UNIX 7 | socket_type = socket.SOCK_STREAM 8 | 9 | try: 10 | os.remove(server_addr) 11 | except: 12 | pass 13 | 14 | my_socket = socket.socket(socket_family, socket_type) 15 | my_socket.bind(server_addr) 16 | my_socket.listen(1) 17 | 18 | connection, client_address = my_socket.accept() 19 | 20 | f = open('linux.json') 21 | content = f.read() 22 | 23 | def handler(): 24 | json_data = json.loads(content) 25 | str_json = json.dumps(json_data, indent=4) 26 | 27 | while True: 28 | connection.recv(1) 29 | handler() 30 | connection.sendall('\0') 31 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/pagerank/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY requirements.txt . 4 | 5 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 6 | 7 | COPY function.py main.py 8 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/pagerank/function.py: -------------------------------------------------------------------------------- 1 | import igraph 2 | import os 3 | import sys 4 | import socket 5 | 6 | server_addr = 'uds.socket' 7 | socket_family = socket.AF_UNIX 8 | socket_type = socket.SOCK_STREAM 9 | 10 | size = 100000 11 | 12 | graph = igraph.Graph.Barabasi(size, 10) 13 | 14 | def generate(length): 15 | letters = string.ascii_lowercase + string.digits 16 | return ''.join(random.choice(letters) for i in range(length)) 17 | 18 | try: 19 | os.remove(server_addr) 20 | except: 21 | pass 22 | 23 | my_socket = socket.socket(socket_family, socket_type) 24 | my_socket.bind(server_addr) 25 | my_socket.listen(1) 26 | 27 | connection, client_address = my_socket.accept() 28 | 29 | def handler(): 30 | """ 31 | "{\"size\":\"100000\"}" 32 | 33 | :return: 34 | """ 35 | result = graph.pagerank() 36 | 37 | while True: 38 | connection.recv(1) 39 | handler() 40 | connection.sendall('\0') 41 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/pagerank/requirements.txt: -------------------------------------------------------------------------------- 1 | python-igraph==0.8.0 2 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/pyaes/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY requirements.txt . 4 | 5 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 6 | 7 | COPY function.py main.py 8 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/pyaes/requirements.txt: -------------------------------------------------------------------------------- 1 | pyaes 2 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/recognition/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | 3 | COPY requirements.txt . 4 | 5 | COPY test.jpg . 6 | 7 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 8 | 9 | COPY function.py main.py 10 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/recognition/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | chameleon 3 | six 4 | pyaes 5 | Pillow 6 | opencv-python==4.2.0.32 7 | requests 8 | future 9 | torch 10 | torchvision 11 | python-igraph==0.8.0 12 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/pause-bench/recognition/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-user-libs/mitosis-lean-container/app/pause-bench/recognition/test.jpg -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/simple_child/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8 2 | 3 | COPY . ./ 4 | RUN pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple 5 | RUN g++ lean_child.cc -o lean_child 6 | RUN g++ nil_rpc.cc -o nil_rpc 7 | 8 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/simple_child/common.h: -------------------------------------------------------------------------------- 1 | //#include 2 | 3 | enum LibMITOSISCmd { 4 | Nil = 0, // for test only 5 | Connect = 3, // connect to remote session 6 | Prepare = 4, // prepare the memory mapping of this process 7 | ResumeLocal = 5, // resume to another process 8 | ResumeRemote = 6, // resume to another process of remote via RPC 9 | PreparePing = 7, // Prepare the memory mapping of this process (and ping it in kernel) 10 | NilRPC = 8, // Call the nil RPC function 11 | }; 12 | 13 | typedef struct { 14 | unsigned int machine_id; // should not be zero! 15 | unsigned int nic_id; // nic idx according to gid 16 | const char *gid; 17 | } connect_req_t; 18 | 19 | typedef struct { 20 | unsigned int machine_id; // keep `machine_id` the same as that in `connect_req_t` 21 | unsigned int handler_id; 22 | } resume_remote_req_t; -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/simple_child/lean_child.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int 6 | main(int argc, char *argv[]) { 7 | if (argc < 3) { 8 | printf("Wrong argc: %d. Usage: %s [mac_id] [handler_id]\n", argc, argv[0]); 9 | return -1; 10 | } 11 | 12 | int mac_id = std::stoi(argv[1]); 13 | int handler_id = std::stoi(argv[2]); 14 | int sd = sopen(); 15 | assert(sd != 0); 16 | fork_resume_remote(sd, mac_id, handler_id); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/simple_child/nil_rpc.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int 6 | main(int argc, char *argv[]) { 7 | if (argc < 3) { 8 | printf("Wrong argc: %d. Usage: %s [mac_id] [handler_id]\n", argc, argv[0]); 9 | return -1; 10 | } 11 | 12 | int mac_id = std::stoi(argv[1]); 13 | int handler_id = std::stoi(argv[2]); 14 | int sd = sopen(); 15 | assert(sd != 0); 16 | fork_resume_remote(sd, mac_id, handler_id); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/simple_child/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy==1.17.3 2 | chameleon==3.10.1 3 | six==1.10.0 4 | pyaes==1.6.1 5 | Pillow==6.2.2 6 | opencv-python==4.2.0.32 7 | requests==2.27.1 8 | future==0.18.2 9 | torch==1.4.0 10 | torchvision==0.5.0 11 | python-igraph==0.8.0 12 | agileutil 13 | pandas -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/simple_child/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-user-libs/mitosis-lean-container/app/simple_child/test.jpeg -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/app/simple_child/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/mitosis-user-libs/mitosis-lean-container/app/simple_child/test.mp4 -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | include(tests/tests.cmake) 4 | include(benchmark/benchmark.cmake) 5 | include(cli/cli.cmake) 6 | 7 | project(lean_container) 8 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/README.md: -------------------------------------------------------------------------------- 1 | # Mitosis User-level Lean Container 2 | 3 | ## Usage 4 | 5 | Currently, we can refer to the unit test in `tests/` for the usage of basic APIs. 6 | 7 | ```bash 8 | mkdir build 9 | cd build 10 | cmake .. 11 | make 12 | sudo ./test_lean_container_template 13 | sudo ./test_process 14 | ``` 15 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/benchmark/benchmark.cmake: -------------------------------------------------------------------------------- 1 | add_executable(benchmark_lean_container benchmark/benchmark_lean_container.c core/lean_container.c) 2 | add_executable(benchmark_lean_container_w_command benchmark/benchmark_lean_container_w_command.c core/lean_container.c) 3 | add_executable(benchmark_lean_container_pause_w_command benchmark/benchmark_lean_container_pause_w_command.c core/lean_container.c) 4 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/cli/cli.cmake: -------------------------------------------------------------------------------- 1 | add_executable(start_lean_container cli/start_lean_container.c core/lean_container.c) 2 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/scripts/sync_to_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # this script will sync the project to the remote server 3 | 4 | user="wtx" 5 | target=("val00" "val01" "val02" "val03" "val04" "val05" "val06" "val07" "val08" "val09" "val10" "val11" "val12" "val13" "val14") 6 | 7 | for machine in ${target[*]} 8 | do 9 | rsync -i -rtuv \ 10 | $(find ../build/ -maxdepth 1 -type f -executable) \ 11 | ${user}@${machine}:/home/${user} 12 | done 13 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/tests/test_cached_namespace.c: -------------------------------------------------------------------------------- 1 | #include "../core/lean_container.h" 2 | #include 3 | #include 4 | 5 | int main() { 6 | int ret, pid; 7 | pid = setup_cached_namespace(NULL); 8 | assert(pid > 0); 9 | ret = remove_cached_namespace(pid, NULL); 10 | assert(ret == 0); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/tests/test_lean_container_template.c: -------------------------------------------------------------------------------- 1 | #include "../core/lean_container.h" 2 | 3 | #include 4 | #include 5 | 6 | int main() { 7 | char* name = "test"; 8 | struct ContainerSpec spec; 9 | int ret; 10 | 11 | // unlimited resources 12 | spec.cpu_start = -1; 13 | spec.cpu_end = -1; 14 | spec.memory_in_mb = -1; 15 | spec.numa_start = -1; 16 | spec.numa_end = -1; 17 | 18 | ret = init_cgroup(); 19 | assert(ret == 0); 20 | 21 | ret = add_lean_container_template(name, &spec); 22 | assert(ret == 0); 23 | 24 | ret = remove_lean_container_template(name); 25 | assert(ret == 0); 26 | 27 | ret = deinit_cgroup(); 28 | assert(ret == 0); 29 | 30 | printf("pass lean container unit test!\n"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/lib/tests/tests.cmake: -------------------------------------------------------------------------------- 1 | add_executable(test_cached_namespace tests/test_cached_namespace.c core/lean_container.c) 2 | add_executable(test_setup_lean_container tests/test_setup_lean_container.c core/lean_container.c) 3 | add_executable(test_lean_container_template tests/test_lean_container_template.c core/lean_container.c) 4 | add_executable(test_lean_container_pause tests/test_lean_container_pause.c core/lean_container.c) 5 | add_executable(test_setup_lean_container_w_double_fork tests/test_setup_lean_container_w_double_fork.c core/lean_container.c) 6 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-lean-container/mount_device.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | import subprocess 4 | 5 | def main(): 6 | parser = argparse.ArgumentParser(description="Mount/Unmount in Rootfs") 7 | parser.add_argument('--rootfs', required=True) 8 | parser.add_argument('--device', required=True) 9 | parser.add_argument('--unmount', action='store_true') 10 | parser.set_defaults(unmount=False) 11 | args = parser.parse_args() 12 | path = os.path.join(args.rootfs, args.device.strip('/')) 13 | if args.unmount: 14 | print("unmount device %s from %s" % (args.device, args.rootfs)) 15 | subprocess.run(['umount', path]) 16 | else: 17 | print("mount device %s to %s" % (args.device, args.rootfs)) 18 | subprocess.run(['touch', path]) 19 | subprocess.run(['mount', '--bind', args.device, path]) 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-protocol/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mitosis-protocol" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-protocol/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | pub type IoctlCmdType = u32; 4 | 5 | /// a simple call cmd to test the work of system calls 6 | pub const CALL_NIL : IoctlCmdType = 0; 7 | 8 | /// Establish a UD connection from the remote end 9 | pub const CALL_CONNECT : IoctlCmdType = 3; 10 | 11 | /// Prepare the caller process's state to a shadow process at the caller machine 12 | pub const CALL_PREPARE : IoctlCmdType = 4; 13 | 14 | /// Resume from a local image 15 | pub const CALL_RESUME_LOCAL : IoctlCmdType = 5; 16 | pub const CALL_RESUME_LOCAL_W_RPC : IoctlCmdType = 6; 17 | 18 | /// Resume from a remote image 19 | pub const CALL_RESUME_REMOTE : IoctlCmdType = 7; 20 | -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-rust-client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mitosis-rust-client" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | libc = "*" 10 | nix = "0.23" 11 | mitosis-protocol = { path = "../mitosis-protocol" } -------------------------------------------------------------------------------- /mitosis-user-libs/mitosis-rust-client/src/signatures.rs: -------------------------------------------------------------------------------- 1 | use crate::{ioctl_write, ioctl_test}; 2 | 3 | ioctl_write!(mitosis_syscall_nil, mitosis_protocol::CALL_NIL as _, usize); 4 | ioctl_write!(mitosis_syscall_prepare, mitosis_protocol::CALL_PREPARE as _, u64); 5 | 6 | ioctl_test!(mitosis_test, usize); 7 | -------------------------------------------------------------------------------- /mitosis-util/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mitosis-util" 3 | version = "0.1.0" 4 | authors = ["xmm , wtx "] 5 | edition = "2018" 6 | 7 | [features] 8 | default = ["rust-kernel-linux-util"] 9 | 10 | [dependencies] 11 | rust-kernel-linux-util = {path = "../deps/krcore/rust-kernel-rdma/rust-kernel-linux-util", optional = true, features=["static_log_check","max_level_trace"]} 12 | 13 | [dependencies.lazy_static] 14 | version = "1.0" 15 | features = ["spin_no_std"] 16 | 17 | # Default profile for this project 18 | # Always enable all the optimizations except overflow-checks, disable debug print 19 | [profile.dev] 20 | opt-level = 2 21 | debug = false 22 | split-debuginfo = '...' # Platform-specific. 23 | debug-assertions = false # Set to false to disable debug print 24 | overflow-checks = true # overflow-checks is currently not a bottleneck 25 | lto = false 26 | panic = 'unwind' 27 | incremental = false 28 | codegen-units = 16 29 | rpath = false 30 | 31 | # Comment the above default profile and uncomment the follow lines, then re-make the project to enable non-release mode 32 | # Reference: https://doc.rust-lang.org/cargo/reference/profiles.html 33 | 34 | # [profile.dev] 35 | # opt-level = 1 36 | -------------------------------------------------------------------------------- /mitosis-util/bench/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /mitosis-util/bench/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | ## cpu_binding 4 | 5 | This benchmark measures the throughput of an nop operation on a single machine with the benchmark framework. 6 | 7 | ### Building & running 8 | 9 | Building: 10 | ``` 11 | cd PATH_TO_MITOSIS/mitosis-util/bench 12 | ../../scripts/bootstrap_proxy.py -f cpu_binding/scripts/build.toml -u USER -p PWD 13 | ``` 14 | 15 | Running: 16 | ``` 17 | cd PATH_TO_MITOSIS/mitosis-util/bench 18 | ../../scripts/bootstrap_proxy.py -f cpu_binding/scripts/run.toml -u USER -p PWD 19 | ../../scripts/bootstrap_proxy.py -f cpu_binding/scripts/clean.toml -u USER -p PWD 20 | ``` 21 | 22 | Be sure the clean the modules after the running! 23 | 24 | 25 | ### Reference Result 26 | 27 | The benchmark is conducted on val01. (Linux val01 4.15.0-46-generic #49~16.04.1-Ubuntu.) 28 | 29 | For a simple empty operation, the performance before and after the core binding is nearly the same. 30 | 31 | The throughput for the empty operation is about **2130M op/s** (**4269M op/s**) when we spawn **12** (**24**) benchmark thread. 32 | -------------------------------------------------------------------------------- /mitosis-util/bench/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | BASE_DIR = os.path.realpath(os.path.dirname(__file__)) 8 | 9 | def run(*args, **kwargs): 10 | cwd = kwargs.pop("cwd", None) 11 | environ = kwargs.pop("environ", os.environ) 12 | assert not kwargs 13 | 14 | print("+ [RUNNING] {}".format(list(args))) 15 | subprocess.check_call(list(args), cwd=cwd, env=environ) 16 | 17 | 18 | def main(argv): 19 | print("I am in", BASE_DIR) 20 | for path in argv[1:] or os.listdir(BASE_DIR): 21 | if ( 22 | not os.path.isdir(os.path.join(BASE_DIR, path)) 23 | ): 24 | continue 25 | 26 | print("+ [{}]".format(path)) 27 | 28 | print(path) 29 | 30 | run( 31 | "make", "-C", BASE_DIR, 32 | "TEST_NAME={}_tests".format(path.replace("-", "_")), 33 | "TEST_PATH={}".format(path), 34 | ) 35 | print("\n ========= to next build ========= \n") 36 | 37 | 38 | if __name__ == "__main__": 39 | main(sys.argv) 40 | -------------------------------------------------------------------------------- /mitosis-util/bench/cpu_binding/scripts/build.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "localhost" 3 | path = '~/projects/mos/mitosis-util/bench' 4 | cmd = './build.py cpu_binding' -------------------------------------------------------------------------------- /mitosis-util/bench/cpu_binding/scripts/clean.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "localhost" 3 | path = '~/projects/mos/mitosis-util/bench' 4 | cmd = 'sudo rmmod cpu_binding_tests.ko;' -------------------------------------------------------------------------------- /mitosis-util/bench/cpu_binding/scripts/run.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "localhost" 3 | path = '~/projects/mos/mitosis-util/bench' 4 | cmd = 'sudo dmesg -C; sudo rmmod cpu_binding_tests.ko; sudo insmod cpu_binding_tests.ko time=10 nthreads=24 & dmesg -wH' -------------------------------------------------------------------------------- /mitosis-util/bench/cpu_binding/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 4 | 5 | uint nthreads = 12; 6 | module_param(nthreads, uint, DEFAULT_PERMISSION); 7 | 8 | uint time = 10; 9 | module_param(time, uint, DEFAULT_PERMISSION); 10 | 11 | uint report_interval = 1; 12 | module_param(report_interval, uint, DEFAULT_PERMISSION); 13 | -------------------------------------------------------------------------------- /mitosis-util/bench/cpu_binding/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /mitosis-util/src/ctx.rs: -------------------------------------------------------------------------------- 1 | use crate::reporter::BenchReporter; 2 | use alloc::sync::Arc; 3 | use core::cell::UnsafeCell; 4 | 5 | pub struct ThreadLocalCTX 6 | where R : BenchReporter 7 | { 8 | pub(crate) reporter: Arc>, // reporter to report the benchmark stats 9 | pub(crate) arg: Arg, // input specific to this thread 10 | pub(crate) id: usize, // thread id 11 | pub(crate) cpu_id: Option, // id of the cpu which this thread might be bound to 12 | } 13 | 14 | impl ThreadLocalCTX 15 | where R : BenchReporter { 16 | pub fn new(arg : Arg, r : R, id : usize, cpu_id : Option) -> Self { 17 | Self { arg : arg, reporter : Arc::new(r.into()), id : id, cpu_id : cpu_id} 18 | } 19 | 20 | pub fn get_reporter(&self) -> Arc> { 21 | self.reporter.clone() 22 | } 23 | } -------------------------------------------------------------------------------- /mitosis-util/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /mitosis-util/unitests/sample_benchmark/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "sample_benchmark_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-linux-util","krdma-test", "mitosis-util"] 16 | 17 | [dependencies] 18 | krdma-test = {path = "../../../deps/rust-kernel-rdma/krdma-test", optional = true} 19 | mitosis-util = {path = "../../../mitosis-util", optional = true} 20 | rust-kernel-linux-util = {path = "../../../deps/rust-kernel-rdma/rust-kernel-linux-util", optional = true, features=["static_log_check","max_level_info"]} 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/rust-kernel-rdma/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /mitosis-util/unitests/sample_benchmark/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_basic() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | assert_eq!(dmesg_contains(&String::from("error")),false); 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /mitosis/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := mitosis.o 2 | mitosis-objs := mitosis.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libmitosis.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /mitosis/src/descriptors/mod.rs: -------------------------------------------------------------------------------- 1 | pub use reg::*; 2 | pub use page_table::*; 3 | pub use rdma::RDMADescriptor; 4 | pub use parent::{CompactPageTable, ParentDescriptor}; 5 | pub use child::ChildDescriptor; 6 | 7 | pub use vma::*; 8 | pub use pair::*; 9 | 10 | pub mod parent; 11 | pub mod child; 12 | pub mod reg; 13 | pub mod page_table; 14 | pub mod vma; 15 | pub mod pair; 16 | pub mod rdma; 17 | 18 | -------------------------------------------------------------------------------- /mitosis/src/descriptors/reg.rs: -------------------------------------------------------------------------------- 1 | #[allow(dead_code)] 2 | #[derive(Default,Debug, PartialEq, Eq, Clone)] 3 | pub struct RegDescriptor { 4 | pub(crate) others: crate::bindings::StackRegisters, 5 | pub(crate) fs: u64, 6 | pub(crate) gs: u64, 7 | } 8 | 9 | impl RegDescriptor { 10 | pub fn get_fs(&self) -> u64 { 11 | self.fs 12 | } 13 | 14 | pub fn get_gs(&self) -> u64 { 15 | self.gs 16 | } 17 | 18 | pub fn get_others_mut(&mut self) -> &mut crate::bindings::StackRegisters { 19 | &mut self.others 20 | } 21 | 22 | pub fn get_fs_mut(&mut self) -> &mut u64 { 23 | &mut self.fs 24 | } 25 | 26 | pub fn get_gs_mut(&mut self) -> &mut u64 { 27 | &mut self.gs 28 | } 29 | } 30 | 31 | impl os_network::serialize::Serialize for RegDescriptor {} 32 | -------------------------------------------------------------------------------- /mitosis/src/lock_bundler.rs: -------------------------------------------------------------------------------- 1 | use crate::linux_kernel_module::mutex::LinuxMutex; 2 | use alloc::boxed::Box; 3 | use rust_kernel_linux_util::linux_kernel_module::sync::Mutex; 4 | 5 | pub type BoxedLockBundler = Box>; 6 | 7 | /// A simple wrapper over LinuxMutex to simplifiy creation 8 | pub struct LockBundler { 9 | inner: LinuxMutex, 10 | } 11 | 12 | impl LockBundler { 13 | // `LinuxMutex` is wrapped in a `Box` because it is a self-referening struct that 14 | // cannot be moved. 15 | #[inline] 16 | pub fn new(inner: T) -> Box { 17 | let res = Box::new(Self { 18 | inner: LinuxMutex::new(inner), 19 | }); 20 | 21 | res.inner.init(); 22 | res 23 | } 24 | } 25 | 26 | #[allow(dead_code)] 27 | impl<'a, T: 'a> LockBundler { 28 | #[inline] 29 | pub fn lock(&self, f: impl FnOnce(&'a mut T) -> R) -> R { 30 | self.inner.lock_f(f) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mitosis/src/remote_mapping/mod.rs: -------------------------------------------------------------------------------- 1 | //! Abstractions for faked remote page tables and other paging related structures. 2 | //! 3 | //! Page tables translate virtual memory “pages” to remote physical memory. 4 | //! 5 | //! Credits: some code is taken from 6 | 7 | pub use page_structures::*; 8 | pub use page_table::{PageEntry, RemotePageAddr, RemotePageTable, RemotePageTableIter}; 9 | 10 | pub mod page_structures; 11 | pub mod page_table; -------------------------------------------------------------------------------- /mitosis/src/shadow_process/page_table.rs: -------------------------------------------------------------------------------- 1 | use rust_kernel_rdma_base::VmallocAllocator; 2 | use alloc::vec::Vec; 3 | 4 | pub trait GetPhyAddr { 5 | fn get_physical_addr(&self) -> crate::kern_wrappers::mm::PhyAddrType; 6 | } 7 | 8 | pub struct ShadowPageTable { 9 | table: Vec, 10 | } 11 | 12 | impl

ShadowPageTable

13 | where 14 | P: GetPhyAddr, 15 | { 16 | pub fn new() -> Self { 17 | Self { 18 | table: Vec::::with_capacity_in(32, VmallocAllocator), 19 | } 20 | } 21 | 22 | #[inline] 23 | pub fn add_page(&mut self, p: P) -> &mut Self { 24 | self.table.push(p); 25 | self 26 | } 27 | 28 | pub fn len(&self) -> usize { 29 | self.table.len() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mitosis/unitests/.gitignore: -------------------------------------------------------------------------------- 1 | child.py 2 | parent.py 3 | syscall_wrapper.py -------------------------------------------------------------------------------- /mitosis/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /mitosis/unitests/dc_pool/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "dc_pool_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 23 | 24 | [profile.dev] 25 | opt-level = 2 26 | debug = false 27 | split-debuginfo = '...' # Platform-specific. 28 | debug-assertions = true # Enable debug print in test by default 29 | overflow-checks = true # overflow-checks is currently not a bottleneck 30 | lto = false 31 | panic = 'unwind' 32 | incremental = false 33 | codegen-units = 16 34 | rpath = false 35 | -------------------------------------------------------------------------------- /mitosis/unitests/dc_pool/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use mitosis::linux_kernel_module; 6 | use mitosis::log; 7 | 8 | use mitosis::startup::*; 9 | 10 | use krdma_test::*; 11 | 12 | #[krdma_main] 13 | fn kmain() { 14 | log::info!("in test mitosis dc_pool"); 15 | 16 | let mut config : mitosis::Config = Default::default(); 17 | config.set_num_nics_used(2); 18 | config.set_max_core_cnt(12); 19 | 20 | start_instance(config).expect("start mitosis instance fail"); 21 | 22 | unsafe { assert!(mitosis::get_dc_pool_service_mut().get_dc_qp(0).is_some()) }; 23 | unsafe { assert!(mitosis::get_dc_pool_service_mut().get_dc_qp(12).is_none()) }; 24 | 25 | // TODO: shall we do more checks? 26 | } 27 | 28 | #[krdma_drop] 29 | fn clean() { 30 | end_instance(); 31 | } 32 | -------------------------------------------------------------------------------- /mitosis/unitests/dc_pool/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dc_pool() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /mitosis/unitests/fork/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "fork_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test",] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 20 | 21 | [dev-dependencies] 22 | mitosis-rust-client = { path = "../../../mitosis-user-libs/mitosis-rust-client" } 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /mitosis/unitests/fork/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | use mitosis_rust_client::*; 3 | 4 | #[test] 5 | fn test_basic() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | let mut client = MClientOptions::new() 9 | .set_device_name(DEFAULT_SYSCALL_PATH.to_string()) 10 | .open() 11 | .unwrap(); 12 | 13 | client.test(0).unwrap(); // basic 14 | 15 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 16 | }); 17 | } -------------------------------------------------------------------------------- /mitosis/unitests/kern_wrapper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "kern_wrapper_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test",] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 20 | 21 | [dev-dependencies] 22 | mitosis-rust-client = { path = "../../../mitosis-user-libs/mitosis-rust-client" } 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /mitosis/unitests/kern_wrapper/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use mitosis::syscalls::*; 6 | use mitosis::linux_kernel_module; 7 | use mitosis::log; 8 | 9 | mod my_syscall; 10 | use my_syscall::MySyscallHandler; 11 | 12 | #[allow(dead_code)] 13 | struct Module { 14 | service : SysCallsService, 15 | } 16 | 17 | impl linux_kernel_module::KernelModule for Module { 18 | fn init() -> linux_kernel_module::KernelResult { 19 | Ok(Self { 20 | service : SysCallsService::::new()? 21 | }) 22 | } 23 | } 24 | 25 | impl Drop for Module { 26 | fn drop(&mut self) { 27 | log::info!("drop System call modules") 28 | } 29 | } 30 | 31 | linux_kernel_module::kernel_module!( 32 | Module, 33 | author: b"xmm", 34 | description: b"A kernel module for testing system calls", 35 | license: b"GPL" 36 | ); 37 | -------------------------------------------------------------------------------- /mitosis/unitests/kern_wrapper/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | use mitosis_rust_client::*; 3 | 4 | #[test] 5 | fn test_different_calls() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | let mut client = MClientOptions::new() 9 | .set_device_name(DEFAULT_SYSCALL_PATH.to_string()) 10 | .open() 11 | .unwrap(); 12 | 13 | // test the task 14 | client.test(0).unwrap(); 15 | assert_eq!(dmesg_contains(&String::from("test task")), true); 16 | 17 | // test the mm 18 | client.test(1).unwrap(); 19 | assert_eq!(dmesg_contains(&String::from("test mm")), true); 20 | 21 | // test the vma 22 | client.test(3).unwrap(); 23 | assert_eq!(dmesg_contains(&String::from("test vma")), true); 24 | 25 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /mitosis/unitests/prefetcher/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "prefetcher_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true, features = ["prefetch"]} 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 23 | mitosis-rust-client = { path = "../../../mitosis-user-libs/mitosis-rust-client" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /mitosis/unitests/prefetcher/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | use mitosis_rust_client::*; 3 | 4 | #[test] 5 | fn test_prefetcher() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | let mut client = MClientOptions::new() 9 | .set_device_name(DEFAULT_SYSCALL_PATH.to_string()) 10 | .open() 11 | .unwrap(); 12 | client.nil().unwrap(); 13 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /mitosis/unitests/rc_conn_pool/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rc_conn_pool_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true, features = ["use_rc"]} 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 23 | 24 | [profile.dev] 25 | opt-level = 2 26 | debug = false 27 | split-debuginfo = '...' # Platform-specific. 28 | debug-assertions = true # Enable debug print in test by default 29 | overflow-checks = true # overflow-checks is currently not a bottleneck 30 | lto = false 31 | panic = 'unwind' 32 | incremental = false 33 | codegen-units = 16 34 | rpath = false -------------------------------------------------------------------------------- /mitosis/unitests/rc_conn_pool/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | 3 | #[test] 4 | fn test_rc_conn_pool() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 8 | }); 9 | } -------------------------------------------------------------------------------- /mitosis/unitests/rdma_context/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rdma_context_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 23 | 24 | [profile.dev] 25 | opt-level = 2 26 | debug = false 27 | split-debuginfo = '...' # Platform-specific. 28 | debug-assertions = true # Enable debug print in test by default 29 | overflow-checks = true # overflow-checks is currently not a bottleneck 30 | lto = false 31 | panic = 'unwind' 32 | incremental = false 33 | codegen-units = 16 34 | rpath = false 35 | -------------------------------------------------------------------------------- /mitosis/unitests/rdma_context/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use mitosis::linux_kernel_module; 6 | use mitosis::log; 7 | 8 | use mitosis::rdma_context::*; 9 | 10 | use krdma_test::*; 11 | 12 | #[krdma_main] 13 | fn kmain() { 14 | log::info!("in test mitosis RDMA context!"); 15 | 16 | let mut config : mitosis::Config = Default::default(); 17 | config.set_num_nics_used(2); 18 | 19 | assert!(start_rdma(&config).is_some()); 20 | } 21 | 22 | #[krdma_drop] 23 | fn clean() { 24 | end_rdma(); 25 | } 26 | -------------------------------------------------------------------------------- /mitosis/unitests/rdma_context/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | 3 | #[test] 4 | fn test_call_nil() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /mitosis/unitests/remote_page_table/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "remote_page_table_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis-protocol = {path="../../../mitosis-user-libs/mitosis-protocol"} 20 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 21 | 22 | [dev-dependencies] 23 | mitosis-rust-client = { path = "../../../mitosis-user-libs/mitosis-rust-client" } 24 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 25 | 26 | [profile.dev] 27 | opt-level = 2 28 | debug = false 29 | split-debuginfo = '...' # Platform-specific. 30 | debug-assertions = true # Enable debug print in test by default 31 | overflow-checks = true # overflow-checks is currently not a bottleneck 32 | lto = false 33 | panic = 'unwind' 34 | incremental = false 35 | codegen-units = 16 36 | rpath = false 37 | -------------------------------------------------------------------------------- /mitosis/unitests/remote_page_table/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | use mitosis_rust_client::*; 3 | 4 | #[test] 5 | fn test_call_paging() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | let mut client = MClientOptions::new() 9 | .set_device_name(DEFAULT_SYSCALL_PATH.to_string()) 10 | .open() 11 | .unwrap(); 12 | client.nil().unwrap(); 13 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /mitosis/unitests/serializer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "serializer_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test",] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 20 | hashbrown = "0.12.0" 21 | 22 | [dev-dependencies] 23 | mitosis-rust-client = { path = "../../../mitosis-user-libs/mitosis-rust-client" } 24 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 25 | 26 | [profile.dev] 27 | opt-level = 2 28 | debug = false 29 | split-debuginfo = '...' # Platform-specific. 30 | debug-assertions = true # Enable debug print in test by default 31 | overflow-checks = true # overflow-checks is currently not a bottleneck 32 | lto = false 33 | panic = 'unwind' 34 | incremental = false 35 | codegen-units = 16 36 | rpath = false 37 | -------------------------------------------------------------------------------- /mitosis/unitests/serializer/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | use mitosis_rust_client::*; 3 | 4 | #[test] 5 | fn test_descriptors_serialization() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | let mut client = MClientOptions::new() 9 | .set_device_name(DEFAULT_SYSCALL_PATH.to_string()) 10 | .open() 11 | .unwrap(); 12 | 13 | // client.test(0).unwrap(); 14 | // client.test(1).unwrap(); 15 | 16 | // client.test(3).unwrap(); 17 | client.test(4).unwrap(); 18 | client.test(5).unwrap(); 19 | client.test(6).unwrap(); 20 | 21 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /mitosis/unitests/services/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "services_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test"] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 23 | 24 | [profile.dev] 25 | opt-level = 2 26 | debug = false 27 | split-debuginfo = '...' # Platform-specific. 28 | debug-assertions = true # Enable debug print in test by default 29 | overflow-checks = true # overflow-checks is currently not a bottleneck 30 | lto = false 31 | panic = 'unwind' 32 | incremental = false 33 | codegen-units = 16 34 | rpath = false 35 | -------------------------------------------------------------------------------- /mitosis/unitests/services/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | 3 | #[test] 4 | fn test_services() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 8 | assert_eq!(dmesg_contains(&String::from("MITOSIS")), true); 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /mitosis/unitests/shadow_process/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "shadow_process_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test",] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 20 | 21 | [dev-dependencies] 22 | mitosis-rust-client = { path = "../../../mitosis-user-libs/mitosis-rust-client" } 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /mitosis/unitests/shadow_process/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use mitosis::KRdmaKit; 6 | use mitosis::linux_kernel_module; 7 | use mitosis::log; 8 | use mitosis::syscalls::*; 9 | 10 | mod my_syscall; 11 | use my_syscall::MySyscallHandler; 12 | 13 | #[allow(dead_code)] 14 | struct Module { 15 | service : SysCallsService, 16 | } 17 | 18 | impl linux_kernel_module::KernelModule for Module { 19 | fn init() -> linux_kernel_module::KernelResult { 20 | Ok(Self { 21 | service : SysCallsService::::new()? 22 | }) 23 | } 24 | } 25 | 26 | impl Drop for Module { 27 | fn drop(&mut self) { 28 | log::info!("drop System call modules") 29 | } 30 | } 31 | 32 | linux_kernel_module::kernel_module!( 33 | Module, 34 | author: b"xmm", 35 | description: b"A kernel module for testing functions related to shadow processes", 36 | license: b"GPL" 37 | ); 38 | -------------------------------------------------------------------------------- /mitosis/unitests/syscalls/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "syscalls_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["mitosis","krdma-test",] 16 | 17 | [dependencies] 18 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 19 | mitosis-protocol = {path="../../../mitosis-user-libs/mitosis-protocol"} 20 | mitosis = {path = "../../../mitosis", version="0.1.0", optional = true} 21 | 22 | [dev-dependencies] 23 | mitosis-rust-client = { path = "../../../mitosis-user-libs/mitosis-rust-client" } 24 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 25 | 26 | [profile.dev] 27 | opt-level = 2 28 | debug = false 29 | split-debuginfo = '...' # Platform-specific. 30 | debug-assertions = true # Enable debug print in test by default 31 | overflow-checks = true # overflow-checks is currently not a bottleneck 32 | lto = false 33 | panic = 'unwind' 34 | incremental = false 35 | codegen-units = 16 36 | rpath = false 37 | -------------------------------------------------------------------------------- /mitosis/unitests/syscalls/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use mitosis::linux_kernel_module; 6 | use mitosis::log; 7 | use mitosis::syscalls::*; 8 | 9 | mod my_syscall; 10 | use my_syscall::MySyscallHandler; 11 | 12 | #[allow(dead_code)] 13 | struct Module { 14 | service : SysCallsService, 15 | } 16 | 17 | impl linux_kernel_module::KernelModule for Module { 18 | fn init() -> linux_kernel_module::KernelResult { 19 | Ok(Self { 20 | service : SysCallsService::::new()? 21 | }) 22 | } 23 | } 24 | 25 | impl Drop for Module { 26 | fn drop(&mut self) { 27 | log::info!("drop System call modules") 28 | } 29 | } 30 | 31 | linux_kernel_module::kernel_module!( 32 | Module, 33 | author: b"xmm", 34 | description: b"A kernel module for testing system calls", 35 | license: b"GPL" 36 | ); 37 | -------------------------------------------------------------------------------- /mitosis/unitests/syscalls/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{dmesg_contains, with_kernel_module}; 2 | use mitosis_rust_client::*; 3 | 4 | #[test] 5 | fn test_call_nil() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | let mut client = MClientOptions::new() 9 | .set_device_name(DEFAULT_SYSCALL_PATH.to_string()) 10 | .open() 11 | .unwrap(); 12 | client.nil().unwrap(); 13 | assert_eq!(dmesg_contains(&String::from("nil")), true); 14 | assert_eq!(dmesg_contains(&String::from("ERROR")), false); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /os-network/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMitosisOS/mitosis-core/3f9f11af3a58b53646d27b79dbd2e91ea55bef2e/os-network/README.md -------------------------------------------------------------------------------- /os-network/bench/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /os-network/bench/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | BASE_DIR = os.path.realpath(os.path.dirname(__file__)) 8 | 9 | def run(*args, **kwargs): 10 | cwd = kwargs.pop("cwd", None) 11 | environ = kwargs.pop("environ", os.environ) 12 | assert not kwargs 13 | 14 | print("+ [RUNNING] {}".format(list(args))) 15 | subprocess.check_call(list(args), cwd=cwd, env=environ) 16 | 17 | 18 | def main(argv): 19 | print("I am in", BASE_DIR) 20 | for path in argv[1:] or os.listdir(BASE_DIR): 21 | if ( 22 | not os.path.isdir(os.path.join(BASE_DIR, path)) 23 | ): 24 | continue 25 | 26 | print("+ [{}]".format(path)) 27 | 28 | print(path) 29 | 30 | run( 31 | "make", "-C", BASE_DIR, 32 | "TEST_NAME={}_tests".format(path.replace("-", "_")), 33 | "TEST_PATH={}".format(path), 34 | ) 35 | 36 | print("\n ========= to next build ========= \n") 37 | 38 | if __name__ == "__main__": 39 | main(sys.argv) 40 | -------------------------------------------------------------------------------- /os-network/bench/dc_read_client/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | uint remote_service_id_base = 50; 7 | module_param(remote_service_id_base, uint, DEFAULT_PERMISSION); 8 | 9 | uint nic_count = 2; 10 | module_param(nic_count, uint, DEFAULT_PERMISSION); 11 | 12 | uint running_secs = 30; 13 | module_param(running_secs, uint, DEFAULT_PERMISSION); 14 | 15 | uint report_interval = 1; 16 | module_param(report_interval, uint, DEFAULT_PERMISSION); 17 | 18 | uint thread_count = 12; 19 | module_param(thread_count, uint, DEFAULT_PERMISSION); 20 | 21 | char gids_arr[BUF_LENGTH] = {'I', 'P', 'A', 'D', 'S', '\0'}; 22 | char* gids = gids_arr; 23 | module_param_string(gids, gids_arr, BUF_LENGTH, DEFAULT_PERMISSION); 24 | 25 | ulong memory_size = 4096; 26 | module_param(memory_size, ulong, DEFAULT_PERMISSION); 27 | -------------------------------------------------------------------------------- /os-network/bench/dc_read_client/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | -------------------------------------------------------------------------------- /os-network/bench/dc_read_or_client/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | uint remote_service_id_base = 50; 7 | module_param(remote_service_id_base, uint, DEFAULT_PERMISSION); 8 | 9 | uint nic_count = 2; 10 | module_param(nic_count, uint, DEFAULT_PERMISSION); 11 | 12 | uint running_secs = 30; 13 | module_param(running_secs, uint, DEFAULT_PERMISSION); 14 | 15 | uint report_interval = 1; 16 | module_param(report_interval, uint, DEFAULT_PERMISSION); 17 | 18 | uint thread_count = 12; 19 | module_param(thread_count, uint, DEFAULT_PERMISSION); 20 | 21 | char gids_arr[BUF_LENGTH] = {'I', 'P', 'A', 'D', 'S', '\0'}; 22 | char* gids = gids_arr; 23 | module_param_string(gids, gids_arr, BUF_LENGTH, DEFAULT_PERMISSION); 24 | 25 | ulong memory_size = 4096; 26 | module_param(memory_size, ulong, DEFAULT_PERMISSION); 27 | 28 | ulong or_factor = 12; 29 | module_param(or_factor, ulong, DEFAULT_PERMISSION); 30 | -------------------------------------------------------------------------------- /os-network/bench/dc_read_or_client/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | -------------------------------------------------------------------------------- /os-network/bench/one_sided_read_server/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 4 | 5 | uint nic_count = 2; 6 | module_param(nic_count, uint, DEFAULT_PERMISSION); 7 | 8 | uint service_id_base = 50; 9 | module_param(service_id_base, uint, DEFAULT_PERMISSION); 10 | 11 | ulong memory_size = 4096; 12 | module_param(memory_size, ulong, DEFAULT_PERMISSION); 13 | -------------------------------------------------------------------------------- /os-network/bench/one_sided_read_server/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /os-network/bench/rc_conn_client/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | uint remote_service_id_base = 50; 7 | module_param(remote_service_id_base, uint, DEFAULT_PERMISSION); 8 | 9 | uint nic_count = 2; 10 | module_param(nic_count, uint, DEFAULT_PERMISSION); 11 | 12 | uint running_secs = 30; 13 | module_param(running_secs, uint, DEFAULT_PERMISSION); 14 | 15 | uint report_interval = 1; 16 | module_param(report_interval, uint, DEFAULT_PERMISSION); 17 | 18 | uint thread_count = 12; 19 | module_param(thread_count, uint, DEFAULT_PERMISSION); 20 | 21 | char gids_arr[BUF_LENGTH] = {'I', 'P', 'A', 'D', 'S', '\0'}; 22 | char* gids = gids_arr; 23 | module_param_string(gids, gids_arr, BUF_LENGTH, DEFAULT_PERMISSION); 24 | -------------------------------------------------------------------------------- /os-network/bench/rc_conn_client/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | -------------------------------------------------------------------------------- /os-network/bench/rc_conn_server/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | uint nic_count = 2; 7 | module_param(nic_count, uint, DEFAULT_PERMISSION); 8 | 9 | uint service_id_base = 50; 10 | module_param(service_id_base, uint, DEFAULT_PERMISSION); 11 | -------------------------------------------------------------------------------- /os-network/bench/rc_conn_server/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /os-network/bench/rc_read_client/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | uint remote_service_id_base = 50; 7 | module_param(remote_service_id_base, uint, DEFAULT_PERMISSION); 8 | 9 | uint nic_count = 2; 10 | module_param(nic_count, uint, DEFAULT_PERMISSION); 11 | 12 | uint running_secs = 30; 13 | module_param(running_secs, uint, DEFAULT_PERMISSION); 14 | 15 | uint report_interval = 1; 16 | module_param(report_interval, uint, DEFAULT_PERMISSION); 17 | 18 | uint thread_count = 12; 19 | module_param(thread_count, uint, DEFAULT_PERMISSION); 20 | 21 | char gids_arr[BUF_LENGTH] = {'I', 'P', 'A', 'D', 'S', '\0'}; 22 | char* gids = gids_arr; 23 | module_param_string(gids, gids_arr, BUF_LENGTH, DEFAULT_PERMISSION); 24 | 25 | ulong memory_size = 4096; 26 | module_param(memory_size, ulong, DEFAULT_PERMISSION); 27 | -------------------------------------------------------------------------------- /os-network/bench/rc_read_client/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | -------------------------------------------------------------------------------- /os-network/bench/rc_read_or_client/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | uint remote_service_id_base = 50; 7 | module_param(remote_service_id_base, uint, DEFAULT_PERMISSION); 8 | 9 | uint nic_count = 2; 10 | module_param(nic_count, uint, DEFAULT_PERMISSION); 11 | 12 | uint running_secs = 30; 13 | module_param(running_secs, uint, DEFAULT_PERMISSION); 14 | 15 | uint report_interval = 1; 16 | module_param(report_interval, uint, DEFAULT_PERMISSION); 17 | 18 | uint thread_count = 12; 19 | module_param(thread_count, uint, DEFAULT_PERMISSION); 20 | 21 | char gids_arr[BUF_LENGTH] = {'I', 'P', 'A', 'D', 'S', '\0'}; 22 | char* gids = gids_arr; 23 | module_param_string(gids, gids_arr, BUF_LENGTH, DEFAULT_PERMISSION); 24 | 25 | ulong memory_size = 4096; 26 | module_param(memory_size, ulong, DEFAULT_PERMISSION); 27 | 28 | ulong or_factor = 12; 29 | module_param(or_factor, ulong, DEFAULT_PERMISSION); 30 | -------------------------------------------------------------------------------- /os-network/bench/rc_read_or_client/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | -------------------------------------------------------------------------------- /os-network/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | components = ["rust-src"] -------------------------------------------------------------------------------- /os-network/src/conn.rs: -------------------------------------------------------------------------------- 1 | use super::Future; 2 | 3 | /// A trait for connection: A connection should support posting (submiting) requests and polling results from trait `Future`. 4 | /// 5 | pub trait Conn: Future { 6 | type ReqPayload; // the request format 7 | type CompPayload = Self::Output; 8 | type IOResult = Self::Error; 9 | 10 | fn post(&mut self, req: &Self::ReqPayload) -> Result<(), Self::IOResult>; 11 | } 12 | 13 | /// A general trait to generate connection object. 14 | /// 15 | pub trait Factory { 16 | type ConnMeta; 17 | type ConnType; 18 | type ConnResult; 19 | 20 | fn create(&self, meta: Self::ConnMeta) -> Result; 21 | } 22 | 23 | /// A general trait to generate connection metadata. 24 | /// 25 | pub trait MetaFactory: Factory { 26 | type HyperMeta: Default; 27 | type Meta; 28 | type MetaResult; 29 | 30 | fn create_meta(&self, meta: Self::HyperMeta) -> Result; 31 | } 32 | -------------------------------------------------------------------------------- /os-network/src/datagram.rs: -------------------------------------------------------------------------------- 1 | use super::Future; 2 | 3 | /// A trait to specificly post (submit) a message buffer to the underlying data structure. 4 | /// The received message is polled from the trait `Future`. 5 | /// 6 | pub trait Receiver: Future { 7 | type IOResult = Self::Error; 8 | type MsgBuf; 9 | 10 | const HEADER: usize; 11 | const MTU: usize; 12 | 13 | // post receive buffer to the underlying datagram implementation 14 | fn post_recv_buf(&mut self, buf: Self::MsgBuf) -> Result<(), Self::IOResult>; 15 | } 16 | 17 | pub mod msg; 18 | pub mod ud; 19 | pub mod ud_receiver; 20 | -------------------------------------------------------------------------------- /os-network/src/future.rs: -------------------------------------------------------------------------------- 1 | /// A simple async marker, inspired by tokio 2 | /// 3 | #[derive(Copy, Clone, Debug, PartialEq)] 4 | pub enum Async { 5 | /// Represents that a value is immediately ready. 6 | Ready(T), 7 | 8 | /// Represents that a value is not ready yet, but may be so later. 9 | NotReady, 10 | } 11 | 12 | impl From for Async { 13 | fn from(t: T) -> Async { 14 | Async::Ready(t) 15 | } 16 | } 17 | 18 | pub type Poll = Result, E>; 19 | 20 | /// A simplified in-kernel future, inspired by tokio 21 | /// 22 | pub trait Future { 23 | type Output; 24 | type Error; 25 | 26 | fn poll<'a>(&'a mut self) -> Poll; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /os-network/src/rdma/payload.rs: -------------------------------------------------------------------------------- 1 | use alloc::sync::Arc; 2 | 3 | use core::ops::Range; 4 | 5 | use KRdmaKit::{DatagramEndpoint, MemoryRegion}; 6 | 7 | #[derive(Copy, Clone)] 8 | pub enum RDMAOp { 9 | READ, 10 | WRITE, 11 | } 12 | 13 | pub trait Signaled { 14 | fn is_signaled(&self) -> bool; 15 | fn set_signaled(self) -> Self; 16 | fn set_unsignaled(self) -> Self; 17 | } 18 | 19 | pub trait LocalMR { 20 | fn set_local_mr(self, mr: Arc) -> Self; 21 | fn set_local_mr_range(self, range: Range) -> Self; 22 | fn get_local_mr(&self) -> Arc; 23 | fn get_local_mr_range(&self) -> Range; 24 | } 25 | 26 | pub trait RDMAWR { 27 | fn set_raddr(self, raddr: u64) -> Self; 28 | fn set_rkey(self, rkey: u32) -> Self; 29 | fn set_op(self, op: RDMAOp) -> Self; 30 | fn get_raddr(&self) -> u64; 31 | fn get_rkey(&self) -> u32; 32 | fn get_op(&self) -> RDMAOp; 33 | } 34 | 35 | pub trait EndPoint { 36 | fn set_endpoint(self, endpoint: Arc) -> Self; 37 | fn get_endpoint(&self) -> Arc; 38 | } 39 | 40 | pub mod dc; 41 | pub mod rc; 42 | pub mod ud; 43 | -------------------------------------------------------------------------------- /os-network/src/remote_memory.rs: -------------------------------------------------------------------------------- 1 | /// A abstraction trait to read/write remote/local memory 2 | /// 3 | pub trait Device { 4 | /// data for authentication the validity of the operation 5 | type Key; 6 | 7 | /// network address, e.g., IP 8 | type Location; 9 | 10 | /// remote memory address 11 | type RemoteMemory; 12 | 13 | /// local memory address 14 | type LocalMemory; 15 | 16 | /// memory size 17 | type Size; 18 | 19 | /// error type 20 | type IOResult; 21 | 22 | unsafe fn read( 23 | &mut self, 24 | loc: &Self::Location, 25 | addr: &Self::RemoteMemory, 26 | key: &Self::Key, 27 | to: &mut Self::LocalMemory, 28 | size: &Self::Size, 29 | ) -> Result<(), Self::IOResult>; 30 | 31 | unsafe fn write( 32 | &mut self, 33 | loc: &Self::Location, 34 | addr: &Self::RemoteMemory, 35 | key: &Self::Key, 36 | to: &mut Self::LocalMemory, 37 | size: &Self::Size, 38 | ) -> Result<(), Self::IOResult>; 39 | } 40 | 41 | pub mod local; 42 | pub mod rdma; 43 | -------------------------------------------------------------------------------- /os-network/src/remote_memory/rdma.rs: -------------------------------------------------------------------------------- 1 | pub mod dc; 2 | pub mod rc; 3 | pub use dc::*; 4 | pub use rc::*; 5 | 6 | pub struct MemoryKeys { 7 | rkey: u32, 8 | } 9 | 10 | impl MemoryKeys { 11 | pub fn new(rkey: u32) -> Self { 12 | Self { 13 | rkey: rkey, 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /os-network/src/rpc/analysis.rs: -------------------------------------------------------------------------------- 1 | use hashbrown::HashMap; 2 | 3 | #[derive(Debug)] 4 | pub struct RPCAnalysis { 5 | ncalls: usize, 6 | pub(crate) session_counts: HashMap, 7 | } 8 | 9 | impl RPCAnalysis { 10 | pub fn new() -> Self { 11 | Self { 12 | ncalls: 0, 13 | session_counts: Default::default(), 14 | } 15 | } 16 | 17 | pub fn get_ncalls(&self) -> usize { 18 | self.ncalls 19 | } 20 | 21 | #[inline] 22 | pub fn handle_one(&mut self) { 23 | self.ncalls += 1; 24 | } 25 | 26 | #[inline] 27 | pub fn handle_session_call(&mut self, id: usize) { 28 | if self.session_counts.contains_key(&id) { 29 | self.session_counts.insert(id, self.session_counts[&id] + 1); 30 | } else { 31 | self.session_counts.insert(id, 1); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /os-network/src/rpc/impls.rs: -------------------------------------------------------------------------------- 1 | pub mod ud; -------------------------------------------------------------------------------- /os-network/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /os-network/unitests/bytes/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "bytes_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test",] 16 | 17 | [dependencies] 18 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 19 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 20 | thiserror-no-std = "2.0.2" 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /os-network/unitests/bytes/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_bytes() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("error")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /os-network/unitests/dc/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [workspace] 3 | 4 | [package] 5 | name = "dc_tests" 6 | version = "0.1.0" 7 | authors = ["xmm "] 8 | edition = "2018" 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["os-network","krdma-test",] 17 | 18 | [dependencies] 19 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 20 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 21 | thiserror-no-std = "2.0.2" 22 | 23 | [dev-dependencies] 24 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 25 | 26 | [profile.dev] 27 | opt-level = 2 28 | debug = false 29 | split-debuginfo = '...' # Platform-specific. 30 | debug-assertions = true # Enable debug print in test by default 31 | overflow-checks = true # overflow-checks is currently not a bottleneck 32 | lto = false 33 | panic = 'unwind' 34 | incremental = false 35 | codegen-units = 16 36 | rpath = false 37 | -------------------------------------------------------------------------------- /os-network/unitests/dc/tests/test.rs: -------------------------------------------------------------------------------- 1 | 2 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 3 | 4 | #[test] 5 | fn test_basic() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | assert_eq!(dmesg_contains(&String::from("error")),false); 9 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /os-network/unitests/rc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rc_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test",] 16 | 17 | [dependencies] 18 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 19 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 20 | thiserror-no-std = "2.0.2" 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /os-network/unitests/rc/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_rc_related() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /os-network/unitests/remote_memory/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "remote_memory_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test",] 16 | 17 | [dependencies] 18 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 19 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 20 | thiserror-no-std = "2.0.2" 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /os-network/unitests/remote_memory/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_bytes() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("error")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /os-network/unitests/rpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rpc_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test",] 16 | 17 | [dependencies] 18 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 19 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 20 | thiserror-no-std = "2.0.2" 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /os-network/unitests/rpc/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_bytes() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /os-network/unitests/timeout/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "timeout_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test",] 16 | 17 | [dependencies] 18 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 19 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 20 | thiserror-no-std = "2.0.2" 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /os-network/unitests/timeout/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_rc_related() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /os-network/unitests/ud/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [workspace] 3 | 4 | [package] 5 | name = "ud_tests" 6 | version = "0.1.0" 7 | authors = ["xmm "] 8 | edition = "2018" 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["os-network","krdma-test",] 17 | 18 | [dependencies] 19 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 20 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 21 | thiserror-no-std = "2.0.2" 22 | 23 | [dev-dependencies] 24 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 25 | 26 | [profile.dev] 27 | opt-level = 2 28 | debug = false 29 | split-debuginfo = '...' # Platform-specific. 30 | debug-assertions = true # Enable debug print in test by default 31 | overflow-checks = true # overflow-checks is currently not a bottleneck 32 | lto = false 33 | panic = 'unwind' 34 | incremental = false 35 | codegen-units = 16 36 | rpath = false 37 | -------------------------------------------------------------------------------- /os-network/unitests/ud/tests/test.rs: -------------------------------------------------------------------------------- 1 | 2 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 3 | 4 | #[test] 5 | fn test_basic() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | assert_eq!(dmesg_contains(&String::from("error")),false); 9 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /os-network/unitests/ud_session/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [workspace] 3 | 4 | [package] 5 | name = "ud_session_tests" 6 | version = "0.1.0" 7 | authors = ["xmm "] 8 | edition = "2018" 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["os-network","krdma-test",] 17 | 18 | [dependencies] 19 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 20 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 21 | thiserror-no-std = "2.0.2" 22 | 23 | [dev-dependencies] 24 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 25 | 26 | [profile.dev] 27 | opt-level = 2 28 | debug = false 29 | split-debuginfo = '...' # Platform-specific. 30 | debug-assertions = true # Enable debug print in test by default 31 | overflow-checks = true # overflow-checks is currently not a bottleneck 32 | lto = false 33 | panic = 'unwind' 34 | incremental = false 35 | codegen-units = 16 36 | rpath = false 37 | -------------------------------------------------------------------------------- /os-network/unitests/ud_session/tests/test.rs: -------------------------------------------------------------------------------- 1 | 2 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 3 | 4 | #[test] 5 | fn test_basic() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | assert_eq!(dmesg_contains(&String::from("error")),false); 9 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /os-network/unitests/wc_err/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "wc_err_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test",] 16 | 17 | [dependencies] 18 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 19 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 20 | thiserror-no-std = "2.0.2" 21 | 22 | [dev-dependencies] 23 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 24 | 25 | [profile.dev] 26 | opt-level = 2 27 | debug = false 28 | split-debuginfo = '...' # Platform-specific. 29 | debug-assertions = true # Enable debug print in test by default 30 | overflow-checks = true # overflow-checks is currently not a bottleneck 31 | lto = false 32 | panic = 'unwind' 33 | incremental = false 34 | codegen-units = 16 35 | rpath = false 36 | -------------------------------------------------------------------------------- /os-network/unitests/wc_err/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_rc_related() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("dump error cqe")),true); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /samples/cpp/.gitignore: -------------------------------------------------------------------------------- 1 | cmake-build-debug -------------------------------------------------------------------------------- /samples/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(simple_cpp_examples) 2 | ADD_DEFINITIONS(-std=c++17) 3 | cmake_minimum_required(VERSION 3.2) 4 | 5 | set(samples 6 | child parent) 7 | add_executable(child child.cc) 8 | add_executable(parent parent.cc) 9 | foreach(s ${samples}) 10 | target_link_libraries(${s} pthread) 11 | endforeach(s) 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/cpp/child.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../../mitosis-user-libs/mitosis-c-client/include/syscall.h" 4 | 5 | int 6 | main() 7 | { 8 | int sd = sopen(); 9 | assert(sd != 0); 10 | sleep(1); 11 | 12 | fork_resume_remote(sd, 0, 73); 13 | assert(0); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /samples/cpp/parent.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../mitosis-user-libs/mitosis-c-client/include/syscall.h" 5 | 6 | int 7 | main() 8 | { 9 | int sd = sopen(); 10 | assert(sd != 0); 11 | int cnt = 0; 12 | printf("time %d\n", cnt++); 13 | sleep(1); 14 | 15 | fork_prepare(sd, 73); 16 | 17 | while (1) { 18 | printf("time %d\n", cnt++); 19 | sleep(1); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /samples/python/child.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import os 4 | import syscall_lib 5 | 6 | dump_key = 73 7 | 8 | def main(): 9 | fd = syscall_lib.open() 10 | print('fd: %d' % fd) 11 | syscall_lib.call_resume_local(fd, dump_key) 12 | 13 | while True: 14 | assert False 15 | 16 | if __name__ == '__main__': 17 | main() -------------------------------------------------------------------------------- /samples/python/parent.py: -------------------------------------------------------------------------------- 1 | import time 2 | import os 3 | import syscall_lib 4 | 5 | fd = -1 6 | counter = 0 7 | 8 | def main(): 9 | global fd, counter 10 | fd = syscall_lib.open() 11 | 12 | time.sleep(1) 13 | print("open MITOSIS client, fd {}", fd) 14 | 15 | syscall_lib.call_prepare(fd, 73) 16 | 17 | while True: 18 | time.sleep(1) 19 | counter += 1 20 | s = "check counter %d, fd %d" % (counter,fd) 21 | print(s) 22 | 23 | if __name__ == '__main__': 24 | main() 25 | -------------------------------------------------------------------------------- /samples/python/syscall_lib.py: -------------------------------------------------------------------------------- 1 | import fcntl 2 | import os 3 | 4 | PREPARE = 4 5 | RESUME_LOCAL = 5 6 | RESUME_LOCAL_RPC = 6 7 | 8 | 9 | def open(): 10 | fd = os.open('/dev/mitosis-syscalls', os.O_RDWR) 11 | return fd 12 | 13 | 14 | def call_prepare(sd, key): 15 | res = fcntl.ioctl(sd, PREPARE, key) 16 | return res 17 | 18 | 19 | def call_resume_local(sd, key): 20 | res = fcntl.ioctl(sd, RESUME_LOCAL, key) 21 | return res 22 | 23 | 24 | def call_resume_local_rpc(sd, key): 25 | res = fcntl.ioctl(sd, RESUME_LOCAL_RPC, key) 26 | return res 27 | -------------------------------------------------------------------------------- /scripts/sync.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #target="$1" 4 | 5 | #target="wxd@val01" 6 | 7 | #target=("val01" "val02" "val03" "val04" "val05") ## all the client and server hosts 8 | target=("val01" "val00") ## all the client and server hosts 9 | 10 | #target = "wxd@cube1" 11 | ## this script will sync the project to the remote server 12 | for machine in ${target[*]} 13 | do 14 | rsync -i -rtuv \ 15 | $PWD/../ \ 16 | $machine:~/projects/mos \ 17 | --exclude 'CMakeCache.txt' \ 18 | --exclude 'target' \ 19 | --exclude 'Cargo.lock' \ 20 | --exclude '.git' \ 21 | 22 | done 23 | -------------------------------------------------------------------------------- /scripts/test.toml: -------------------------------------------------------------------------------- 1 | helloworld 2 | json 3 | linpack 4 | compression 5 | pyaes 6 | chameleon 7 | image 8 | dd 9 | recognition 10 | pagerank 11 | matmul 12 | ffmpeg -------------------------------------------------------------------------------- /stress-test/.gitignore: -------------------------------------------------------------------------------- 1 | copy*.sh 2 | run*.toml 3 | out* 4 | makefile 5 | build 6 | -------------------------------------------------------------------------------- /stress-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(c_common) 2 | ADD_DEFINITIONS(-std=c++17) 3 | cmake_minimum_required(VERSION 3.2) 4 | 5 | set(ggflags_DIR "${CMAKE_SOURCE_DIR}/../deps/gflags") 6 | add_subdirectory(${CMAKE_SOURCE_DIR}/../deps/gflags gflags_dir) 7 | 8 | include_directories(../mitosis-user-libs/mitosis-lean-container/lib) 9 | 10 | set(targets 11 | simple_parent ## simple parent demo 12 | ) 13 | 14 | add_executable(simple_parent fork/simple_parent.cc) 15 | target_link_libraries(simple_parent gflags pthread -static) 16 | -------------------------------------------------------------------------------- /stress-test/fork/simple_parent.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../../mitosis-user-libs/mitosis-c-client/include/syscall.h" 7 | 8 | DEFINE_int64(handler_id, 73, "rfork handler id"); 9 | DEFINE_bool(pin, true, "whether pin in kernel"); 10 | 11 | int 12 | main(int argc, char *argv[]) { 13 | gflags::ParseCommandLineFlags(&argc, &argv, true); 14 | 15 | int sd = sopen(); 16 | int cnt = 0; 17 | assert(sd != 0); 18 | 19 | if (FLAGS_pin) { 20 | fork_prepare_ping(sd, FLAGS_handler_id); 21 | // return immediately 22 | _exit(0); 23 | } else { 24 | sleep(1); 25 | printf("time %d\n", cnt++); 26 | fork_prepare(sd, FLAGS_handler_id); 27 | } 28 | 29 | while (1) { 30 | printf("time %d\n", cnt++); 31 | sleep(1); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /stress-test/rpc/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "os-network krdma-test" --no-default-features 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /stress-test/rpc/Kbuild-checksum-payload: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "os-network krdma-test checksum-payload" --no-default-features 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /stress-test/rpc/Kbuild-empty-rpc: -------------------------------------------------------------------------------- 1 | obj-m := $(TEST_NAME).o 2 | $(TEST_NAME)-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "os-network krdma-test" --no-default-features 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /stress-test/rpc/build_tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | BASE_DIR = os.path.realpath(os.path.dirname(__file__)) 8 | 9 | def run(*args, **kwargs): 10 | cwd = kwargs.pop("cwd", None) 11 | environ = kwargs.pop("environ", os.environ) 12 | assert not kwargs 13 | 14 | print("+ [RUNNING] {}".format(list(args))) 15 | subprocess.check_call(list(args), cwd=cwd, env=environ) 16 | 17 | 18 | def main(argv): 19 | print("I am in", BASE_DIR) 20 | for path in argv[1:] or os.listdir(BASE_DIR): 21 | if ( 22 | not os.path.isdir(os.path.join(BASE_DIR, path)) or 23 | not os.path.exists(os.path.join(BASE_DIR, path, "tests")) 24 | ): 25 | continue 26 | 27 | print("+ [{}]".format(path)) 28 | 29 | print(path) 30 | 31 | run( 32 | "make", "-C", BASE_DIR, 33 | "TEST_NAME={}_tests".format(path.replace("-", "_")), 34 | "TEST_PATH={}".format(path), 35 | ) 36 | print("\n ========= to next test ========= \n") 37 | 38 | 39 | if __name__ == "__main__": 40 | main(sys.argv) 41 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rpc_client_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test"] 16 | checksum-payload = [] 17 | 18 | [dependencies] 19 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 20 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 21 | mitosis-macros = {path = "../../../mitosis-macros"} 22 | hashbrown = {features=["raw"], path="../../../deps/hashbrown"} 23 | rpc_common = {path = "../rpc_common"} 24 | 25 | [dev-dependencies] 26 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 27 | 28 | [profile.dev] 29 | opt-level = 2 30 | debug = false 31 | split-debuginfo = '...' # Platform-specific. 32 | debug-assertions = true # Enable debug print in test by default 33 | overflow-checks = true # overflow-checks is currently not a bottleneck 34 | lto = false 35 | panic = 'unwind' 36 | incremental = false 37 | codegen-units = 16 38 | rpath = false 39 | 40 | [build-dependencies] 41 | bindgen = "0.54" 42 | cc = "1.0" 43 | shlex = "0.1" 44 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_client/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define BUF_LENGTH 256 4 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 5 | 6 | ulong server_qd_hint = 73; 7 | module_param(server_qd_hint, ulong, DEFAULT_PERMISSION); 8 | 9 | ulong client_qd_hint = 74; 10 | module_param(client_qd_hint, ulong, DEFAULT_PERMISSION); 11 | 12 | ulong server_service_id = 0; 13 | module_param(server_service_id, ulong, DEFAULT_PERMISSION); 14 | 15 | ulong client_service_id_base = 1; 16 | module_param(client_service_id_base, ulong, DEFAULT_PERMISSION); 17 | 18 | ulong thread_count = 1; 19 | module_param(thread_count, ulong, DEFAULT_PERMISSION); 20 | 21 | uint test_rpc_id = 73; 22 | module_param(test_rpc_id, uint, DEFAULT_PERMISSION); 23 | 24 | ulong session_id_base = 0; 25 | module_param(session_id_base, ulong, DEFAULT_PERMISSION); 26 | 27 | long running_secs = 10; 28 | module_param(running_secs, long, DEFAULT_PERMISSION); 29 | 30 | long report_interval = 1; 31 | module_param(report_interval, long, DEFAULT_PERMISSION); 32 | 33 | char gid_arr[BUF_LENGTH] = "fe80:0000:0000:0000:ec0d:9a03:00ca:2f4c"; 34 | char* gid = gid_arr; 35 | module_param_string(gid, gid_arr, BUF_LENGTH, DEFAULT_PERMISSION); 36 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_client/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_client/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_bytes() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_common/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rpc_common" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | hashbrown = {features=["raw"], path="../../../deps/hashbrown"} 10 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_common/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | pub mod random; 4 | pub mod payload; 5 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_common/src/payload.rs: -------------------------------------------------------------------------------- 1 | use crate::random::FastRandom; 2 | 3 | pub const DEFAULT_PAYLOAD_SIZE: usize = 2048; 4 | pub type DefaultSizedPayload = Payload; 5 | 6 | pub struct Payload { 7 | pub checksum: u64, 8 | pub arr: [u8; N], 9 | } 10 | 11 | impl Payload { 12 | 13 | pub fn create(random_seed: u64) -> Self { 14 | let mut arr: [u8; N] = [0 as u8; N]; 15 | let mut random = FastRandom::new(random_seed); 16 | for i in 0..N { 17 | let r = random.get_next() as u8; 18 | arr[i] = r; 19 | } 20 | let mut res = Self { 21 | checksum: 0, 22 | arr: arr, 23 | }; 24 | res.checksum = res.calculate_checksum(); 25 | res 26 | } 27 | 28 | pub fn checksum_ok(&self) -> bool { 29 | self.calculate_checksum() == self.checksum 30 | } 31 | 32 | fn calculate_checksum(&self) -> u64 { 33 | use core::hash::BuildHasher; 34 | use hashbrown::hash_map::DefaultHashBuilder; 35 | use core::hash::{Hash, Hasher}; 36 | let mut s = DefaultHashBuilder::with_seed(0).build_hasher(); 37 | self.arr.hash(&mut s); 38 | s.finish() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_common/src/random.rs: -------------------------------------------------------------------------------- 1 | /// taken from a java-version implementation: 2 | /// http://developer.classpath.org/doc/java/util/Random-source.htmlv 3 | #[allow(dead_code)] 4 | pub struct FastRandom { 5 | seed: u64, 6 | } 7 | 8 | #[allow(dead_code)] 9 | impl FastRandom { 10 | pub fn new(seed: u64) -> Self { 11 | Self { 12 | seed: Self::set_seed0(seed), 13 | } 14 | } 15 | 16 | pub fn get_next(&mut self) -> u64 { 17 | self.next(32).wrapping_shl(32).wrapping_add(self.next(32)) 18 | } 19 | 20 | pub fn get_cur_seed(&self) -> u64 { 21 | self.seed 22 | } 23 | 24 | #[inline] 25 | fn next(&mut self, bits: usize) -> u64 { 26 | self.seed = (self 27 | .seed 28 | .wrapping_mul(0x5DEECE66D as u64) 29 | .wrapping_add(0xB as u64)) 30 | & (((1 as u64) << 48) - 1); 31 | // self.seed 32 | self.seed.wrapping_shr((48 - bits) as u32) 33 | } 34 | 35 | #[inline] 36 | fn set_seed0(seed: u64) -> u64 { 37 | (seed ^ (0x5DEECE66D as u64)) & (((1 as u64) << 48) - 1) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_server/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rpc_server_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["os-network","krdma-test"] 16 | checksum-payload = [] 17 | 18 | [dependencies] 19 | os-network = {path = "../../../os-network", optional = true, features = ["dct"]} 20 | krdma-test = {path="../../../deps/krcore/rust-kernel-rdma/krdma-test",optional = true} 21 | mitosis-macros = {path = "../../../mitosis-macros"} 22 | hashbrown = {features=["raw"], path="../../../deps/hashbrown"} 23 | rpc_common = {path = "../rpc_common"} 24 | 25 | [dev-dependencies] 26 | kernel-module-testlib = { path = "../../../deps/krcore/testlib" } 27 | 28 | [profile.dev] 29 | opt-level = 2 30 | debug = false 31 | split-debuginfo = '...' # Platform-specific. 32 | debug-assertions = true # Enable debug print in test by default 33 | overflow-checks = true # overflow-checks is currently not a bottleneck 34 | lto = false 35 | panic = 'unwind' 36 | incremental = false 37 | codegen-units = 16 38 | rpath = false 39 | 40 | [build-dependencies] 41 | bindgen = "0.54" 42 | cc = "1.0" 43 | shlex = "0.1" 44 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_server/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | 3 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 4 | 5 | ulong qd_hint = 73; 6 | module_param(qd_hint, ulong, DEFAULT_PERMISSION); 7 | 8 | ulong service_id = 0; 9 | module_param(service_id, ulong, DEFAULT_PERMISSION); 10 | 11 | ulong test_rpc_id = 73; 12 | module_param(test_rpc_id, ulong, DEFAULT_PERMISSION); 13 | 14 | long running_secs = 30; 15 | module_param(running_secs, long, DEFAULT_PERMISSION); 16 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_server/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_server/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_bytes() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /stress-test/rpc/rpc_single_machine/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_bytes() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /stress-test/templates-build/template-build-cpp.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'exp' 7 | cmd = 'cmake . ; make -j' 8 | 9 | [[template.pass]] 10 | role = 'builder' 11 | path = 'stress-test' 12 | cmd = 'mkdir -p build; cd build; cmake ..; make -j' 13 | 14 | [template.placeholder] 15 | name = ["build"] 16 | -------------------------------------------------------------------------------- /stress-test/templates-build/template-build-lean-container.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'child' 6 | path = '' 7 | cmd = 'make clean_fs; make export LEAN_APP_NAME=simple_child' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | -------------------------------------------------------------------------------- /stress-test/templates-build/template-build-mitosis.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = '' 7 | cmd = 'source $HOME/.profile; source $HOME/.cargo/env; cp mitosis-kms/${Kbuild} mitosis-kms/Kbuild && make km;' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | Kbuild = "Kbuild-mitosis-cow" 12 | -------------------------------------------------------------------------------- /stress-test/templates-build/template-build-rpc-bench.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'stress-test/rpc' 7 | cmd = 'source $HOME/.profile; cp Kbuild-empty-rpc Kbuild; ./build_tests.py rpc_server rpc_client' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | -------------------------------------------------------------------------------- /stress-test/templates-build/template-build-rpc-checksum.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'stress-test/rpc' 7 | cmd = 'source $HOME/.profile; cp Kbuild-checksum-payload Kbuild; ./build_tests.py rpc_server rpc_client' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | -------------------------------------------------------------------------------- /stress-test/templates-build/template-clean.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'child' 6 | path = '' 7 | cmd = 'make clean_fs LEAN_APP_NAME=simple_child' 8 | 9 | [[template.pass]] 10 | role = 'child' 11 | path = '' 12 | cmd = 'source $HOME/.cargo/env; rm -rf mitosis-kms/target ; make rmmod' 13 | 14 | [[template.pass]] 15 | role = 'parent' 16 | path = '' 17 | cmd = 'source $HOME/.cargo/env; rm -rf mitosis-kms/target ; sleep 10 && make rmmod' 18 | 19 | [template.placeholder] 20 | name = ["build"] 21 | -------------------------------------------------------------------------------- /stress-test/templates-run/peak-lean-container.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = '' 7 | cmd = 'make insmod ID=0' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = '' 13 | cmd = 'make insmod ID=${@incr} && make unmount_dev mount_dev LEAN_APP_NAME=simple_child' 14 | order = 0 15 | 16 | [[template.pass]] 17 | role = 'child' 18 | path = 'exp' 19 | cmd = './connector -gid=${parent_gid} -mac_id=0 -nic_id=0' 20 | order = 1 21 | 22 | [[template.pass]] 23 | role = 'parent' 24 | path = 'stress-test/build' 25 | cmd = './simple_parent -pin true' 26 | order = 2 27 | 28 | 29 | [[template.pass]] 30 | role = 'child' 31 | path = '' 32 | cmd = 'make bench_lean_mitosis mac_id=0 LEAN_BENCH_EXE_PATH=${exe_name} LEAN_APP_NAME=simple_child BENCH_SEC=${run_sec}' 33 | order = 3 34 | loop = 24 35 | 36 | [template.placeholder] 37 | working_set = ["lean_container"] 38 | exe_name = "exp/bench_lean_container" 39 | run_sec = 30 40 | -------------------------------------------------------------------------------- /stress-test/templates-run/peak-rpc-kernel-module.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'parent' 6 | path = 'stress-test/rpc' 7 | cmd = 'sudo dmesg -C > /dev/null; dmesg -wH & sudo insmod rpc_server_tests.ko running_secs=${server_running_secs} test_rpc_id=${test_rpc_id} qd_hint=${server_qd_hint} service_id=${server_service_id} && sleep 10 && sudo rmmod rpc_server_tests.ko && pkill dmesg' 8 | order = 0 9 | 10 | [[template.pass]] 11 | role = 'child' 12 | path = 'stress-test/rpc' 13 | cmd = 'export session_id_base=$(echo $RANDOM*100|bc) && sudo dmesg -C > /dev/null && sleep 2; dmesg -wH & sudo insmod rpc_client_tests.ko server_qd_hint=${server_qd_hint} client_qd_hint=${client_qd_hint} server_service_id=${server_service_id} client_service_id_base=${client_service_id_base} test_rpc_id=${test_rpc_id} running_secs=${client_running_secs} report_interval=${report_interval} thread_count=${thread_count} session_id_base=$session_id_base gid=${parent_gid} && sleep 2 && sudo rmmod rpc_client_tests.ko && pkill dmesg' 14 | order = 0 15 | 16 | [template.placeholder] 17 | name = ["nil_rpc"] 18 | server_running_secs = 80 19 | client_running_secs = 60 20 | thread_count = 12 21 | test_rpc_id = 778 22 | server_qd_hint = 73 23 | server_service_id = 0 24 | client_qd_hint = 75 25 | client_service_id_base = 1 26 | report_interval = 1 27 | --------------------------------------------------------------------------------