After this patch is applied, the loader priority feature is basically activated.
The platform developer can adjust a scheduling priority using
the loader configuration file.
The 'SCEHD_PRIORITY' tag is added for the loader process.
The loader developer can set the scheduling priority as below:
+------------------------------------------------------------------------------+
| [LOADER] |
| NAME hw-loader |
| ... |
| SCEHD_PRIORITY -20 |
+------------------------------------------------------------------------------+
The range of the priority is -20 to 19. (-20 being the highest priority
and 19 being the lowest priority.)
If the loader has the sched priority tag, the child process sets
the scheduling priority using the configure information after the process
is created. And then, the loader process sets the priority to the normal
priority before running the main loop.
Change-Id: I531cc8381936ef4f6c9b8bad1640a0a8714f2777
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
IF(_TIZEN_FEATURE_PRIORITY_CHANGE)
ADD_DEFINITIONS("-DTIZEN_FEATURE_PRIORITY_CHANGE")
ENDIF(_TIZEN_FEATURE_PRIORITY_CHANGE)
-IF(_TIZEN_FEATURE_LOADER_PRIORITY)
- ADD_DEFINITIONS("-DTIZEN_FEATURE_LOADER_PRIORITY")
-ENDIF(_TIZEN_FEATURE_LOADER_PRIORITY)
IF(_TIZEN_FEATURE_SET_PERSONALITY_32)
ADD_DEFINITIONS("-DTIZEN_FEATURE_SET_PERSONALITY_32")
ENDIF(_TIZEN_FEATURE_SET_PERSONALITY_32)
Obsoletes: amd-mod-launchpad
%define tizen_feature_priority_change 0
-%define tizen_feature_loader_priority 0
%ifarch armv7l i686 i586
%define tizen_arch32 1
%else
%if 0%{?tizen_feature_priority_change}
_TIZEN_FEATURE_PRIORITY_CHANGE=ON
%endif
-%if 0%{?tizen_feature_loader_priority}
-_TIZEN_FEATURE_LOADER_PRIORITY=ON
-%endif
%if 0%{?tizen_arch32}
_TIZEN_FEATURE_SET_PERSONALITY_32=ON
%else
-DMAJORVER=${MAJORVER} \
-DHW_LOADER_THREADS=${HW_LOADER_THREADS} \
-D_TIZEN_FEATURE_PRIORITY_CHANGE:BOOL=${_TIZEN_FEATURE_PRIORITY_CHANGE} \
- -D_TIZEN_FEATURE_LOADER_PRIORITY:BOOL=${_TIZEN_FEATURE_LOADER_PRIORITY} \
-D_TIZEN_FEATURE_SET_PERSONALITY_32:BOOL=${_TIZEN_FEATURE_SET_PERSONALITY_32} \
-D_TIZEN_FEATURE_PRELINK:BOOL=${_TIZEN_FEATURE_PRELINK} \
-D_TIZEN_FEATURE_LOADER_ARCH64:BOOL=${_TIZEN_FEATURE_LOADER_ARCH64} \
return adapter_;
}
- void SetLoaderPriority(bool enable) {
- loader_priority_enabled_ = enable;
- }
-
- bool IsLoaderPriorityEnabled() {
- return loader_priority_enabled_;
- }
-
void SetFdHandler(Ecore_Fd_Handler* fd_handler) {
fd_handler_ = fd_handler;
}
return;
}
- if (loader->IsLoaderPriorityEnabled())
- launchpad_loader_set_priority(19);
-
loader->PreloadLib(ex);
ecore_init();
setenv("AUL_LOADER_INIT", "1", 1);
setenv("AUL_HWACC", "none", 1);
else if (loader_type == LOADER_TYPE_HW)
setenv("AUL_HWACC", "hw", 1);
-
- if (loader->IsLoaderPriorityEnabled())
- launchpad_loader_set_priority(0);
}
static int OnLaunch(int argc, char** argv, const char* app_path,
const char* appid, const char* pkgid, const char* pkg_type,
void* user_data) {
_I("on launch");
- AppDefinedLoader* loader = static_cast<AppDefinedLoader*>(user_data);
bundle* kb = launchpad_loader_get_bundle();
if (kb == nullptr)
return 0;
private:
std::shared_ptr<loader_lifecycle_callback_s> lifecycle_cb_ = nullptr;
std::shared_ptr<loader_adapter_s> adapter_ = nullptr;
- bool loader_priority_enabled_ = false;
loader_receiver_cb receiver_cb_ = nullptr;
Ecore_Fd_Handler* fd_handler_ = nullptr;
std::unique_ptr<Proc> proc_;
int main(int argc, char** argv) {
launchpad::AppDefinedLoader loader(argc, argv);
-
-#ifdef TIZEN_FEATURE_LOADER_PRIORITY
- loader.SetLoaderPriority(true);
-#endif
-
return launchpad_loader_main(argc, argv,
loader.GetLifeCycle().get(), loader.GetAdapter().get(), &loader);
}
return;
}
-#ifdef TIZEN_FEATURE_LOADER_PRIORITY
- launchpad_loader_set_priority(19);
-#endif
-
if (!strcmp(LOADER_TYPE_COMMON, ltype))
__type = TYPE_COMMON;
else if (!strcmp(LOADER_TYPE_SW, ltype))
_E("Failed to register callback for %s",
VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
}
-#ifdef TIZEN_FEATURE_LOADER_PRIORITY
- launchpad_loader_set_priority(0);
-#endif
}
static loader_convertible __converter_table[MAX_LOADER_TYPE][MAX_ACC_TYPE] = {
bool is_hydra;
bool app_check;
int on_boot_timeout;
+ int sched_priority;
} loader_info_t;
typedef void (*loader_info_foreach_cb)(loader_info_t *info, void *data);
bool is_hydra;
bool app_check;
int on_boot_timeout;
+ int sched_priority;
} slot_info_t;
#endif /* __SLOT_INFO_H__ */
int cpu_check_count;
int on_boot_timeout;
guint on_boot_timer;
+ int sched_priority;
} candidate_process_context_t;
typedef struct {
return 0;
}
-static int __fork_app_process(int (*child_fn)(void *), void *arg)
+static int __fork_app_process(int (*child_fn)(void *), void *arg,
+ int sched_priority)
{
int pid;
int ret;
}
if (pid == 0) {
+ if (sched_priority != 0)
+ _set_priority(sched_priority);
+
_W("security_manager_prepare_app_candidate ++");
ret = security_manager_prepare_app_candidate();
_W("security_manager_prepare_app_candidate --");
if (ret < 0)
return ret;
- info->pid = __fork_app_process(__exec_loader_process, info->argv);
+ info->pid = __fork_app_process(__exec_loader_process, info->argv,
+ cpt->sched_priority);
if (info->pid == -1) {
_E("Failed to create a child process. type: %d", type);
__candidate_info_free(info);
arg.kb = kb;
_print_hwc_log("before calling fork(). %s", appid);
- pid = __fork_app_process(__exec_app_process, &arg);
+ pid = __fork_app_process(__exec_app_process, &arg, 0);
if (pid <= 0)
_E("failed to fork app process");
slot_info.is_hydra = false;
slot_info.app_check = true;
slot_info.on_boot_timeout = 0;
+ slot_info.sched_priority = 0;
cpc = __add_slot(&slot_info);
free(loader_name);
slot_info.is_hydra = false;
slot_info.app_check = true;
slot_info.on_boot_timeout = 0;
+ slot_info.sched_priority = 0;
cpc = __add_slot(&slot_info);
bundle_free_encoded_rawdata(&extra);
cpc->pss = 0;
cpc->cpu_check_count = 0;
cpc->on_boot_timeout = info->on_boot_timeout;
+ cpc->sched_priority = info->sched_priority;
if ((cpc->deactivation_method & METHOD_OUT_OF_MEMORY) &&
__is_low_memory())
.is_hydra = info->is_hydra,
.app_check = info->app_check,
.on_boot_timeout = info->on_boot_timeout,
+ .sched_priority = info->sched_priority,
};
if (!strcmp(info->exe, "null")) {
#define TAG_HYDRA "HYDRA"
#define TAG_APP_CHECK "APP_CHECK"
#define TAG_ON_BOOT_TIMEOUT "ON_BOOT_TIMEOUT"
+#define TAG_SCHED_PRIORITY "SCHED_PRIORITY"
#define VAL_ON "ON"
#define VAL_OFF "OFF"
{
loader_info_t *info;
- info = malloc(sizeof(loader_info_t));
+ info = calloc(1, sizeof(loader_info_t));
if (info == NULL) {
_E("Out of memory");
return NULL;
cur_info->app_check = false;
} else if (strcasecmp(TAG_ON_BOOT_TIMEOUT, tok1) == 0) {
cur_info->on_boot_timeout = atoi(tok2);
+ } else if (strcasecmp(TAG_SCHED_PRIORITY, tok1) == 0) {
+ cur_info->sched_priority = atoi(tok2);
+ if (cur_info->sched_priority < -20)
+ cur_info->sched_priority = -20;
+ else if (cur_info->sched_priority > 19)
+ cur_info->sched_priority = 19;
}
}
int _set_priority(int prio)
{
- int r;
+ int ret;
- r = setpriority(PRIO_PGRP, 0, prio);
- if (r < 0) {
+ ret = setpriority(PRIO_PROCESS, 0, prio);
+ if (ret != 0) {
SECURE_LOGE("Failed to set process(%d) priority(%d) - err(%d)",
getpid(), prio, errno);
+ } else {
+ SECURE_LOGD("priority(%d)", prio);
}
- return r;
+ return ret;
}
static int __dbus_send_message(DBusMessage *callback(void *), void *user_data,
return -1;
}
+ _set_priority(0);
_D("[candidate] ecore main loop begin");
__loader_adapter->loop_begin(__loader_user_data);