summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKichan Kwon <k_c.kwon@samsung.com>2016-11-21 14:36:34 +0900
committerKichan Kwon <k_c.kwon@samsung.com>2016-11-21 14:43:51 +0900
commitdb0989e1662d40ba700f4ffd2d98ebbb39286f46 (patch)
treeb2c160d0639b6077a1e245323921e6c114e09acc
parent958484629334d98d4cc2faac79c5cf5f5b28d5b6 (diff)
parent763bfbd091e9df5529d7060d59d9bedac772f11e (diff)
downloadresourced-db0989e1662d40ba700f4ffd2d98ebbb39286f46.tar.gz
resourced-db0989e1662d40ba700f4ffd2d98ebbb39286f46.tar.bz2
resourced-db0989e1662d40ba700f4ffd2d98ebbb39286f46.zip
Merge branch 'tizen' into tizen_3.0
Change-Id: I24c32bc9ccf3e0ac85f5b84c26b57d2ded02c909 Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
-rw-r--r--packaging/resourced.spec1
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/common/cgroup.c10
-rw-r--r--src/cpu/cpu.c15
-rw-r--r--src/memory/memcontrol.c6
-rw-r--r--src/memory/vmpressure-lowmem-handler.c8
-rw-r--r--src/proc-stat/proc-main.c45
7 files changed, 51 insertions, 35 deletions
diff --git a/packaging/resourced.spec b/packaging/resourced.spec
index d290108b..40f97be5 100644
--- a/packaging/resourced.spec
+++ b/packaging/resourced.spec
@@ -58,7 +58,6 @@ BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(vconf-internal-keys)
BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(ecore-file)
BuildRequires: pkgconfig(eina)
BuildRequires: pkgconfig(edbus)
BuildRequires: pkgconfig(libsystemd)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 696404e7..a47230b4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -133,7 +133,6 @@ SET(REQUIRES_LIST ${REQUIRES_LIST}
sqlite3
vconf
vconf-internal-keys
- ecore-file
eina
edbus
eina
diff --git a/src/common/cgroup.c b/src/common/cgroup.c
index 180a5c8d..7a466fb8 100644
--- a/src/common/cgroup.c
+++ b/src/common/cgroup.c
@@ -43,8 +43,8 @@
#include <unistd.h>
#include <sys/mount.h>
-#define RELEASE_AGENT "/release_agent"
-#define NOTIFY_ON_RELEASE "/notify_on_release"
+#define RELEASE_AGENT "release_agent"
+#define NOTIFY_ON_RELEASE "notify_on_release"
static bool cgroup_is_exists(const char *cgroup_full_path)
{
@@ -130,7 +130,7 @@ int cgroup_write_node(const char *cgroup_name,
const char *file_name, unsigned int value)
{
char buf[MAX_PATH_LENGTH];
- snprintf(buf, sizeof(buf), "%s%s", cgroup_name, file_name);
+ snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
_SD("cgroup_buf %s, value %d\n", buf, value);
return fwrite_int(buf, value);
}
@@ -139,7 +139,7 @@ int cgroup_write_node_str(const char *cgroup_name,
const char *file_name, const char *string)
{
char buf[MAX_PATH_LENGTH];
- snprintf(buf, sizeof(buf), "%s%s", cgroup_name, file_name);
+ snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
_SD("cgroup_buf %s, string %s\n", buf, string);
return fwrite_str(buf, string);
}
@@ -149,7 +149,7 @@ int cgroup_read_node(const char *cgroup_name,
{
char buf[MAX_PATH_LENGTH];
int ret;
- snprintf(buf, sizeof(buf), "%s%s", cgroup_name, file_name);
+ snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
ret = fread_uint(buf, value);
_SD("cgroup_buf %s, value %d\n", buf, *value);
return ret;
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 8f929ee5..fb0cae16 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -45,18 +45,19 @@
#include "const.h"
#include "file-helper.h"
-#define CPU_DEFAULT_CGROUP "/sys/fs/cgroup/cpu"
-#define CPU_BACKGROUND_GROUP CPU_DEFAULT_CGROUP"/background"
-#define CPU_CPUQUOTA_GROUP CPU_DEFAULT_CGROUP"/quota"
-#define CPU_CONTROL_BANDWIDTH "/cpu.cfs_quota_us"
-#define CPU_CONTROL_FULL_BANDWIDTH "/cpu.cfs_period_us"
+#define CPU_DEFAULT_CGROUP "/sys/fs/cgroup/cpu"
+#define CPU_BACKGROUND_GROUP CPU_DEFAULT_CGROUP"/background"
+#define CPU_CPUQUOTA_GROUP CPU_DEFAULT_CGROUP"/quota"
+#define CPU_CONTROL_BANDWIDTH "cpu.cfs_quota_us"
+#define CPU_CONTROL_FULL_BANDWIDTH "cpu.cfs_period_us"
+#define CPU_SHARE "cpu.shares"
+
#define CPU_CONF_FILE RD_CONFIG_FILE(cpu)
#define CPU_CONF_SECTION "CONTROL"
#define CPU_CONF_PREDEFINE "PREDEFINE"
#define CPU_CONF_BOOTING "BOOTING_PREDEFINE"
#define CPU_CONF_WRT "WRT_PREDEFINE"
#define CPU_CONF_LAZY "LAZY_PREDEFINE"
-#define CPU_SHARE "/cpu.shares"
#define MAX_PREDEFINED_TASKS 10
#define CPU_TIMER_INTERVAL 30
#define CPU_DEFAULT_PRI 0
@@ -152,7 +153,7 @@ static void cpu_check_cpuquota(void)
int ret, node = 0;
char buf[MAX_PATH_LENGTH];
- snprintf(buf, sizeof(buf), "%s%s", CPU_DEFAULT_CGROUP, CPU_CONTROL_BANDWIDTH);
+ snprintf(buf, sizeof(buf), "%s/%s", CPU_DEFAULT_CGROUP, CPU_CONTROL_BANDWIDTH);
ret = fread_int(buf, &node);
if (!ret)
bCPUQuota = true;
diff --git a/src/memory/memcontrol.c b/src/memory/memcontrol.c
index 87455fc0..50acf4f3 100644
--- a/src/memory/memcontrol.c
+++ b/src/memory/memcontrol.c
@@ -63,7 +63,7 @@ static struct memcg_info *memcg_info_alloc_subcgroup(struct memcg *memcg)
return NULL;
mi->id = memcg->num_subcgroup;
pmi = memcg->info;
- snprintf(mi->name, MAX_PATH_LENGTH, "%s%d/",
+ snprintf(mi->name, MAX_PATH_LENGTH, "%s/%d",
pmi->name, memcg->num_subcgroup++);
mi->limit_ratio = pmi->limit_ratio;
mi->limit = pmi->limit;
@@ -161,7 +161,7 @@ int memcg_get_anon_usage(struct memcg_info *mi, unsigned long long *anon_usage)
char name[BUF_MAX] = {0, };
unsigned long long tmp, active_anon = 0, inactive_anon = 0;
- snprintf(buf, sizeof(buf), "%smemory.stat", mi->name);
+ snprintf(buf, sizeof(buf), "%s/memory.stat", mi->name);
_I("get mem usage anon from %s", buf);
f = fopen(buf, "r");
@@ -213,7 +213,7 @@ int memcg_get_pids(struct memcg_info *mi, GArray *pids)
if (pids == NULL)
return RESOURCED_ERROR_FAIL;
- snprintf(buf, sizeof(buf), "%scgroup.procs", mi->name);
+ snprintf(buf, sizeof(buf), "%s/cgroup.procs", mi->name);
f = fopen(buf, "r");
if (!f) {
diff --git a/src/memory/vmpressure-lowmem-handler.c b/src/memory/vmpressure-lowmem-handler.c
index e55a74e3..504eb689 100644
--- a/src/memory/vmpressure-lowmem-handler.c
+++ b/src/memory/vmpressure-lowmem-handler.c
@@ -1496,10 +1496,10 @@ static int init_memcg_params(void)
}
memcg_init(memcg_tree[idx]);
if (memcg_name[idx])
- snprintf(buf, MAX_PATH_LENGTH, "%s/%s/", LOWMEM_DEFAULT_CGROUP,
+ snprintf(buf, MAX_PATH_LENGTH, "%s/%s", LOWMEM_DEFAULT_CGROUP,
memcg_name[idx]);
else
- snprintf(buf, MAX_PATH_LENGTH, "%s/", LOWMEM_DEFAULT_CGROUP);
+ snprintf(buf, MAX_PATH_LENGTH, "%s", LOWMEM_DEFAULT_CGROUP);
mi = (struct memcg_info *)malloc(sizeof(struct memcg_info));
if (!mi) {
int i;
@@ -1849,14 +1849,14 @@ static void lowmem_press_register_eventfd(struct memcg_info *mi)
if (mi->threshold[LOWMEM_MEDIUM] == LOWMEM_THRES_INIT)
return;
- snprintf(buf, sizeof(buf), "%s%s", name, MEMCG_EVENTFD_CONTROL);
+ snprintf(buf, sizeof(buf), "%s/%s", name, MEMCG_EVENTFD_CONTROL);
cgfd = open(buf, O_WRONLY);
if (cgfd < 0) {
_E("open event_control failed");
return;
}
- snprintf(buf, sizeof(buf), "%s%s", name, MEMCG_EVENTFD_MEMORY_PRESSURE);
+ snprintf(buf, sizeof(buf), "%s/%s", name, MEMCG_EVENTFD_MEMORY_PRESSURE);
pressurefd = open(buf, O_RDONLY);
if (pressurefd < 0) {
_E("open pressure control failed");
diff --git a/src/proc-stat/proc-main.c b/src/proc-stat/proc-main.c
index e29a840f..cbc07960 100644
--- a/src/proc-stat/proc-main.c
+++ b/src/proc-stat/proc-main.c
@@ -29,7 +29,8 @@
#include <fcntl.h>
#include <Ecore.h>
-#include <Ecore_File.h>
+#include <glib-object.h>
+#include <gio/gio.h>
#include <pthread.h>
#include "freezer.h"
@@ -61,7 +62,7 @@
#endif
static GHashTable *proc_exclude_list;
-static Ecore_File_Monitor *exclude_list_monitor;
+static GFileMonitor *exclude_list_monitor;
static const unsigned int exclude_list_limit = 1024;
static const struct module_ops *freezer;
static GSList *proc_module; /* proc sub-module list */
@@ -1011,28 +1012,41 @@ static void _fill_exclude_list(GHashTable *list)
fill_exclude_list_by_path(EXCLUDE_LIST_RW_PATH, list);
}
-static void _exclude_list_change_cb(void *data, Ecore_File_Monitor *em,
- Ecore_File_Event event, const char *path)
+static void _exclude_list_change_cb(GFileMonitor *monitor,
+ GFile *file, GFile *file2,
+ GFileMonitorEvent event, gpointer data)
{
- _SD("file %s changed, path: %s, event: %d ", EXCLUDE_LIST_RW_PATH,
- path, event);
+ _SD("Exclude list file %s changed, event: %d ", EXCLUDE_LIST_RW_PATH, event);
g_hash_table_remove_all(proc_exclude_list);
/* reread all */
_fill_exclude_list(proc_exclude_list);
}
+
static void _init_exclude_list_noti(void)
{
- if (ecore_file_init() == 0) {
- _E("ecore_file_init() failed");
+ GFile *exclude_list_file = NULL;
+
+ exclude_list_file = g_file_new_for_path(EXCLUDE_LIST_RW_PATH);
+ if (!exclude_list_file) {
+ _E("g_file_new_for_path() failed. Dynamic exclude list will not be activated.");
return;
}
- exclude_list_monitor = ecore_file_monitor_add(EXCLUDE_LIST_RW_PATH,
- _exclude_list_change_cb,
- NULL);
- if (exclude_list_monitor == NULL)
- _E("Dynamic exclude list not supported. Cannot add notification callback");
+
+ exclude_list_monitor = g_file_monitor(exclude_list_file,
+ G_FILE_MONITOR_NONE, NULL, NULL);
+ if (exclude_list_monitor == NULL) {
+ _E("g_file_monitor_file() failed. Dynamic exclude list will not be activated.");
+ g_object_unref(exclude_list_file);
+ return;
+ }
+
+ g_signal_connect(exclude_list_monitor, "changed",
+ G_CALLBACK(_exclude_list_change_cb), NULL);
+
+ g_object_unref(exclude_list_file);
+ return;
}
static void proc_exclude_init(void)
@@ -1213,7 +1227,10 @@ static int resourced_proc_exit(void* data)
{
proc_delete_all_lists();
g_hash_table_destroy(proc_exclude_list);
- ecore_file_monitor_del(exclude_list_monitor);
+ if (exclude_list_monitor) {
+ g_file_monitor_cancel(exclude_list_monitor);
+ g_object_unref(exclude_list_monitor);
+ }
proc_module_exit(data);
return RESOURCED_ERROR_NONE;
}