From 5dfa017a76b59b7c0b4bbab91ec9c02db29770f8 Mon Sep 17 00:00:00 2001 From: ClawSeven Date: Tue, 30 Apr 2024 14:59:42 +0800 Subject: [PATCH] [libos] Implement IO_Uring feature config --- .github/workflows/composite_action/prebuild/action.yml | 3 ++- docs/readthedocs/docs/source/occlum_configuration.md | 7 +++++++ etc/template/Occlum.json | 1 + src/libos/src/config.rs | 5 +++++ test/Occlum.json | 1 + tools/gen_internal_conf/src/main.rs | 10 +++++++++- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composite_action/prebuild/action.yml b/.github/workflows/composite_action/prebuild/action.yml index d7e44c3d..0c525352 100644 --- a/.github/workflows/composite_action/prebuild/action.yml +++ b/.github/workflows/composite_action/prebuild/action.yml @@ -18,5 +18,6 @@ runs: docker exec ${{ inputs.container-name }} bash -c "git config --global --add safe.directory /root/occlum/deps/rust-sgx-sdk"; docker exec ${{ inputs.container-name }} bash -c "git config --global --add safe.directory /root/occlum/deps/sefs"; docker exec ${{ inputs.container-name }} bash -c "git config --global --add safe.directory /root/occlum/deps/serde-json-sgx"; - docker exec ${{ inputs.container-name }} bash -c "git config --global --add safe.directory /root/occlum/deps/serde-sgx" + docker exec ${{ inputs.container-name }} bash -c "git config --global --add safe.directory /root/occlum/deps/serde-sgx"; + docker exec ${{ inputs.container-name }} bash -c "git config --global --add safe.directory /root/occlum/deps/io-uring" shell: bash \ No newline at end of file diff --git a/docs/readthedocs/docs/source/occlum_configuration.md b/docs/readthedocs/docs/source/occlum_configuration.md index 654f2963..08df4c3f 100644 --- a/docs/readthedocs/docs/source/occlum_configuration.md +++ b/docs/readthedocs/docs/source/occlum_configuration.md @@ -72,6 +72,13 @@ The template of `Occlum.json` is shown below. }, // Features "feature": { + // Determines the use of the IO_Uring feature in Occlum for network I/O operations. + // Enabling IO_Uring feature can improve network I/O performance. + // + // "io_uring": 0 - Disables IO_Uring; network I/O uses Ocall instead. + // "io_uring": 1 - Enables IO_Uring with a single IO_Uring instance. + // "io_uring": n (1 < n <= 16) - Enables IO_Uring with 'n' IO_Uring instances. + "io_uring": 0, // Whether to turn on AMX feature in Occlum // Occlum supports AMX instruction running inside the enclave when user enables it // diff --git a/etc/template/Occlum.json b/etc/template/Occlum.json index 0b8cc202..e7d82ccd 100644 --- a/etc/template/Occlum.json +++ b/etc/template/Occlum.json @@ -38,6 +38,7 @@ "feature": { "amx": 0, "pkru": 0, + "io_uring": 0, "enable_edmm": false, "enable_posix_shm": false }, diff --git a/src/libos/src/config.rs b/src/libos/src/config.rs index ecf82cd2..38b32ff5 100644 --- a/src/libos/src/config.rs +++ b/src/libos/src/config.rs @@ -148,6 +148,7 @@ pub struct ConfigApp { pub struct ConfigFeature { pub amx: u32, pub pkru: u32, + pub io_uring: u32, pub enable_edmm: bool, pub enable_posix_shm: bool, } @@ -307,6 +308,7 @@ impl ConfigFeature { Ok(ConfigFeature { amx: input.amx, pkru: input.pkru, + io_uring: input.io_uring, enable_edmm: input.enable_edmm, enable_posix_shm: input.enable_posix_shm, }) @@ -538,6 +540,8 @@ struct InputConfigFeature { #[serde(default)] pub pkru: u32, #[serde(default)] + pub io_uring: u32, + #[serde(default)] pub enable_edmm: bool, #[serde(default)] pub enable_posix_shm: bool, @@ -548,6 +552,7 @@ impl Default for InputConfigFeature { InputConfigFeature { amx: 0, pkru: 0, + io_uring: 0, enable_edmm: false, enable_posix_shm: false, } diff --git a/test/Occlum.json b/test/Occlum.json index 9459fb20..5f120799 100644 --- a/test/Occlum.json +++ b/test/Occlum.json @@ -44,6 +44,7 @@ "feature": { "amx": 0, "pkru": 0, + "io_uring": 0, "enable_edmm": false, "enable_posix_shm": true }, diff --git a/tools/gen_internal_conf/src/main.rs b/tools/gen_internal_conf/src/main.rs index c35a136d..92b82ca2 100644 --- a/tools/gen_internal_conf/src/main.rs +++ b/tools/gen_internal_conf/src/main.rs @@ -160,6 +160,12 @@ fn main() { "WITHOUT" } ); + + debug!( + "Enable IO_Uring feature with {:?} instances", + occlum_config.feature.io_uring + ); + debug!( "user config init num of threads = {:?}", occlum_config.resource_limits.init_num_of_threads @@ -448,7 +454,7 @@ fn main() { TCSNum: tcs_init_num, TCSMinPool: tcs_min_pool, TCSMaxNum: tcs_max_num, - TCSPolicy: 1, + TCSPolicy: 0, DisableDebug: match occlum_config.metadata.debuggable { true => 0, false => 1, @@ -758,6 +764,8 @@ struct OcclumFeature { #[serde(default)] pkru: u32, #[serde(default)] + io_uring: u32, + #[serde(default)] enable_edmm: bool, #[serde(default)] enable_posix_shm: bool,