Add cpu priority inheritance 22/277022/8
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 29 Jun 2022 07:26:30 +0000 (16:26 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Fri, 1 Jul 2022 01:59:50 +0000 (10:59 +0900)
To improve performance in case of IPC call,
the cpu priority is inherited from caller process.
When calling register_cpu_inheritance_destination(),
it can be inherited cpu priority from caller.

Requires:
 - https://review.tizen.org/gerrit/c/platform/core/appfw/amd/+/276948

Change-Id: Ie4ed308f299efc0f76db465d3b824adeec6c1555
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 fb3d5ca..267df09 100644 (file)
@@ -70,5 +70,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(CAPI_SYSTEM_RESOURCE_DEPS REQUIRED capi-system-resource)
 
 ADD_SUBDIRECTORY(src)
index 5548027..a788059 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
@@ -191,4 +192,3 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ
 %{_libdir}/*.so
 %{_libdir}/pkgconfig/liblaunchpad.pc
 %{_libdir}/pkgconfig/liblaunchpad-hydra.pc
-
index b0af4fe..caec083 100644 (file)
@@ -39,6 +39,7 @@ APPLY_PKG_CONFIG(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC
   TANCHOR_DEPS
   TTRACE_DEPS
   VCONF_DEPS
+  CAPI_SYSTEM_RESOURCE_DEPS
 )
 
 TARGET_LINK_LIBRARIES(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC "-lm -ldl")
index 37fd7a3..5b7eb5a 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #define _GNU_SOURCE
+#include <cpu-boosting.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -72,6 +73,7 @@
 #define LOADERS_PATH "loaders"
 #define APP_DEFINED_LOADER_INFO_PATH   OPT_SHARE_PATH "/" LOADERS_PATH
 #define COMMON_LOADER_NAME "common-loader1"
+#define LAUNCHPAD_PROCESS_NAME "launchpad-process-pool"
 
 #define LAUNCHER_INFO_PATH     LOADER_INFO_PATH
 #define REGULAR_UID_MIN 5000
@@ -784,6 +786,13 @@ static int __fork_app_process(int (*child_fn)(void *), void *arg)
        }
 
        if (pid == 0) {
+               resource_pid_t resource_st = {
+                       pid = getpid(),
+               };
+               ret = resource_clear_cpu_boosting(resource_st);
+               if (ret != 0)
+                       _E("Failed to clear cpu boosting. error(%d)", ret);
+
                _W("security_manager_prepare_app_candidate ++");
                ret = security_manager_prepare_app_candidate();
                _W("security_manager_prepare_app_candidate --");
@@ -2772,11 +2781,11 @@ static void __get_app_type_string(loader_info_t *info, char buf[], int size)
                strncpy(ptr, app_type, size);
                ptr += len;
                size -= len;
-                if (iter) {
+               if (iter) {
                        (*ptr++) = ' ';
                        size--;
                }
-        }
+       }
 }
 
 static void __add_slot_from_info(gpointer data, gpointer user_data)
@@ -2834,12 +2843,12 @@ static void __add_slot_from_info(gpointer data, gpointer user_data)
 
                info->type = LAUNCHPAD_LOADER_TYPE_USER + user_slot_offset;
                user_slot_offset++;
-                __get_app_type_string(info, buf, sizeof(buf));
-                _I("candidate slot. app-type(%s) loader-type(%d)",
+               __get_app_type_string(info, buf, sizeof(buf));
+               _I("candidate slot. app-type(%s) loader-type(%d)",
                                buf, info->type);
                _print_hwc_log("candidate slot. app-type(%s) loader-type(%d)",
                                buf, info->type);
-        }
+       }
 }
 
 static int __add_default_slots(void)
@@ -3156,6 +3165,9 @@ static gboolean __launchpad_recovery_cb(gpointer data)
 static int __before_loop(int argc, char **argv)
 {
        int ret;
+       resource_pid_t resource_st = {
+               .pid = getpid(),
+       };
 
        _print_hwc_log("%s(%d): START", __FUNCTION__, __LINE__);
        ret = __sequencer_init();
@@ -3227,11 +3239,27 @@ static int __before_loop(int argc, char **argv)
        _log_init();
        _print_hwc_log("%s(%d): END", __FUNCTION__, __LINE__);
 
+       ret = resource_register_cpu_inheritance_destination(
+                       LAUNCHPAD_PROCESS_NAME, resource_st);
+       if (ret != 0) {
+               _E("Failed to register cpu inheritance destination. error(%d)",
+                               ret);
+       }
+
        return 0;
 }
 
 static void __after_loop(void)
 {
+       int ret;
+
+       ret = resource_unregister_cpu_inheritance_destination(
+                       LAUNCHPAD_PROCESS_NAME);
+       if (ret != 0) {
+               _E("Failed to unregister cpu inheritance destination. "
+                               "error(%d)", ret);
+       }
+
        _log_fini();
        _memory_monitor_fini();
        __unregister_vconf_events();