Apply cpu boosting 20/292020/2
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 26 Apr 2023 07:57:28 +0000 (16:57 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 26 Apr 2023 08:04:02 +0000 (17:04 +0900)
This patch applies cpu boosting while calling __before_loop()

Change-Id: I1dbe82f54c443ae07eb6388c4f162824708c5476
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
CMakeLists.txt
packaging/launchpad.spec
src/launchpad-process-pool/CMakeLists.txt
src/launchpad-process-pool/src/launchpad.c

index 69ff6644e16a66da6c0f5ae869283cec2d124a14..5e5b954338c0c1812ec62c634f841f857d6dda50 100644 (file)
@@ -68,5 +68,6 @@ PKG_CHECK_MODULES(SECURITY_MANAGER_DEPS REQUIRED security-manager)
 PKG_CHECK_MODULES(TANCHOR_DEPS REQUIRED tanchor)
 PKG_CHECK_MODULES(TTRACE_DEPS REQUIRED ttrace)
 PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf)
+PKG_CHECK_MODULES(SYSTEM_RESOURCE_DEPS REQUIRED capi-system-resource)
 
 ADD_SUBDIRECTORY(src)
index aa5de8ef42bdebe6a02f9fe0d4159c1567d68639..57edcd0324968d54b2139fb40b918b16787d1095 100644 (file)
@@ -33,6 +33,7 @@ BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  pkgconfig(pkgmgr-installer)
+BuildRequires:  pkgconfig(capi-system-resource)
 
 Requires(post): /sbin/ldconfig
 Requires(post): /usr/bin/systemctl
@@ -199,4 +200,3 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ
 %{_libdir}/*.so
 %{_libdir}/pkgconfig/liblaunchpad.pc
 %{_libdir}/pkgconfig/liblaunchpad-hydra.pc
-
index b0af4fe93247313da2db0b6744568a99e88a88c1..b5de3141cc7729bd6dcffa1badecb948b68814a4 100644 (file)
@@ -39,6 +39,7 @@ APPLY_PKG_CONFIG(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC
   TANCHOR_DEPS
   TTRACE_DEPS
   VCONF_DEPS
+  SYSTEM_RESOURCE_DEPS
 )
 
 TARGET_LINK_LIBRARIES(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC "-lm -ldl")
index 5d1e66a06bd503ed0982864e8861843710daa0b9..9083b207f4443a89bc14ef3e0a42b55b6d56a1cd 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #define _GNU_SOURCE
+#include <cpu-boosting.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -3628,6 +3629,39 @@ static void __after_loop(void)
        __sequencer_fini();
 }
 
+static void __set_cpu_boosting()
+{
+       pid_t pid = getpid();
+       resource_pid_t res_pid = {
+               .pid = 0,
+               .tid = &pid,
+               .tid_count = 1,
+       };
+
+       int ret = resource_set_cpu_boosting(res_pid, CPU_BOOSTING_LEVEL_MEDIUM,
+                       CPU_BOOSTING_RESET_ON_FORK, 5000);
+       if (ret != 0)
+               _E("Failed to set cpu boosting, %d", ret);
+       else
+               _D("Successfully set cpu boosting");
+}
+
+static void __unset_cpu_boosting()
+{
+       pid_t pid = getpid();
+       resource_pid_t res_pid = {
+               .pid = 0,
+               .tid = &pid,
+               .tid_count = 1,
+       };
+
+       int ret = resource_clear_cpu_boosting(res_pid);
+       if (ret != 0)
+               _E("Failed to unset cpu boosting, %d", ret);
+       else
+               _D("Successfully unset cpu boosting");
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop = NULL;
@@ -3641,6 +3675,7 @@ int main(int argc, char **argv)
                return -1;
        }
 
+       __set_cpu_boosting();
        _print_hwc_log("%s(%d): __before_loop()", __FUNCTION__, __LINE__);
        if (__before_loop(argc, argv) != 0) {
                _E("process-pool Initialization failed!");
@@ -3651,6 +3686,8 @@ int main(int argc, char **argv)
        _set_priority(-12);
 #endif
        _print_hwc_log("%s(%d): g_main_loop_run()", __FUNCTION__, __LINE__);
+
+       __unset_cpu_boosting();
        g_main_loop_run(mainloop);
 
        __after_loop();