From 95e243a68b20e4efb669451ebc0ab1d129dfa80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Wed, 6 Aug 2025 13:30:09 +0000 Subject: [PATCH 01/17] update services/flow_update/update_bin/bin_process.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/flow_update/update_bin/bin_process.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/flow_update/update_bin/bin_process.cpp b/services/flow_update/update_bin/bin_process.cpp index 18cbf402..53f4c997 100644 --- a/services/flow_update/update_bin/bin_process.cpp +++ b/services/flow_update/update_bin/bin_process.cpp @@ -33,6 +33,9 @@ using namespace Hpackage; using namespace Uscript; namespace Updater { +using Updater::Utils::GetAllTids; +using Updater::Utils::VectorToString; + constexpr uint32_t STASH_BUFFER_SIZE = 4 * 1024 * 1024; constexpr uint32_t MAX_BUFFER_NUM = 16; constexpr uint8_t ES_IMAGE = 6; @@ -232,7 +235,9 @@ int32_t UScriptInstructionBinFlowWrite::ProcessBinFile(Uscript::UScriptEnv &env, LOG(ERROR) << "Error to load flow data stream"; return USCRIPT_ERROR_EXECUTE; } - + LOG(INFO) << "Get binary tids"; + std::vector tids = GetAllTids(getpid()); + env.PostMessage("set_binary_tids", VectorToString(tids)); for (const auto &iter : innerFileNames) { // 根据镜像名称获取分区名称和大小 std::string partitionName = iter; -- Gitee From f5447aef306b7600a1d83e2abbc3a2c071c97275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Wed, 6 Aug 2025 13:31:16 +0000 Subject: [PATCH 02/17] update services/include/updater/updater.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/include/updater/updater.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/include/updater/updater.h b/services/include/updater/updater.h index 0e8f4f66..63230c1c 100644 --- a/services/include/updater/updater.h +++ b/services/include/updater/updater.h @@ -146,10 +146,10 @@ std::vector &GetBootModes(void); std::optional SelectMode(const UpdateMessage &boot); -std::vector GetAllTids(pid_t pid); - bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores); void ReduceLoad(const UpdaterParams &upParams); + +void SetBinaryTids(const std::vector &output, UpdaterParams &upParams) } // Updater #endif /* UPDATER_UPDATER_H */ -- Gitee From 0c0831e2e2b3fd232c44d132eeb27fda8f88bd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Wed, 6 Aug 2025 13:32:14 +0000 Subject: [PATCH 03/17] update services/updater.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/updater.cpp b/services/updater.cpp index 11f71017..5b0b8d7c 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -551,6 +551,8 @@ void HandleChildOutput(const std::string &buffer, int32_t bufferLen, bool &retry } } else if (outputHeader == "set_progress") { SetProgress(output, upParams); + } else if (outputHeader == "set_binary_tids") { + SetBinaryTids(output, upParams); } else { LOG(WARNING) << "Child process returns unexpected message."; } @@ -736,7 +738,6 @@ UpdaterStatus StartUpdaterProc(PkgManager::PkgManagerPtr pkgManager, UpdaterPara } upParams.binaryPid = pid; - ReduceLoad(upParams); close(pipeWrite); // close write endpoint bool retryUpdate = false; if (HandlePipeMsg(upParams, pipeRead, retryUpdate) != UPDATE_SUCCESS) { -- Gitee From a3370c80aa7752a4aa2d8297b63abdc911c0ff8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Wed, 6 Aug 2025 13:35:36 +0000 Subject: [PATCH 04/17] update services/updater_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater_utils.cpp | 65 ++++++++++++++------------------------ 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index ec17c43d..77d37499 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -13,8 +13,6 @@ * limitations under the License. */ #include -#include -#include #include #include #include @@ -41,6 +39,8 @@ namespace Updater { using namespace Hpackage; using namespace Updater::Utils; +std::vector g_binaryTids; + void DeleteInstallTimeFile() { const std::string installTimeFilePath = std::string(UPDATER_PATH) + "/" + std::string(INSTALL_TIME_FILE); @@ -293,43 +293,11 @@ std::optional SelectMode(const UpdateMessage &boot) return *it; } -std::vector GetAllTids(pid_t pid) -{ - std::vector tids; - std::string pathName = std::string("/proc/").append(std::to_string(pid)).append("/task"); - char tmpPath[PATH_MAX + 1] = {0}; - if (realpath(pathName.c_str(), tmpPath) == nullptr || tmpPath[0] == '\0') { - LOG(ERROR) << "realpath fail pathName:" << pathName; - return tids; - } - DIR *dir = opendir(tmpPath); - if (dir == nullptr) { - LOG(ERROR) << "opendir fail pathName:" << pathName; - return tids; - } - struct dirent *de = nullptr; - while ((de = readdir(dir)) != nullptr) { - if (!(de->d_type & DT_DIR) || !isdigit(de->d_name[0])) { - continue; - } - int32_t temp = -1; - if (!Utils::ConvertToLong(de->d_name, temp)) { - LOG(ERROR) << "ConvertToLong failed"; - continue; - } - pid_t tid = static_cast(temp); - if (tid > 0) { - tids.push_back(tid); - } - } - closedir(dir); - return tids; -} - bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores) { LOG(INFO) << "SetCpuAffinityByPid binaryPid:" << binaryPid; - if (binaryPid == -1) { + if (binaryPid == -1 || std::find( + g_binaryTids.begin(), g_binaryTids.end(), std::to_string(binaryPid)) == g_binaryTids.end()) { LOG(WARNING) << "invalid binaryPid:" << binaryPid; return false; } @@ -344,13 +312,14 @@ bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores) for (unsigned int i = 0; i < coreCount - reservedCores; i++) { CPU_SET(i, &mask); } - std::vector tids = GetAllTids(binaryPid); - if (tids.empty()) { - LOG(WARNING) << "set affinity faild, tids is null"; - return false; - } int syscallRes; - for (auto& tid : tids) { + for (auto& str : g_binaryTids) { + int32_t temp = -1; + if (!Utils::ConvertToLong(str, temp)) { + LOG(ERROR) << "ConvertToLong failed"; + continue; + } + pid_t tid = static_cast(temp); syscallRes = syscall(__NR_sched_setaffinity, tid, sizeof(mask), &mask); LOG(INFO) << "setaffinity tid:" << tid; if (syscallRes != 0) { @@ -368,4 +337,16 @@ void ReduceLoad(const UpdaterParams &upParams) SetCpuAffinityByPid(upParams.binaryPid, reservedCores); } } + +void SetBinaryTids(const std::vector &output, UpdaterParams &upParams) +{ + if (output.size() < DEFAULT_PROCESS_NUM) { + LOG(ERROR) << "check output fail"; + return; + } + auto outputInfo = Trim(output[1]); + LOG(INFO) << "binary tids:" << outputInfo; + g_binaryTids = SplitString(outputInfo, ","); + ReduceLoad(upParams); +} } // namespace Updater -- Gitee From f68326840dfd10e51788d2331258c683b9d3f9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Wed, 6 Aug 2025 13:36:38 +0000 Subject: [PATCH 05/17] update utils/include/utils.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- utils/include/utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/include/utils.h b/utils/include/utils.h index c8f93d68..07fe7578 100644 --- a/utils/include/utils.h +++ b/utils/include/utils.h @@ -121,6 +121,8 @@ bool SetUpdateSuffix(std::string stringsuffix); int GetUpdateSlot(); std::string GetUpdateSuffix(); std::string GetUpdateActiveSuffix(); +std::vector GetAllTids(pid_t pid); +std::string VectorToString(const std::vector &pids); #ifndef __WIN32 void SetFileAttributes(const std::string& file, uid_t owner, gid_t group, mode_t mode); #endif -- Gitee From 0668a22c0be31fc8aea11083cc71a590d5116a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Wed, 6 Aug 2025 13:39:18 +0000 Subject: [PATCH 06/17] update utils/utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- utils/utils.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/utils/utils.cpp b/utils/utils.cpp index da4a4167..981ad9bf 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -1179,6 +1179,54 @@ std::string GetUpdateActiveSuffix() return std::string(paramValue); } +std::vector GetAllTids(pid_t pid) +{ + std::vector tids; + tids.push_back(pid); + std::string pathName = std::string("/proc/").append(std::to_string(pid)).append("/task"); + char tmpPath[PATH_MAX + 1] = {0}; + if (realpath(pathName.c_str(), tmpPath) == nullptr || tmpPath[0] == '\0') { + LOG(ERROR) << "realpath fail pathName:" << pathName; + return tids; + } + DIR *dir = opendir(tmpPath); + if (dir == nullptr) { + LOG(ERROR) << "opendir fail pathName:" << pathName; + return tids; + } + struct dirent *de = nullptr; + while ((de = readdir(dir)) != nullptr) { + if (!(de->d_type & DT_DIR) || !isdigit(de->d_name[0])) { + continue; + } + int32_t temp = -1; + if (!Utils::ConvertToLong(de->d_name, temp)) { + LOG(ERROR) << "ConvertToLong failed"; + continue; + } + pid_t tid = static_cast(temp); + if (tid > 0) { + tids.push_back(tid); + } + } + closedir(dir); + return tids; +} + +std::string VectorToString(const std::vector &pids) +{ + if (pids.empty()) { + return ""; + } + std::ostringstream oss; + auto it = pids.begin(); + oss << *it++; + while (it != pids.end()) { + oss << "," << *it++; + } + return oss.str(); +} + #ifndef __WIN32 void SetFileAttributes(const std::string& file, uid_t owner, gid_t group, mode_t mode) { -- Gitee From dfb4d7b9460055148b9ba2e52e60d93ff9bbb99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 00:57:27 +0000 Subject: [PATCH 07/17] update services/include/updater/updater.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/include/updater/updater.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/include/updater/updater.h b/services/include/updater/updater.h index 63230c1c..33b97fd1 100644 --- a/services/include/updater/updater.h +++ b/services/include/updater/updater.h @@ -150,6 +150,6 @@ bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores); void ReduceLoad(const UpdaterParams &upParams); -void SetBinaryTids(const std::vector &output, UpdaterParams &upParams) +void SetBinaryTids(const std::vector &output, UpdaterParams &upParams); } // Updater #endif /* UPDATER_UPDATER_H */ -- Gitee From 0f3de580ce2d505097d7b890c1a33238fa48fdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 06:52:30 +0000 Subject: [PATCH 08/17] update services/include/updater/updater.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/include/updater/updater.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/include/updater/updater.h b/services/include/updater/updater.h index 33b97fd1..8af7dd52 100644 --- a/services/include/updater/updater.h +++ b/services/include/updater/updater.h @@ -73,6 +73,7 @@ struct UpdaterParams { std::vector updatePackage {}; std::vector> installTime {}; std::function callbackProgress {}; + std::vector binaryTids {}; }; using CondFunc = std::function; @@ -146,10 +147,8 @@ std::vector &GetBootModes(void); std::optional SelectMode(const UpdateMessage &boot); -bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores); +bool SetCpuAffinityByPid(const UpdaterParams &upParams, unsigned int reservedCores); -void ReduceLoad(const UpdaterParams &upParams); - -void SetBinaryTids(const std::vector &output, UpdaterParams &upParams); +void UpdateBinaryTids(const std::vector &output, UpdaterParams &upParams); } // Updater #endif /* UPDATER_UPDATER_H */ -- Gitee From 0ac049b9b6418beb4f4fc2e84e91c8f0db4b62df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 06:56:27 +0000 Subject: [PATCH 09/17] update services/updater_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater_utils.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index 77d37499..ea646f53 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -293,12 +293,12 @@ std::optional SelectMode(const UpdateMessage &boot) return *it; } -bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores) +bool SetCpuAffinityByPid(const UpdaterParams &upParams, unsigned int reservedCores) { - LOG(INFO) << "SetCpuAffinityByPid binaryPid:" << binaryPid; - if (binaryPid == -1 || std::find( - g_binaryTids.begin(), g_binaryTids.end(), std::to_string(binaryPid)) == g_binaryTids.end()) { - LOG(WARNING) << "invalid binaryPid:" << binaryPid; + std::vector binaryTids = upParams.binaryTids; + if (upParams.binaryPid == -1 || std::find( + binaryTids.begin(), binaryTids.end(), std::to_string(upParams.binaryPid)) == binaryTids.end()) { + LOG(WARNING) << "invalid binaryPid:" << upParams.binaryPid; return false; } unsigned int coreCount = std::thread::hardware_concurrency(); @@ -313,7 +313,7 @@ bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores) CPU_SET(i, &mask); } int syscallRes; - for (auto& str : g_binaryTids) { + for (auto& str : binaryTids) { int32_t temp = -1; if (!Utils::ConvertToLong(str, temp)) { LOG(ERROR) << "ConvertToLong failed"; @@ -329,16 +329,7 @@ bool SetCpuAffinityByPid(pid_t binaryPid, unsigned int reservedCores) return true; } -void ReduceLoad(const UpdaterParams &upParams) -{ - if (upParams.isLoadReduction) { - unsigned int coreCount = std::thread::hardware_concurrency(); - unsigned int reservedCores = coreCount - LITTLE_CPU_CORES; - SetCpuAffinityByPid(upParams.binaryPid, reservedCores); - } -} - -void SetBinaryTids(const std::vector &output, UpdaterParams &upParams) +void UpdateBinaryTids(const std::vector &output, UpdaterParams &upParams) { if (output.size() < DEFAULT_PROCESS_NUM) { LOG(ERROR) << "check output fail"; @@ -346,7 +337,11 @@ void SetBinaryTids(const std::vector &output, UpdaterParams &upPara } auto outputInfo = Trim(output[1]); LOG(INFO) << "binary tids:" << outputInfo; - g_binaryTids = SplitString(outputInfo, ","); - ReduceLoad(upParams); + upParams.binaryTids = SplitString(outputInfo, ","); + if (upParams.isLoadReduction) { + unsigned int coreCount = std::thread::hardware_concurrency(); + unsigned int reservedCores = coreCount - LITTLE_CPU_CORES; + SetCpuAffinityByPid(upParams, reservedCores); + } } } // namespace Updater -- Gitee From c043e3b00037ed6fb3db85daaa64ef97621824ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 06:59:29 +0000 Subject: [PATCH 10/17] update services/updater.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/updater.cpp b/services/updater.cpp index 5b0b8d7c..f7c7d97c 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -552,7 +552,7 @@ void HandleChildOutput(const std::string &buffer, int32_t bufferLen, bool &retry } else if (outputHeader == "set_progress") { SetProgress(output, upParams); } else if (outputHeader == "set_binary_tids") { - SetBinaryTids(output, upParams); + UpdateBinaryTids(output, upParams); } else { LOG(WARNING) << "Child process returns unexpected message."; } -- Gitee From 575bcfcbb46a0d8b48245e50a3e0c93bc8ca52e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 07:00:53 +0000 Subject: [PATCH 11/17] update services/updater_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater_utils.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index ea646f53..7c6de9e9 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -39,8 +39,6 @@ namespace Updater { using namespace Hpackage; using namespace Updater::Utils; -std::vector g_binaryTids; - void DeleteInstallTimeFile() { const std::string installTimeFilePath = std::string(UPDATER_PATH) + "/" + std::string(INSTALL_TIME_FILE); -- Gitee From e5cb35d0078e60a077ed4e8dc435487fda234053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 08:14:09 +0000 Subject: [PATCH 12/17] update services/flow_update/update_bin/bin_process.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/flow_update/update_bin/bin_process.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/flow_update/update_bin/bin_process.cpp b/services/flow_update/update_bin/bin_process.cpp index 53f4c997..b42c6e33 100644 --- a/services/flow_update/update_bin/bin_process.cpp +++ b/services/flow_update/update_bin/bin_process.cpp @@ -31,11 +31,9 @@ using namespace std; using namespace Hpackage; using namespace Uscript; +using namespace Utils; namespace Updater { -using Updater::Utils::GetAllTids; -using Updater::Utils::VectorToString; - constexpr uint32_t STASH_BUFFER_SIZE = 4 * 1024 * 1024; constexpr uint32_t MAX_BUFFER_NUM = 16; constexpr uint8_t ES_IMAGE = 6; -- Gitee From ffb5d9658d5fc6b7373053051515aba988dea4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 08:16:40 +0000 Subject: [PATCH 13/17] update services/updater_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index 7c6de9e9..46942523 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -311,10 +311,10 @@ bool SetCpuAffinityByPid(const UpdaterParams &upParams, unsigned int reservedCor CPU_SET(i, &mask); } int syscallRes; - for (auto& str : binaryTids) { + for (auto &str : binaryTids) { int32_t temp = -1; if (!Utils::ConvertToLong(str, temp)) { - LOG(ERROR) << "ConvertToLong failed"; + LOG(ERROR) << "ConvertToLong failed:" << str; continue; } pid_t tid = static_cast(temp); -- Gitee From 5eba1b555db5e95e3e3c791fe393c4172a5f66f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 12:24:31 +0000 Subject: [PATCH 14/17] update services/flow_update/update_bin/bin_process.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/flow_update/update_bin/bin_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/flow_update/update_bin/bin_process.cpp b/services/flow_update/update_bin/bin_process.cpp index b42c6e33..78526993 100644 --- a/services/flow_update/update_bin/bin_process.cpp +++ b/services/flow_update/update_bin/bin_process.cpp @@ -31,7 +31,7 @@ using namespace std; using namespace Hpackage; using namespace Uscript; -using namespace Utils; +using namespace Updater::Utils; namespace Updater { constexpr uint32_t STASH_BUFFER_SIZE = 4 * 1024 * 1024; -- Gitee From ffbd280e5b073c1bcc678ea6dca42749e3a77a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 12:29:47 +0000 Subject: [PATCH 15/17] update services/updater_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater_utils.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index 46942523..8774401c 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -39,6 +39,8 @@ namespace Updater { using namespace Hpackage; using namespace Updater::Utils; +std::mutex setAffinityLock_; + void DeleteInstallTimeFile() { const std::string installTimeFilePath = std::string(UPDATER_PATH) + "/" + std::string(INSTALL_TIME_FILE); @@ -293,6 +295,7 @@ std::optional SelectMode(const UpdateMessage &boot) bool SetCpuAffinityByPid(const UpdaterParams &upParams, unsigned int reservedCores) { + std::lock_guard lock(setAffinityLock_); std::vector binaryTids = upParams.binaryTids; if (upParams.binaryPid == -1 || std::find( binaryTids.begin(), binaryTids.end(), std::to_string(upParams.binaryPid)) == binaryTids.end()) { -- Gitee From 5a77030d884df2889b40e7e22132ef0317e866a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Thu, 7 Aug 2025 13:29:37 +0000 Subject: [PATCH 16/17] update services/updater_binary/update_image_block.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater_binary/update_image_block.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/updater_binary/update_image_block.cpp b/services/updater_binary/update_image_block.cpp index a37187bf..4f09e7c2 100644 --- a/services/updater_binary/update_image_block.cpp +++ b/services/updater_binary/update_image_block.cpp @@ -35,6 +35,7 @@ using namespace Uscript; using namespace Hpackage; using namespace Updater; +using namespace Updater::Utils; namespace Updater { constexpr int32_t SHA_CHECK_SECOND = 2; @@ -426,7 +427,8 @@ static int32_t ExecuteUpdateBlock(Uscript::UScriptEnv &env, Uscript::UScriptCont env.GetPkgManager()->ClosePkgStream(outStream); return USCRIPT_ERROR_EXECUTE; } - + std::vector tids = GetAllTids(getpid()); + env.PostMessage("set_binary_tids", VectorToString(tids)); return DoExecuteUpdateBlock(infos, tm.get(), outStream, lines, context); } -- Gitee From 867b103ad8d39f350711487aeb92ccb9fce4fd52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=BA?= Date: Fri, 8 Aug 2025 02:47:28 +0000 Subject: [PATCH 17/17] update services/updater_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张强 --- services/updater_utils.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index 8774401c..f23e8ef3 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -39,8 +39,6 @@ namespace Updater { using namespace Hpackage; using namespace Updater::Utils; -std::mutex setAffinityLock_; - void DeleteInstallTimeFile() { const std::string installTimeFilePath = std::string(UPDATER_PATH) + "/" + std::string(INSTALL_TIME_FILE); @@ -295,7 +293,8 @@ std::optional SelectMode(const UpdateMessage &boot) bool SetCpuAffinityByPid(const UpdaterParams &upParams, unsigned int reservedCores) { - std::lock_guard lock(setAffinityLock_); + static std::mutex setAffinityLock; + std::lock_guard lock(setAffinityLock); std::vector binaryTids = upParams.binaryTids; if (upParams.binaryPid == -1 || std::find( binaryTids.begin(), binaryTids.end(), std::to_string(upParams.binaryPid)) == binaryTids.end()) { -- Gitee