Loading .gitlab-ci.yml +6 −0 Original line number Diff line number Diff line Loading @@ -56,11 +56,17 @@ unit-test-job: # This job runs in the test stage. image: gekkofs/deps:0.9.4-dev needs: ['build-job'] script: - ${BUILD_PATH}/opendevnull --syscall open --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall open --reps 1 --verbose - ${BUILD_PATH}/opendevnull --syscall getpid --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpid --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpid --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose --always_syscall artifacts: expire_in: 1 week when: always Loading CMakeLists.txt +10 −11 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) message(STATUS "[${PROJECT_NAME}] Checking for syscall_intercept") find_package(Syscall_intercept REQUIRED) # Print the include directory for debugging message(STATUS "Syscall_intercept include dir: ${Syscall_intercept_INCLUDE_DIR}") set(INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include") Loading @@ -33,23 +35,20 @@ include_directories( ${INCLUDE_DIR} ${CMAKE_BINARY_DIR}/include /usr/include ${Syscall_intercept_INCLUDE_DIR} ) add_library(eval_intercept SHARED src/eval.cpp) add_executable(opendevnull src/opendevnull.cpp) add_library(eval_intercept SHARED) add_executable(opendevnull) target_sources(eval_intercept PRIVATE src/eval.cpp ) target_sources(opendevnull # Include path from Syscall_intercept into opendevnull target_include_directories(opendevnull PRIVATE src/opendevnull.cpp ${Syscall_intercept_INCLUDE_DIR} ) # Include path from Syscall_intercept into opendevnull target_include_directories(opendevnull target_include_directories(eval_intercept PRIVATE ${Syscall_intercept_INCLUDE_DIR} ) Loading @@ -75,6 +74,6 @@ install( install( TARGETS opendevnull LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) scripts/run.sh +73 −6 Original line number Diff line number Diff line NATIVE="./opendevnull --syscall getpid" INTERC="./opendevnull --syscall getpid" SC2SC="./opendevnull --syscall getpid --always_syscall" #!/bin/bash SYSCALL="getpid" BUILD=../build REPEATS=20 ARCH="X86" NATIVE="$BUILD/opendevnull --syscall $SYSCALL" INTERC="$BUILD/opendevnull --syscall $SYSCALL" SC2SC="$BUILD/opendevnull --syscall $SYSCALL --always_syscall" # Arrays to store output values native_outputs=() interc_outputs=() sc2sc_outputs=() # Function to calculate statistics calculate_stats() { local values=("$@") local sum=0 local count=${#values[@]} local min=${values[0]} local max=${values[0]} # Calculate sum, min, and max for value in "${values[@]}"; do sum=$(echo "$sum + $value" | bc) if (( $(echo "$value < $min" | bc -l) )); then min=$value fi if (( $(echo "$value > $max" | bc -l) )); then max=$value fi done # Calculate average local avg=$(echo "scale=2; $sum / $count" | bc) # Calculate standard deviation local variance=0 for value in "${values[@]}"; do variance=$(echo "$variance + ($value - $avg)^2" | bc) done local stddev=$(echo "scale=2; sqrt($variance / $count)" | bc) echo "Average: $avg, Min: $min, Max: $max, StdDev: $stddev" } for ((i=1; i<=REPEATS; i++)) do OUTPUT=$($NATIVE | cut -f4 --delim=" ") native_outputs+=("$OUTPUT") echo "Native,$ARCH,"$OUTPUT done for ((i=1; i<=REPEATS; i++)) do OUTPUT=$(LD_PRELOAD=./libeval_intercept.so $INTERC | cut -f4 --delim=" ") OUTPUT=$(LD_PRELOAD=$BUILD/libeval_intercept.so $INTERC | cut -f4 --delim=" ") interc_outputs+=("$OUTPUT") echo "Syscall,$ARCH,"$OUTPUT done for ((i=1; i<=REPEATS; i++)) do OUTPUT=$(LD_PRELOAD=./libeval_intercept.so $SC2SC | cut -f4 --delim=" ") OUTPUT=$(LD_PRELOAD=$BUILD/libeval_intercept.so $SC2SC | cut -f4 --delim=" ") sc2sc_outputs+=("$OUTPUT") echo "Syscall2S,$ARCH,"$OUTPUT done # Calculate and print statistics echo "" echo "Statistics for NATIVE mode:" calculate_stats "${native_outputs[@]}" echo "" echo "Statistics for INTERC mode:" calculate_stats "${interc_outputs[@]}" echo "" echo "Statistics for SC2SC mode:" calculate_stats "${sc2sc_outputs[@]}" # Calculate overhead native_avg=$(echo "${native_outputs[@]}" | tr ' ' '\n' | awk '{sum+=$1} END {print sum/NR}') interc_avg=$(echo "${interc_outputs[@]}" | tr ' ' '\n' | awk '{sum+=$1} END {print sum/NR}') sc2sc_avg=$(echo "${sc2sc_outputs[@]}" | tr ' ' '\n' | awk '{sum+=$1} END {print sum/NR}') overhead_interc=$(echo "scale=2; (($interc_avg - $native_avg) / $native_avg) * 100" | bc) overhead_sc2sc=$(echo "scale=2; (($sc2sc_avg - $native_avg) / $native_avg) * 100" | bc) echo "" echo "Overhead of INTERC over NATIVE: $overhead_interc%" echo "Overhead of SC2SC over NATIVE: $overhead_sc2sc%" src/opendevnull.cpp +21 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ main(int argc, char* argv[]) { syscall = argv[++i]; } else { std::cerr << "Error: --syscall requires an argument (open|getpid|kill)" << "Error: --syscall requires an argument (open|getpid|kill|getpagesize)" << std::endl; return 1; } Loading Loading @@ -133,7 +133,22 @@ main(int argc, char* argv[]) { auto post_kill = [](int) { }; double time_taken = 0.0; // getpagesyze() is used to determine the page size, pre - post auto pre_size = []() { int ret = getpagesize(); if(verbose) { std::cout << "getpagesize() returned " << ret << std::endl; } if(always_syscall) { syscall_no_intercept(SYS_getpagesize); } return ret; }; auto post_size = [](int) { }; if(syscall == "open") { time_taken = measure_syscall_time(pre_open, post_open, reps); Loading @@ -141,7 +156,10 @@ main(int argc, char* argv[]) { time_taken = measure_syscall_time(pre_getpid, post_getpid, reps); } else if(syscall == "kill") { time_taken = measure_syscall_time(pre_kill, post_kill, reps); } else { } else if(syscall == "getpagesize") { time_taken = measure_syscall_time(pre_size, post_size, reps); } else { std::cerr << "Error: Unsupported syscall '" << syscall << "'" << std::endl; return 1; Loading Loading
.gitlab-ci.yml +6 −0 Original line number Diff line number Diff line Loading @@ -56,11 +56,17 @@ unit-test-job: # This job runs in the test stage. image: gekkofs/deps:0.9.4-dev needs: ['build-job'] script: - ${BUILD_PATH}/opendevnull --syscall open --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall open --reps 1 --verbose - ${BUILD_PATH}/opendevnull --syscall getpid --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpid --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpid --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose --always_syscall artifacts: expire_in: 1 week when: always Loading
CMakeLists.txt +10 −11 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) message(STATUS "[${PROJECT_NAME}] Checking for syscall_intercept") find_package(Syscall_intercept REQUIRED) # Print the include directory for debugging message(STATUS "Syscall_intercept include dir: ${Syscall_intercept_INCLUDE_DIR}") set(INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include") Loading @@ -33,23 +35,20 @@ include_directories( ${INCLUDE_DIR} ${CMAKE_BINARY_DIR}/include /usr/include ${Syscall_intercept_INCLUDE_DIR} ) add_library(eval_intercept SHARED src/eval.cpp) add_executable(opendevnull src/opendevnull.cpp) add_library(eval_intercept SHARED) add_executable(opendevnull) target_sources(eval_intercept PRIVATE src/eval.cpp ) target_sources(opendevnull # Include path from Syscall_intercept into opendevnull target_include_directories(opendevnull PRIVATE src/opendevnull.cpp ${Syscall_intercept_INCLUDE_DIR} ) # Include path from Syscall_intercept into opendevnull target_include_directories(opendevnull target_include_directories(eval_intercept PRIVATE ${Syscall_intercept_INCLUDE_DIR} ) Loading @@ -75,6 +74,6 @@ install( install( TARGETS opendevnull LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
scripts/run.sh +73 −6 Original line number Diff line number Diff line NATIVE="./opendevnull --syscall getpid" INTERC="./opendevnull --syscall getpid" SC2SC="./opendevnull --syscall getpid --always_syscall" #!/bin/bash SYSCALL="getpid" BUILD=../build REPEATS=20 ARCH="X86" NATIVE="$BUILD/opendevnull --syscall $SYSCALL" INTERC="$BUILD/opendevnull --syscall $SYSCALL" SC2SC="$BUILD/opendevnull --syscall $SYSCALL --always_syscall" # Arrays to store output values native_outputs=() interc_outputs=() sc2sc_outputs=() # Function to calculate statistics calculate_stats() { local values=("$@") local sum=0 local count=${#values[@]} local min=${values[0]} local max=${values[0]} # Calculate sum, min, and max for value in "${values[@]}"; do sum=$(echo "$sum + $value" | bc) if (( $(echo "$value < $min" | bc -l) )); then min=$value fi if (( $(echo "$value > $max" | bc -l) )); then max=$value fi done # Calculate average local avg=$(echo "scale=2; $sum / $count" | bc) # Calculate standard deviation local variance=0 for value in "${values[@]}"; do variance=$(echo "$variance + ($value - $avg)^2" | bc) done local stddev=$(echo "scale=2; sqrt($variance / $count)" | bc) echo "Average: $avg, Min: $min, Max: $max, StdDev: $stddev" } for ((i=1; i<=REPEATS; i++)) do OUTPUT=$($NATIVE | cut -f4 --delim=" ") native_outputs+=("$OUTPUT") echo "Native,$ARCH,"$OUTPUT done for ((i=1; i<=REPEATS; i++)) do OUTPUT=$(LD_PRELOAD=./libeval_intercept.so $INTERC | cut -f4 --delim=" ") OUTPUT=$(LD_PRELOAD=$BUILD/libeval_intercept.so $INTERC | cut -f4 --delim=" ") interc_outputs+=("$OUTPUT") echo "Syscall,$ARCH,"$OUTPUT done for ((i=1; i<=REPEATS; i++)) do OUTPUT=$(LD_PRELOAD=./libeval_intercept.so $SC2SC | cut -f4 --delim=" ") OUTPUT=$(LD_PRELOAD=$BUILD/libeval_intercept.so $SC2SC | cut -f4 --delim=" ") sc2sc_outputs+=("$OUTPUT") echo "Syscall2S,$ARCH,"$OUTPUT done # Calculate and print statistics echo "" echo "Statistics for NATIVE mode:" calculate_stats "${native_outputs[@]}" echo "" echo "Statistics for INTERC mode:" calculate_stats "${interc_outputs[@]}" echo "" echo "Statistics for SC2SC mode:" calculate_stats "${sc2sc_outputs[@]}" # Calculate overhead native_avg=$(echo "${native_outputs[@]}" | tr ' ' '\n' | awk '{sum+=$1} END {print sum/NR}') interc_avg=$(echo "${interc_outputs[@]}" | tr ' ' '\n' | awk '{sum+=$1} END {print sum/NR}') sc2sc_avg=$(echo "${sc2sc_outputs[@]}" | tr ' ' '\n' | awk '{sum+=$1} END {print sum/NR}') overhead_interc=$(echo "scale=2; (($interc_avg - $native_avg) / $native_avg) * 100" | bc) overhead_sc2sc=$(echo "scale=2; (($sc2sc_avg - $native_avg) / $native_avg) * 100" | bc) echo "" echo "Overhead of INTERC over NATIVE: $overhead_interc%" echo "Overhead of SC2SC over NATIVE: $overhead_sc2sc%"
src/opendevnull.cpp +21 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ main(int argc, char* argv[]) { syscall = argv[++i]; } else { std::cerr << "Error: --syscall requires an argument (open|getpid|kill)" << "Error: --syscall requires an argument (open|getpid|kill|getpagesize)" << std::endl; return 1; } Loading Loading @@ -133,7 +133,22 @@ main(int argc, char* argv[]) { auto post_kill = [](int) { }; double time_taken = 0.0; // getpagesyze() is used to determine the page size, pre - post auto pre_size = []() { int ret = getpagesize(); if(verbose) { std::cout << "getpagesize() returned " << ret << std::endl; } if(always_syscall) { syscall_no_intercept(SYS_getpagesize); } return ret; }; auto post_size = [](int) { }; if(syscall == "open") { time_taken = measure_syscall_time(pre_open, post_open, reps); Loading @@ -141,7 +156,10 @@ main(int argc, char* argv[]) { time_taken = measure_syscall_time(pre_getpid, post_getpid, reps); } else if(syscall == "kill") { time_taken = measure_syscall_time(pre_kill, post_kill, reps); } else { } else if(syscall == "getpagesize") { time_taken = measure_syscall_time(pre_size, post_size, reps); } else { std::cerr << "Error: Unsupported syscall '" << syscall << "'" << std::endl; return 1; Loading