From: Changgyu Choi Date: Wed, 26 Apr 2023 07:57:28 +0000 (+0900) Subject: Apply cpu boosting X-Git-Tag: accepted/tizen/7.0/unified/20230511.180840~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07cd6465c99d94c84ecc43e2e37c09c15a335c86;p=platform%2Fcore%2Fappfw%2Flaunchpad.git Apply cpu boosting This patch applies cpu boosting while calling __before_loop() Change-Id: I1dbe82f54c443ae07eb6388c4f162824708c5476 Signed-off-by: Changgyu Choi --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 69ff6644..5e5b9543 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index aa5de8ef..57edcd03 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -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 - diff --git a/src/launchpad-process-pool/CMakeLists.txt b/src/launchpad-process-pool/CMakeLists.txt index b0af4fe9..b5de3141 100644 --- a/src/launchpad-process-pool/CMakeLists.txt +++ b/src/launchpad-process-pool/CMakeLists.txt @@ -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") diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index 5d1e66a0..9083b207 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -15,6 +15,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -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();