support CPU core binding

(cherry picked from commit ee0ff86d2536f5a4997820378f22e74d07becf9a)
This commit is contained in:
zhengxiaoxiao 2024-08-15 22:15:52 +08:00 committed by openeuler-sync-bot
parent e007b0de4b
commit 347292f02c
2 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,67 @@
From 3beeb13f9040b0c78aa5f246bedfa4d5475787ae Mon Sep 17 00:00:00 2001
From: zhengxiaoxiao <zhengxiaoxiao2@huawei.com>
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 <sched.h>
#include <stdint.h>
+#include <stdbool.h>
#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

View File

@ -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 <zhengxiaoxiao2@huawei.com> - 0.1.0-41
- support CPU core binding
* Thu Jun 20 2024 houmingyong <houmingyong@huawei.com> - 0.1.0-40
- synchoronous features