-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e719dcf
Showing
408 changed files
with
34,331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
IndentWidth: 4 | ||
ColumnLimit: 100 | ||
AllowShortBlocksOnASingleLine: Empty | ||
# AllowShortFunctionsOnASingleLine: Inline | ||
AllowShortLoopsOnASingleLine: true | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AlignConsecutiveMacros: true | ||
AlignEscapedNewlines: Left | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterFunction: true | ||
PointerAlignment: Right | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Build CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build-libos: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: sudo apt-get install -y cmake libnuma-dev libgflags-dev zlib1g-dev libzstd-dev | ||
- name: Cache build | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{github.workspace}}/build | ||
key: ${{ runner.os }}-build-${{ env.cache-name }} | ||
- name: Build libos and apps | ||
run: CMAKE_ARGS="-DROCKSDB_JOBS=1" SCHED=fifo make DPDK=0 | ||
|
||
|
||
build-kmod: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build kernel module | ||
run: make kmod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.vscode | ||
*.o | ||
*.ko | ||
*.cmd | ||
*.mod | ||
*.mod.c | ||
*.symvers | ||
*.order | ||
.DS_Store | ||
build/ | ||
main | ||
.cache/ | ||
__pycache__/ | ||
compile_commands.json | ||
!extra.symvers | ||
include/skyloft/uapi/params.h | ||
include/skyloft/params.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[submodule "apps/schbench"] | ||
path = apps/schbench | ||
url = [email protected]:yhtzd/schbench.git | ||
branch = skyloft | ||
[submodule "apps/memcached"] | ||
path = apps/memcached | ||
url = [email protected]:yhtzd/memcached.git | ||
branch = skyloft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(skyloft LANGUAGES C CXX ASM) | ||
|
||
if(DEBUG) | ||
set(CMAKE_BUILD_TYPE "Debug") | ||
add_definitions(-DDEBUG) | ||
endif() | ||
|
||
set(CMAKE_C_STANDARD 23) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 -Wall -Wextra -Wno-unused-parameter") | ||
if (DPDK) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") | ||
elseif (SCHED_POLICY MATCHES "^(fifo|rr|cfs)$") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-sse") | ||
endif() | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-strict-aliasing") | ||
|
||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${CMAKE_CURRENT_SOURCE_DIR}/libos/libos.ld") | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
|
||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") | ||
|
||
include(CheckCXXCompilerFlag) | ||
CHECK_CXX_COMPILER_FLAG("-momit-leaf-frame-pointer" HAVE_OMIT_LEAF_FRAME_POINTER) | ||
|
||
if(HAVE_OMIT_LEAF_FRAME_POINTER) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -momit-leaf-frame-pointer") | ||
endif() | ||
endif() | ||
|
||
if(NOT USE_RTTI) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") | ||
endif() | ||
|
||
# Hook exit in all targets | ||
add_compile_options(-Wl,--wrap=exit) | ||
add_link_options(-Wl,--wrap=exit) | ||
|
||
set(CMAKE_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/) | ||
|
||
if(STAT) | ||
add_definitions(-DSKYLOFT_STAT) | ||
endif() | ||
|
||
if(UINTR) | ||
add_definitions(-DSKYLOFT_UINTR) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -muintr") | ||
endif() | ||
|
||
if(LOG_LEVEL) | ||
if(NOT LOG_LEVEL MATCHES "^(debug|info|notice|warn|err|crit)$") | ||
message(FATAL_ERROR "Invalid log level: ${LOG_LEVEL}") | ||
endif() | ||
|
||
string(TOUPPER ${LOG_LEVEL} LOG_LEVEL_UPPER) | ||
add_definitions(-DLOG_LEVEL_${LOG_LEVEL_UPPER}) | ||
endif() | ||
|
||
message(STATUS "Log level: ${LOG_LEVEL}") | ||
|
||
if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") | ||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) | ||
endif() | ||
|
||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
message(STATUS "Schedule policy: ${SCHED_POLICY}") | ||
|
||
if(SCHED_POLICY STREQUAL "fifo") | ||
add_definitions(-DSKYLOFT_SCHED_FIFO) | ||
elseif(SCHED_POLICY STREQUAL "rr") | ||
add_definitions(-DSKYLOFT_SCHED_FIFO2) | ||
elseif(SCHED_POLICY STREQUAL "cfs") | ||
add_definitions(-DSKYLOFT_SCHED_CFS) | ||
elseif(SCHED_POLICY STREQUAL "sq") | ||
add_definitions(-DSKYLOFT_SCHED_SQ) | ||
elseif(SCHED_POLICY STREQUAL "sq_lcbe") | ||
add_definitions(-DSKYLOFT_SCHED_SQ_LCBE) | ||
endif() | ||
|
||
add_subdirectory(utils) | ||
add_subdirectory(libos) | ||
|
||
if (SCHED_POLICY MATCHES "^(sq|sq_lcbe)$") | ||
add_subdirectory(synthetic) | ||
else() | ||
add_subdirectory(apps) | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
SIGNAL ?= | ||
DPDK ?= 1 | ||
TIMER ?= 1 | ||
UINTR ?= 0 | ||
SCHED ?= fifo | ||
DAEMON ?= | ||
DEBUG ?= | ||
STAT ?= | ||
LOG ?= info | ||
|
||
CC ?= gcc | ||
CFLAGS := -Wall -O2 -D_GNU_SOURCE | ||
CMAKE_ARGS ?= | ||
|
||
CMAKE_ARGS += -DSCHED_POLICY=$(SCHED) | ||
CMAKE_ARGS += -DSIGNAL=$(SIGNAL) -DDPDK=$(DPDK) -DTIMER=$(TIMER) -DUINTR=$(UINTR) -DDAEMON=$(DAEMON) -DDEBUG=$(DEBUG) -DSTAT=$(STAT) -DLOG_LEVEL=$(LOG) | ||
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=install | ||
|
||
all: build | ||
|
||
build: | ||
mkdir -p build | ||
cd build && cmake .. $(CMAKE_ARGS) && make VERBOSE=1 -j4 | ||
|
||
install: build | ||
cd build && make install | ||
|
||
kmod: | ||
cd kmod && make | ||
|
||
insmod: | ||
cd kmod && make insmod | ||
|
||
tests: | ||
cd tests && make | ||
|
||
memcached: install | ||
cd build && make memcached VERBOSE=1 | ||
|
||
zstd: install | ||
cd build && make zstd VERBOSE=1 | ||
|
||
schbench: install | ||
cd build && make schbench VERBOSE=1 | ||
|
||
rocksdb: install | ||
cd build && make rocksdb_server VERBOSE=1 | ||
|
||
fmt: | ||
@clang-format --style=file -i $(shell find utils/ libos/ apps/ tests/ experiments/ -iname '*.c' -o -iname '*.cc' -o -iname '*.h') | ||
|
||
clean: | ||
make -C build clean | ||
|
||
distclean: clean | ||
rm -rf build | ||
make -C tests clean | ||
make -C kmod clean | ||
|
||
.PHONY: all clean fmt kmod build tests install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Skyloft | ||
|
||
Skyloft: A General High-Efficient Scheduling Framework in User Space | ||
|
||
## Overview | ||
|
||
<div align="left"> | ||
<img src=docs/imgs/overview.jpg width=60% /> | ||
</div> | ||
|
||
### Layout | ||
|
||
- `apps/`: Benchmark real-world applications | ||
- `docs/`: Documents and images | ||
- `synthetic/`: Benchmark c-FCFS and PS scheduling policies | ||
- `rocksdb/`: Latency-critical application | ||
- `antagonist/`: Batch application | ||
- `kmod/`: Skyloft kernel module | ||
- `libos/`: Skyloft main code | ||
- `io/`: IO thread | ||
- `net/`: Network stack | ||
- `shim/`: Shim layer for POSIX APIs | ||
- `sync/`: Synchronization primitives | ||
- `mm/`: Memory management | ||
- `sched/`: Schedulers | ||
- `utils/`: Useful tools | ||
- `scripts/`: Setup machine; run experiments | ||
- `microbench/`: Microbenchmarks and prototypes | ||
- `paper_results/`: Experimental results in the paper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
add_executable(hello hello.c) | ||
target_link_libraries(hello skyloft) | ||
|
||
add_executable(bench bench.c) | ||
target_link_libraries(bench skyloft) | ||
|
||
add_executable(bench_app_switch bench_app_switch.c) | ||
target_link_libraries(bench_app_switch skyloft) | ||
|
||
add_executable(bench_pthread bench_pthread.c) | ||
target_link_libraries(bench_pthread pthread utils) | ||
|
||
add_executable(hello_shim hello_shim.c) | ||
target_link_libraries(hello_shim PRIVATE shim) | ||
set_target_properties(hello_shim PROPERTIES LINK_FLAGS "-Wl,--wrap=main") | ||
target_include_directories(hello_shim PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../shim/include) | ||
|
||
add_executable(test_timer test_timer.c) | ||
target_link_libraries(test_timer skyloft utils) | ||
|
||
add_executable(test_rcu test_rcu.c) | ||
target_link_libraries(test_rcu skyloft utils) | ||
|
||
add_executable(test_net test_net.c) | ||
target_link_libraries(test_net skyloft utils) | ||
|
||
if(DPDK) | ||
add_executable(fakework fakework.c) | ||
target_link_libraries(fakework skyloft utils) | ||
|
||
include(${CMAKE_SCRIPTS}/rocksdb.mk) | ||
add_custom_target( | ||
rocksdb_server | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb_server | ||
COMMAND make clean && make SKYLOFT_DIR=${CMAKE_CURRENT_BINARY_DIR}/../install ROCKSDB_SRC=${rocksdb_SOURCE_DIR}/ | ||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb_server/rocksdb_server ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rocksdb_server | ||
) | ||
add_dependencies(rocksdb_server librocksdb) | ||
endif() | ||
|
||
add_custom_target( | ||
memcached | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/memcached | ||
COMMAND ./autogen.sh | ||
COMMAND ./configure --with-skyloft=${CMAKE_CURRENT_BINARY_DIR}/../install | ||
COMMAND make clean && make -j | ||
COMMAND cp memcached ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/memcached | ||
) | ||
|
||
add_custom_target( | ||
schbench | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/schbench | ||
COMMAND make clean && make SKYLOFT_DIR=${CMAKE_CURRENT_BINARY_DIR}/../install | ||
COMMAND cp schbench ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/schbench | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include <stdatomic.h> | ||
#include <stdio.h> | ||
|
||
#include <skyloft/task.h> | ||
#include <skyloft/uapi/task.h> | ||
#include <utils/time.h> | ||
|
||
#include "bench_common.h" | ||
|
||
#define ROUNDS 10000000 | ||
#define ROUNDS2 10000 | ||
|
||
static atomic_int counter = 0; | ||
|
||
static void null_fn(void *) | ||
{ | ||
atomic_fetch_add(&counter, 1); | ||
} | ||
|
||
static void thread_yield_fn(void *) | ||
{ | ||
for (int i = 0; i < ROUNDS / 2; ++i) sl_task_yield(); | ||
atomic_fetch_add(&counter, 1); | ||
} | ||
|
||
static void bench_spawn() | ||
{ | ||
for (int i = 0; i < ROUNDS; ++i) { | ||
atomic_store(&counter, 0); | ||
sl_task_spawn(null_fn, NULL, 0); | ||
sl_task_yield(); | ||
} | ||
} | ||
|
||
#ifndef SKYLOFT_SCHED_SQ | ||
static void bench_spawn2() | ||
{ | ||
atomic_store(&counter, 0); | ||
for (int i = 0; i < ROUNDS2; ++i) { | ||
sl_task_spawn(null_fn, NULL, 0); | ||
} | ||
for (int i = 0; i < ROUNDS2; ++i) { | ||
sl_task_yield(); | ||
} | ||
} | ||
#endif | ||
|
||
static void bench_yield() | ||
{ | ||
atomic_store(&counter, 0); | ||
|
||
sl_task_spawn(thread_yield_fn, NULL, 0); | ||
thread_yield_fn(NULL); | ||
|
||
while (atomic_load(&counter) < 2) { | ||
sl_task_yield(); | ||
} | ||
} | ||
|
||
static void bench_task_create() | ||
{ | ||
for (int i = 0; i < ROUNDS2; i++) task_create(null_fn, NULL); | ||
} | ||
|
||
void app_main(void *arg) | ||
{ | ||
bench_one("yield", bench_yield, ROUNDS); | ||
bench_one("spawn", bench_spawn, ROUNDS); | ||
#ifndef SKYLOFT_SCHED_SQ | ||
bench_one("spawn2", bench_spawn2, ROUNDS2); | ||
#endif | ||
bench_one("task_create", bench_task_create, ROUNDS2); | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
printf("Skyloft micro-benchmarks\n"); | ||
sl_libos_start(app_main, NULL); | ||
} |
Oops, something went wrong.