From 4a3ba5e5346e9712df8abc58d7566c43bfe3c67d Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 5 Sep 2024 07:39:42 +0900 Subject: [PATCH] Apply CPU inheritance to aul window functions To improve IPC performance, this patch applies the CPU inheritance feature to aul window codes. Change-Id: I863d8ca4caafdcfd0b76046f1b902666eb1cd76f Signed-off-by: Hwankyu Jhun --- src/aul/aul_window.cc | 4 ++++ src/aul/cpu_inheritance.cc | 23 +++++++++++++++-------- src/aul/cpu_inheritance.hh | 4 ++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/aul/aul_window.cc b/src/aul/aul_window.cc index 4b0f720..2bd4705 100644 --- a/src/aul/aul_window.cc +++ b/src/aul/aul_window.cc @@ -29,6 +29,7 @@ #include "aul/app_request.h" #include "aul/aul_api.h" #include "aul/aul_util.h" +#include "aul/cpu_inheritance.hh" #include "aul/include/aul.h" #include "aul/include/aul_app_com.h" #include "aul/include/aul_cmd.h" @@ -45,6 +46,7 @@ constexpr const char kWmInterfaceName[] = "org.enlightenment.wm.proc"; constexpr const char kWmMethodNameInfo[] = "GetVisibleWinInfo"; constexpr const char kWmMethodNameFocus[] = "GetFocusProc"; constexpr const unsigned int kWmDbusTimeout = 5000; +constexpr const char kDestProcess[] = "enlightenment"; GDBusConnection* system_conn; @@ -227,6 +229,7 @@ extern "C" API int aul_window_stack_get(aul_window_stack_h* handle) { return AUL_R_EINVAL; } + CPUInheritance inheritance(kDestProcess); GDBusConnection* conn = GetConn(); if (conn == nullptr) return AUL_R_ERROR; @@ -471,6 +474,7 @@ extern "C" API int aul_window_get_focused_pid(pid_t* pid) { return AUL_R_EINVAL; } + CPUInheritance inheritance(kDestProcess); GDBusConnection* conn = GetConn(); if (conn == nullptr) return AUL_R_ERROR; diff --git a/src/aul/cpu_inheritance.cc b/src/aul/cpu_inheritance.cc index 1a7b6b2..1572392 100644 --- a/src/aul/cpu_inheritance.cc +++ b/src/aul/cpu_inheritance.cc @@ -29,10 +29,19 @@ constexpr const char DEST_PROCESS[] = "amd"; } // namespace -CPUInheritance::CPUInheritance(pid_t pid, int cmd) { +CPUInheritance::CPUInheritance(std::string destination) + : destination_(std::move(destination)) { + int ret = resource_set_cpu_inheritance(gettid(), destination_.c_str(), -1); + if (ret != 0) + _E("resource_set_cpu_inheritance() is failed. error(%d)", ret); + else + inherited_ = true; +} + +CPUInheritance::CPUInheritance(pid_t pid, int cmd) + : destination_(DEST_PROCESS) { if (pid == -2 && IsLaunchRequest(cmd)) { - int ret = resource_set_cpu_inheritance(gettid(), - const_cast(DEST_PROCESS), -1); + int ret = resource_set_cpu_inheritance(gettid(), destination_.c_str(), -1); if (ret != 0) _E("resource_set_cpu_inheritance() is failed. error(%d)", ret); else @@ -40,9 +49,8 @@ CPUInheritance::CPUInheritance(pid_t pid, int cmd) { } } -CPUInheritance::CPUInheritance() { - int ret = resource_set_cpu_inheritance(gettid(), - const_cast(DEST_PROCESS), -1); +CPUInheritance::CPUInheritance() : destination_(DEST_PROCESS) { + int ret = resource_set_cpu_inheritance(gettid(), destination_.c_str(), -1); if (ret != 0) _E("resource_set_cpu_inheritance() is failed. error(%d)", ret); else @@ -51,8 +59,7 @@ CPUInheritance::CPUInheritance() { CPUInheritance::~CPUInheritance() { if (inherited_) { - int ret = resource_clear_cpu_inheritance(gettid(), - const_cast(DEST_PROCESS)); + int ret = resource_clear_cpu_inheritance(gettid(), destination_.c_str()); if (ret != 0) _E("resource_clear_cpu_inheritance() is failed. error(%d)", ret); } diff --git a/src/aul/cpu_inheritance.hh b/src/aul/cpu_inheritance.hh index e25c8c7..4085927 100644 --- a/src/aul/cpu_inheritance.hh +++ b/src/aul/cpu_inheritance.hh @@ -19,11 +19,14 @@ #include +#include + namespace aul { namespace internal { class CPUInheritance { public: + explicit CPUInheritance(std::string destination); CPUInheritance(pid_t pid, int cmd); CPUInheritance(); ~CPUInheritance(); @@ -32,6 +35,7 @@ class CPUInheritance { static bool IsLaunchRequest(int cmd); private: + std::string destination_; bool inherited_ = false; }; -- 2.7.4