- Change prefix to "TIZEN_FEATURE".
- Change lowest priority value to 19. (range: -20 ~ 19)
- Set CAP_SYS_NICE if the feature is enabled
- Add a new API to adjust scheduling priority
Note:
- To enable the feature, the user session systemd should have
the cap_sys_nice capability(inheritable).
Change-Id: I86e3d30a26ecde5bf8a70ef1cb2660fa33cc5aef
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
ADD_DEFINITIONS("-DSHARE_PREFIX=\"/usr/share/aul\"")
-IF(_APPFW_FEATURE_PRIORITY_CHANGE)
- ADD_DEFINITIONS("-D_APPFW_FEATURE_PRIORITY_CHANGE")
-ENDIF(_APPFW_FEATURE_PRIORITY_CHANGE)
+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)
ADD_DEFINITIONS("-DLAUNCHPAD_LOG")
ADD_DEFINITIONS("-DPRELOAD_ACTIVATE")
#define AUL_K_LOADER_NAME "__AUL_LOADER_NAME__"
#define AUL_K_SDK "__AUL_SDK__"
#define AUL_K_ORG_CALLER_PID "__AUL_ORG_CALLER_PID__"
+#define AUL_K_HIGHPRIORITY "__AUL_HIGHPRIORITY__"
#ifdef __cplusplus
}
loader_lifecycle_callback_s *callbacks,
loader_adapter_s *adapter, void *user_data);
+/*
+ * @par Description
+ * Set program scheduling priority.
+ *
+ * @param[in] prio The priority
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @remarks
+ * The prio is a value in the range -20 to 19.
+ * If the prio is higher than current value, the process MUST have
+ * CAP_SYS_NICE capability.
+ */
+int launchpad_loader_set_priority(int prio);
+
#ifdef __cplusplus
}
#endif
int _close_all_fds(void);
void _get_cpu_idle(unsigned long long *total, unsigned long long *idle);
int _setup_stdio(const char *ident);
+int _set_priority(int prio);
#endif /* __LAUNCHPAD_COMMON_H__ */
Requires(postun): /usr/bin/systemctl
Requires(preun): /usr/bin/systemctl
-%define appfw_feature_priority_change 0
+%define tizen_feature_priority_change 0
+%define tizen_feature_loader_priority 0
%description
Launchpad for launching applications
export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
%endif
-%if 0%{?appfw_feature_priority_change}
-_APPFW_FEATURE_PRIORITY_CHANGE=ON
+%if 0%{?tizen_feature_priority_change}
+_TIZEN_FEATURE_PRIORITY_CHANGE=ON
+%endif
+%if 0%{?tizen_feature_loader_priority}
+_TIZEN_FEATURE_LOADER_PRIORITY=ON
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
%cmake -DVERSION=%{version} \
-DMAJORVER=${MAJORVER} \
- -D_APPFW_FEATURE_PRIORITY_CHANGE:BOOL=${_APPFW_FEATURE_PRIORITY_CHANGE} \
+ -D_TIZEN_FEATURE_PRIORITY_CHANGE:BOOL=${_TIZEN_FEATURE_PRIORITY_CHANGE} \
+ -D_TIZEN_FEATURE_LOADER_PRIORITY:BOOL=${_TIZEN_FEATURE_LOADER_PRIORITY} \
.
%__make %{?_smp_mflags}
%{_unitdir_user}/launchpad-process-pool.socket
%{_unitdir_user}/sockets.target.wants/launchpad-process-pool.socket
%{_unitdir_user}/basic.target.wants/launchpad-process-pool.service
+%if 0%{?tizen_feature_priority_change} || 0%{?tizen_feature_loader_priority}
+%caps(cap_mac_admin,cap_dac_override,cap_setgid,cap_sys_nice=ei) %{_bindir}/launchpad-process-pool
+%else
%caps(cap_mac_admin,cap_dac_override,cap_setgid=ei) %{_bindir}/launchpad-process-pool
+%endif
%attr(0644,root,root) %{_libdir}/liblaunchpad.so.*
%files devel
%manifest %{name}.manifest
%license LICENSE
%{_prefix}/share/aul/default.loader
+%if 0%{?tizen_feature_priority_change} || 0%{?tizen_feature_loader_priority}
+%caps(cap_setgid,cap_sys_nice=ei) %{_bindir}/launchpad-loader
+%else
%caps(cap_setgid=ei) %{_bindir}/launchpad-loader
+%endif
security_manager_app_labels_monitor_finish(label_monitor);
}
-#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
-static void __set_priority(void)
-{
- char err_str[MAX_LOCAL_BUFSZ] = { 0, };
- int res;
-
- res = setpriority(PRIO_PROCESS, 0, -12);
- if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority to -12 failed, " \
- "errno: %d (%s)", getpid(), errno,
- strerror_r(errno, err_str, sizeof(err_str)));
- }
-}
-#endif
-
int main(int argc, char **argv)
{
GMainLoop *mainloop = NULL;
return -1;
}
-#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
- __set_priority();
+#ifdef TIZEN_FEATURE_PRIORITY_CHANGE
+ _set_priority(-12);
#endif
g_main_loop_run(mainloop);
#include <stdio.h>
#include <stdbool.h>
#include <systemd/sd-journal.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include "launchpad_common.h"
#include "key.h"
return 0;
}
+
+int _set_priority(int prio)
+{
+ int r;
+
+ r = setpriority(PRIO_PGRP, 0, prio);
+ if (r < 0) {
+ SECURE_LOGE("Failed to set process(%d) priority(%d) - err(%d)",
+ getpid(), prio, errno);
+ }
+
+ return r;
+}
#include <sys/types.h>
#include <sys/prctl.h>
#include <malloc.h>
-#ifdef _APPFW_FEATURE_LOADER_PRIORITY
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
#include <bundle_internal.h>
#include <aul.h>
#include <security-manager.h>
#endif
#define AUL_PR_NAME 16
-#define LOWEST_PRIO 20
static loader_lifecycle_callback_s *__loader_callbacks;
static loader_adapter_s *__loader_adapter;
const char *pkgid, const char *pkg_type, int loader_type)
{
char err_str[MAX_LOCAL_BUFSZ] = { 0, };
-#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
- int res;
- const char *high_priority = bundle_get_val(kb, AUL_K_HIGHPRIORITY);
-
- _D("high_priority: %s", high_priority);
- if (strncmp(high_priority, "true", 4) == 0) {
- res = setpriority(PRIO_PROCESS, 0, -10);
- if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority " \
- "to -10 failed, errno: %d (%s)",
- getpid(), errno,
- strerror_r(errno, err_str, sizeof(err_str)));
- }
- }
- bundle_del(kb, AUL_K_HIGHPRIORITY);
-#endif
if (__prepare_exec(appid, app_path, pkg_type, loader_type) < 0) {
_E("__candidate_process_prepare_exec() failed");
int client_fd;
int ret = -1;
bundle *extra = NULL;
-#ifdef _APPFW_FEATURE_LOADER_PRIORITY
- char err_str[MAX_LOCAL_BUFSZ] = { 0, };
- int res = setpriority(PRIO_PROCESS, 0, LOWEST_PRIO);
- if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority to %d failed, " \
- "errno: %d (%s)", getpid(), LOWEST_PRIO, errno,
- strerror_r(errno, err_str, sizeof(err_str)));
- }
-#endif
__preexec_init(argc, argv);
/* Set new session ID & new process group ID*/
bundle_free(extra);
malloc_trim(0);
-#ifdef _APPFW_FEATURE_LOADER_PRIORITY
- res = setpriority(PRIO_PGRP, 0, 0);
- if (res == -1) {
- SECURE_LOGE("Setting process (%d) priority to 0 failed, " \
- "errno: %d (%s)", getpid(), errno,
- strerror_r(errno, err_str, sizeof(err_str)));
- }
-#endif
+
client_fd = _connect_to_launchpad(__loader_type, __loader_id);
if (client_fd == -1) {
_D("Connecting to candidate process was failed.");
return __after_loop();
}
+API int launchpad_loader_set_priority(int prio)
+{
+ return _set_priority(prio);
+}
#define LOADER_TYPE_HW "hw-loader"
#define LOADER_TYPE_SW "sw-loader"
-
extern bundle *launchpad_loader_get_bundle(void);
static Ecore_Fd_Handler *__fd_handler;
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] = {
bundle *kb = launchpad_loader_get_bundle();
int acc = SW_ACC;
loader_convertible convert;
+#ifdef TIZEN_FEATURE_PRIORITY_CHANGE
+ const char *high_priority;
+#endif
vconf_ignore_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION,
__vconf_cb);
if (kb == NULL)
return 0;
+#ifdef TIZEN_FEATURE_PRIORITY_CHANGE
+ high_priority = bundle_get_val(kb, AUL_K_HIGHPRIORITY);
+ if (high_priority) {
+ if (!strcmp(high_priority, "true"))
+ launchpad_loader_set_priority(-12);
+ bundle_del(kb, AUL_K_HIGHPRIORITY);
+ }
+#endif
+
hwacc = bundle_get_val(kb, AUL_K_HWACC);
if (!hwacc)