From 0848b64c1d83c70860d7aaf6a77c1babe96c143c Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Mon, 27 Jul 2020 11:23:21 +0900 Subject: [PATCH] uti: integrate syscall_intercept Change-Id: Ide14341acdca1450b0ad4f8a16cc078d0743afc8 --- .gitmodules | 3 +++ CMakeLists.txt | 5 ---- docs/uti.rst | 36 +++++------------------------ executer/user/CMakeLists.txt | 11 ++++++--- executer/user/lib/CMakeLists.txt | 13 +++++++++++ executer/user/lib/syscall_intercept | 1 + scripts/mckernel.spec.in | 11 +++++++-- 7 files changed, 40 insertions(+), 40 deletions(-) create mode 160000 executer/user/lib/syscall_intercept diff --git a/.gitmodules b/.gitmodules index d49326e3..2a363f52 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "executer/user/lib/libdwarf/libdwarf"] path = executer/user/lib/libdwarf/libdwarf url = https://github.com/bgerofi/libdwarf.git +[submodule "executer/user/lib/syscall_intercept"] + path = executer/user/lib/syscall_intercept + url = https://github.com/RIKEN-SysSoft/syscall_intercept.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e84631f..dae38c9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,11 +218,6 @@ if (ENABLE_QLMPI) find_package(MPI REQUIRED) endif() -if (ENABLE_UTI) - pkg_check_modules(LIBSYSCALL_INTERCEPT REQUIRED libsyscall_intercept) - link_directories(${LIBSYSCALL_INTERCEPT_LIBRARY_DIRS}) -endif() - string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-([0-9]+)(.*))?" "\\1;\\2;\\3;\\5;\\6" LINUX_VERSION ${UNAME_R}) list(GET LINUX_VERSION 0 LINUX_VERSION_MAJOR) list(GET LINUX_VERSION 1 LINUX_VERSION_MINOR) diff --git a/docs/uti.rst b/docs/uti.rst index c019d0ff..607fd2c6 100644 --- a/docs/uti.rst +++ b/docs/uti.rst @@ -41,32 +41,6 @@ and then install it to your home directory of the login node: sed -i 's#/usr/#'"$HOME"'/'"$(uname -p)"'/usr/#' $HOME/$(uname -p)/usr/lib64/pkgconfig/capstone.pc -Install syscall_intercept -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - git clone https://github.com/RIKEN-SysSoft/syscall_intercept.git - mkdir build && cd build - -When ``capstone`` and ``capstone-devel`` are installed into the system directory: - -:: - - cmake ../syscall_intercept/arch/aarch64 -DCMAKE_INSTALL_PREFIX=${HOME}/$(uname -p)/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DTREAT_WARNINGS_AS_ERRORS=OFF - -When ``capstone`` and ``capstone-devel`` are installed into your home directory: - -:: - - CMAKE_PREFIX_PATH=${HOME}/$(uname -p)/usr cmake ../syscall_intercept/arch/aarch64 -DCMAKE_INSTALL_PREFIX=${HOME}/$(uname -p)/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DTREAT_WARNINGS_AS_ERRORS=OFF - -Install: - -:: - - make && make install && make test - Install UTI for McKernel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -79,6 +53,7 @@ Install: ../uti/configure --prefix= --with-rm=mckernel make && make install + Install McKernel ~~~~~~~~~~~~~~~~~~~~ @@ -86,11 +61,11 @@ Install McKernel :: - CMAKE_PREFIX_PATH=${HOME}/$(uname -p)/usr cmake -DCMAKE_INSTALL_PREFIX=${HOME}/ihk+mckernel -DENABLE_UTI=ON $HOME/src/ihk+mckernel/mckernel + cmake -DCMAKE_INSTALL_PREFIX=${HOME}/ihk+mckernel -DENABLE_UTI=ON $HOME/src/ihk+mckernel/mckernel make -j install Run programs -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~ ``mcexec`` with ``--enable-uti`` option: @@ -99,9 +74,9 @@ Run programs mcexec --enable-uti Install UTI for Linux -~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~ -You should skip this step if it's already installed as with, for example, Fujitsu Technical Computing Suite. +You can skip this step if you don't want to develop a run-time using UTI, or if it's already installed with, for example, Fujitsu Technical Computing Suite. Install by make """"""""""""""" @@ -124,3 +99,4 @@ Install by rpm rm -f ~/rpmbuild/SOURCES/.tar.gz rpmbuild -ba ./scripts/uti.spec rpm -Uvh uti---.rpm + diff --git a/executer/user/CMakeLists.txt b/executer/user/CMakeLists.txt index 42edafed..c53dc9d9 100644 --- a/executer/user/CMakeLists.txt +++ b/executer/user/CMakeLists.txt @@ -69,13 +69,18 @@ if (ENABLE_QLMPI) endif() if (ENABLE_UTI) + link_directories("${CMAKE_CURRENT_BINARY_DIR}/lib/syscall_intercept") + add_library(mck_syscall_intercept SHARED syscall_intercept.c arch/${ARCH}/archdep_c.c) + + # target name is defined by add_library(), not project() or add_subdirectory() + add_dependencies(mck_syscall_intercept syscall_intercept_shared) if (${ARCH} STREQUAL "arm64") set_source_files_properties(syscall_intercept.c PROPERTIES COMPILE_FLAGS -mgeneral-regs-only) endif() - target_link_libraries(mck_syscall_intercept ${LIBSYSCALL_INTERCEPT_LIBRARIES}) - target_include_directories(mck_syscall_intercept PRIVATE ${LIBSYSCALL_INTERCEPT_INCLUDE_DIRS}) - set_target_properties(mck_syscall_intercept PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) + target_link_libraries(mck_syscall_intercept syscall_intercept) + target_include_directories(mck_syscall_intercept PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib/syscall_intercept/include) + set_target_properties(mck_syscall_intercept PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib64) install(TARGETS mck_syscall_intercept DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/executer/user/lib/CMakeLists.txt b/executer/user/lib/CMakeLists.txt index 9488eb7b..e44fbe1b 100644 --- a/executer/user/lib/CMakeLists.txt +++ b/executer/user/lib/CMakeLists.txt @@ -1,3 +1,16 @@ if (NOT LIBDWARF) add_subdirectory(libdwarf) endif() + +if (ENABLE_UTI) + if (${ARCH} STREQUAL "arm64") + set(SYSCALL_INTERCEPT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/syscall_intercept/arch/aarch64" CACHE STRINGS "relative path to syscalL_intercept source directory") + elseif (${ARCH} STREQUAL "x86_64") + set(SYSCALL_INTERCEPT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/syscall_intercept" CACHE STRINGS "relative path to syscalL_intercept source directory") + endif() + + # change cmake options only in this directory + SET(CMAKE_BUILD_TYPE Release CACHE STRING "release build" FORCE) + SET(TREAT_WARNINGS_AS_ERRORS OFF CACHE BOOL "ignore warnings" FORCE) + add_subdirectory(${SYSCALL_INTERCEPT_SOURCE_DIR} syscall_intercept) +endif() diff --git a/executer/user/lib/syscall_intercept b/executer/user/lib/syscall_intercept new file mode 160000 index 00000000..13e8ed10 --- /dev/null +++ b/executer/user/lib/syscall_intercept @@ -0,0 +1 @@ +Subproject commit 13e8ed10a0c28160c81a2fb3f79b3c83da6b135f diff --git a/scripts/mckernel.spec.in b/scripts/mckernel.spec.in index f7179d66..9b3651c5 100644 --- a/scripts/mckernel.spec.in +++ b/scripts/mckernel.spec.in @@ -23,13 +23,13 @@ Summary: IHK/McKernel License: GPLv2 Source0: mckernel-%{version}.tar.gz -Requires: systemd-libs numactl-libs libdwarf +Requires: systemd-libs numactl-libs libdwarf capstone # don't use kernel_module_package so that one rpm including .ko and binaries are created %if "%{?_host_cpu}" == "x86_64" && "%{?_target_cpu}" == "aarch64" %define cross_compile 1 %else -BuildRequires: systemd-devel numactl-devel binutils-devel kernel-devel libdwarf-devel +BuildRequires: systemd-devel numactl-devel binutils-devel kernel-devel libdwarf-devel capstone-devel # Friendly reminder of the fact that kernel-rpm-macros is no longer included in kernel-devel %if 0%{?rhel} >= 8 BuildRequires: redhat-rpm-config kernel-rpm-macros elfutils-libelf-devel @@ -107,6 +107,10 @@ This package contains headers and libraries required for build apps using IHK/Mc %{_libdir}/libsched_yield.so.1.0.0 %{_libdir}/libsched_yield.so %{_libdir}/libldump2mcdump.so +%{_libdir}/libmck_syscall_intercept.so +%{_libdir}/libsyscall_intercept.so.0.1.0 +%{_libdir}/libsyscall_intercept.so.0 +%{_libdir}/libsyscall_intercept.so %{_sysconfdir}/irqbalance_mck.in %{_mandir}/man1/mcreboot.1.gz %{_mandir}/man1/ihkconfig.1.gz @@ -131,6 +135,9 @@ This package contains headers and libraries required for build apps using IHK/Mc %{_includedir}/ihk/ihk_monitor.h %{_includedir}/ihk/ihk_debug.h %{_includedir}/ihk/ihk_host_driver.h +%{_includedir}/libsyscall_intercept_hook_point.h +%{_libdir}/pkgconfig/libsyscall_intercept.pc +%{_mandir}/man3/libsyscall_intercept.3 /lib/modules/%{kernel_version}/extra/mckernel/ihk/linux/core/Module.symvers # taken from /usr/lib/rpm/redhat/kmodtool (kernel_module_package)