summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlokilee73 <changjoo.lee@samsung.com>2018-03-08 16:43:11 +0900
committerlokilee73 <changjoo.lee@samsung.com>2018-03-08 16:43:18 +0900
commit060ebe900fd9eab6a563422b1b90dfde38c3f8b3 (patch)
tree4903ebc57ced3bceab94e6a1a0fb8f1414a60e1b
parent84d761d16014bf1f8381e1e646ba1daf6fad49d1 (diff)
downloaddeviced-060ebe900fd9eab6a563422b1b90dfde38c3f8b3.tar.gz
deviced-060ebe900fd9eab6a563422b1b90dfde38c3f8b3.tar.bz2
deviced-060ebe900fd9eab6a563422b1b90dfde38c3f8b3.zip
Change-Id: Ia9eb3346109a97a89ba8dd99caa389fcb8204ed8 Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rwxr-xr-xCMakeLists.txt1
-rw-r--r--src/proc/proc-handler.c212
2 files changed, 0 insertions, 213 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e2cc328..b1d2aa89 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,7 +77,6 @@ SET(SRCS
src/core/sig-handler.c
src/core/udev.c
src/proc/cpu-info.c
- src/proc/proc-handler.c
src/time/time-handler.c
)
diff --git a/src/proc/proc-handler.c b/src/proc/proc-handler.c
deleted file mode 100644
index 64d903de..00000000
--- a/src/proc/proc-handler.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <stdio.h>
-#include <unistd.h>
-//#include <dirent.h>
-//#include <sys/types.h>
-//#include <device-node.h>
-//#include <sys/un.h>
-//#include <stdarg.h>
-#include <errno.h>
-#include <vconf.h>
-//#include <fcntl.h>
-
-#include "core/log.h"
-#include "core/common.h"
-#include "core/devices.h"
-#include "core/device-notifier.h"
-#include "shared/dbus.h"
-#include "shared/score-defines.h"
-
-#define OOMADJ_SET "oomadj_set"
-#define OOM_PMQOS_TIME 2000 /* ms */
-#define SIGNAL_PROC_STATUS "ProcStatus"
-
-enum proc_status_type {
- PROC_STATUS_LAUNCH,
- PROC_STATUS_RESUME,
- PROC_STATUS_TERMINATE,
- PROC_STATUS_FOREGROUND,
- PROC_STATUS_BACKGROUND,
-};
-
-static void memcg_move_group(int pid, int oom_score_adj)
-{
- char buf[100];
- FILE *f;
- int size;
- char exe_name[PATH_MAX];
-
- if (get_cmdline_name(pid, exe_name, PATH_MAX) != 0) {
- _E("fail to get process name(%d)", pid);
- return;
- }
-
- _SD("memcg_move_group : %s, pid = %d", exe_name, pid);
- if (oom_score_adj >= OOMADJ_BACKGRD_LOCKED)
- snprintf(buf, sizeof(buf), "/sys/fs/cgroup/memory/background/cgroup.procs");
- else if (oom_score_adj >= OOMADJ_FOREGRD_LOCKED && oom_score_adj < OOMADJ_BACKGRD_LOCKED)
- snprintf(buf, sizeof(buf), "/sys/fs/cgroup/memory/foreground/cgroup.procs");
- else
- return;
-
- f = fopen(buf, "w");
- if (f == NULL)
- return;
- size = snprintf(buf, sizeof(buf), "%d", pid);
- if (fwrite(buf, size, 1, f) != 1)
- _E("fwrite cgroup tasks : %d", pid);
- fclose(f);
-}
-
-int set_oom_score_adj_action(int argc, char **argv)
-{
- FILE *fp;
- int pid = -1;
- int new_oom_score_adj = 0;
-
- if (argc < 2)
- return -1;
- pid = atoi(argv[0]);
- new_oom_score_adj = atoi(argv[1]);
- if (pid < 0 || new_oom_score_adj <= -20)
- return -1;
-
- _I("OOMADJ_SET : pid %d, new_oom_score_adj %d", pid, new_oom_score_adj);
-
- fp = open_proc_oom_score_adj_file(pid, "w");
- if (fp == NULL)
- return -1;
- if (new_oom_score_adj < OOMADJ_SU)
- new_oom_score_adj = OOMADJ_SU;
- fprintf(fp, "%d", new_oom_score_adj);
- fclose(fp);
-
- memcg_move_group(pid, new_oom_score_adj);
- return 0;
-}
-
-GVariant *dbus_oom_handler(GDBusConnection *conn,
- const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
- GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
-{
- pid_t pid;
- int ret;
- int argc;
- char *type_str;
- char *argv[2];
-
- g_variant_get(param, "(siss)", &type_str, &argc, &argv[0], &argv[1]);
-
- if (argc < 0) {
- _E("message is invalid!");
- ret = -EINVAL;
- goto out;
- }
-
- pid = dbus_connection_get_sender_pid(conn, sender);
- if (kill(pid, 0) == -1) {
- _E("%d process does not exist, dbus ignored!", pid);
- ret = -ESRCH;
- goto out;
- }
-
- if (strncmp(type_str, OOMADJ_SET, strlen(OOMADJ_SET)) == 0)
- ret = set_oom_score_adj_action(argc, (char **)&argv);
- else
- ret = -EINVAL;
-
-out:
- g_free(type_str);
- g_free(argv[0]);
- g_free(argv[1]);
- return g_variant_new("(i)", ret);
-}
-
-static void proc_signal_handler(GDBusConnection *conn,
- const gchar *sender,
- const gchar *path,
- const gchar *iface,
- const gchar *name,
- GVariant *param,
- gpointer data)
-{
- int type;
- pid_t pid;
-
- g_variant_get(param, "(ii)", &type, &pid);
-
- if (type == PROC_STATUS_BACKGROUND)
- device_notify(DEVICE_NOTIFIER_PROCESS_BACKGROUND, &pid);
- if (type == PROC_STATUS_FOREGROUND)
- device_notify(DEVICE_NOTIFIER_PROCESS_FOREGROUND, &pid);
-}
-
-static const dbus_method_s dbus_methods[] = {
- { OOMADJ_SET, "siss", "i", dbus_oom_handler },
- /* Add methods here */
-};
-
-static const dbus_interface_u dbus_interface = {
- .oh = NULL,
- .name = DEVICED_INTERFACE_PROCESS,
- .methods = dbus_methods,
- .nr_methods = ARRAY_SIZE(dbus_methods),
-};
-
-
-static void proc_change_lowmemory(keynode_t *key, void *data)
-{
- int state = 0;
-
- if (vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &state))
- return;
-
- if (state == VCONFKEY_SYSMAN_LOW_MEMORY_HARD_WARNING)
- device_notify(DEVICE_NOTIFIER_PMQOS_OOM, (void *)OOM_PMQOS_TIME);
-}
-
-static void process_init(void *data)
-{
- int ret;
-
- ret = subscribe_dbus_signal(NULL,
- RESOURCED_PATH_PROCESS,
- RESOURCED_INTERFACE_PROCESS,
- SIGNAL_PROC_STATUS,
- proc_signal_handler,
- NULL, NULL);
- if (ret <= 0)
- _E("fail to init dbus method(%d)", ret);
-
- ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_PROCESS, &dbus_interface);
- if (ret < 0)
- _E("fail to init dbus method(%d)", ret);
-
- vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY,
- proc_change_lowmemory, NULL);
-}
-
-static const struct device_ops process_device_ops = {
- .name = "process",
- .init = process_init,
-};
-
-DEVICE_OPS_REGISTER(&process_device_ops)