From ee0ff86d2536f5a4997820378f22e74d07becf9a Mon Sep 17 00:00:00 2001 From: zhengxiaoxiao Date: Thu, 15 Aug 2024 22:15:52 +0800 Subject: [PATCH] support CPU core binding --- 0077-support-CPU-core-binding.patch | 67 +++++++++++++++++++++++++++++ secGear.spec | 6 ++- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 0077-support-CPU-core-binding.patch diff --git a/0077-support-CPU-core-binding.patch b/0077-support-CPU-core-binding.patch new file mode 100644 index 0000000..e820585 --- /dev/null +++ b/0077-support-CPU-core-binding.patch @@ -0,0 +1,67 @@ +From 3beeb13f9040b0c78aa5f246bedfa4d5475787ae Mon Sep 17 00:00:00 2001 +From: zhengxiaoxiao +Date: Tue, 13 Aug 2024 20:43:31 +0800 +Subject: [PATCH] support CPU core binding + +--- + inc/host_inc/secgear_uswitchless.h | 7 ++++++- + src/enclave_src/gp/itrustee/CMakeLists.txt | 2 ++ + src/enclave_src/gp/itrustee/itrustee_tswitchless.c | 1 + + 3 files changed, 9 insertions(+), 1 deletion(-) + +diff --git a/inc/host_inc/secgear_uswitchless.h b/inc/host_inc/secgear_uswitchless.h +index 2ea4691..b7c68d5 100644 +--- a/inc/host_inc/secgear_uswitchless.h ++++ b/inc/host_inc/secgear_uswitchless.h +@@ -41,7 +41,9 @@ + #ifndef SECGEAR_USWITCHLESS_H + #define SECGEAR_USWITCHLESS_H + ++#include + #include ++#include + + #ifdef __cplusplus + extern "C" { +@@ -85,9 +87,12 @@ typedef struct { + + /* Indicates whether to roll back to common invoking when asynchronous switchless invoking fails, only for GP */ + uint32_t rollback_to_common; ++ ++ /* Specifies the name of the bound core. */ ++ cpu_set_t tworkers_cores; + } cc_sl_config_t; + +-#define CC_USWITCHLESS_CONFIG_INITIALIZER {1, 1, 1, 16, 0, 0, WORKERS_POLICY_BUSY, 0} ++#define CC_USWITCHLESS_CONFIG_INITIALIZER {1, 1, 1, 16, 0, 0, WORKERS_POLICY_BUSY, 0, {{0}} } + + #ifdef __cplusplus + } +diff --git a/src/enclave_src/gp/itrustee/CMakeLists.txt b/src/enclave_src/gp/itrustee/CMakeLists.txt +index 14b3c64..c44fc38 100644 +--- a/src/enclave_src/gp/itrustee/CMakeLists.txt ++++ b/src/enclave_src/gp/itrustee/CMakeLists.txt +@@ -19,6 +19,8 @@ set(SOURCE_FILES ${SOURCE_FILES} ../gp.c ../gp_ocall.c itrustee_seal_data.c erro + set(ITRUSTEE_TEEDIR ${SDK_PATH}/) + set(ITRUSTEE_LIBC ${SDK_PATH}/thirdparty/open_source/musl/libc) + ++add_definitions(-D_GNU_SOURCE) ++ + if (CMAKE_COMPILER_IS_GNUCC) + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpfullversion -dumpversion + OUTPUT_VARIABLE GCC_VERSION) +diff --git a/src/enclave_src/gp/itrustee/itrustee_tswitchless.c b/src/enclave_src/gp/itrustee/itrustee_tswitchless.c +index 3955ff9..4048507 100644 +--- a/src/enclave_src/gp/itrustee/itrustee_tswitchless.c ++++ b/src/enclave_src/gp/itrustee/itrustee_tswitchless.c +@@ -342,6 +342,7 @@ static pthread_t *tswitchless_init_workers(sl_task_pool_t *pool) + SLogError("Create tee thread failed, index:%u, ret:%d.", i, ret); + return NULL; + } ++ pthread_setaffinity_np(tids[i], sizeof(pool_cfg->tworkers_cores), &(pool_cfg->tworkers_cores)); + } + + CC_THREAD_ATTR_DESTROY(&attr); +-- +2.27.0 + diff --git a/secGear.spec b/secGear.spec index cc8cea2..0fbc512 100644 --- a/secGear.spec +++ b/secGear.spec @@ -1,6 +1,6 @@ Name: secGear Version: 0.1.0 -Release: 40 +Release: 41 Summary: secGear is an SDK to develop confidential computing apps based on hardware enclave features @@ -85,6 +85,7 @@ Patch72: 0073-memset-no-optimize.patch Patch73: 0074-add-codegen-compile-marco.patch Patch74: 0075-Correct-the-error-in-the-comment.patch Patch75: 0076-change-log-file-permission-0400.patch +Patch76: 0077-support-CPU-core-binding.patch BuildRequires: gcc python automake autoconf libtool @@ -217,6 +218,9 @@ popd systemctl restart rsyslog %changelog +* Thu Aug 15 2024 zhengxiaoxiao - 0.1.0-41 +- support CPU core binding + * Thu Jun 20 2024 houmingyong - 0.1.0-40 - synchoronous features -- Gitee