summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Aksenov <a.aksenov@samsung.com>2014-06-05 13:30:52 +0400
committerAlexander Aksenov <a.aksenov@samsung.com>2014-06-06 10:46:01 +0400
commit11fef2b803cea20d672b1fd9e52de5810b4e1ba7 (patch)
tree921725a733d45e2f9c153e713309da5eb79df104
parent8a0ea3203a21ba7b99d664a8bb2fb25781fc5d1e (diff)
downloadswap-modules-11fef2b803cea20d672b1fd9e52de5810b4e1ba7.tar.gz
swap-modules-11fef2b803cea20d672b1fd9e52de5810b4e1ba7.tar.bz2
swap-modules-11fef2b803cea20d672b1fd9e52de5810b4e1ba7.zip
[IMPROVE] Us_manager: new proc filter inteface
Now proc filter statically allocated and stored in pf_group structure. Main purpoise of this commit - fix proc filter memleak Change-Id: I10632952f67262e562ab960ba5f519ebcc6599fe Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
-rw-r--r--us_manager/pf/pf_group.c35
-rw-r--r--us_manager/pf/proc_filters.c31
-rw-r--r--us_manager/pf/proc_filters.h11
3 files changed, 26 insertions, 51 deletions
diff --git a/us_manager/pf/pf_group.c b/us_manager/pf/pf_group.c
index 18e6248a..b1172d62 100644
--- a/us_manager/pf/pf_group.c
+++ b/us_manager/pf/pf_group.c
@@ -37,7 +37,7 @@
struct pf_group {
struct list_head list;
struct img_proc *i_proc;
- struct proc_filter *filter;
+ struct proc_filter filter;
/* TODO: proc_list*/
struct list_head proc_list;
@@ -122,7 +122,7 @@ static struct sspt_proc *new_proc_by_pfg(struct pf_group *pfg,
struct pl_struct *pls;
struct sspt_proc *proc;
- proc = sspt_proc_get_by_task_or_new(task, pfg->filter->priv);
+ proc = sspt_proc_get_by_task_or_new(task, pfg->filter.priv);
copy_proc_form_img_to_sspt(pfg->i_proc, proc);
pls = create_pl_struct(proc);
@@ -132,12 +132,12 @@ static struct sspt_proc *new_proc_by_pfg(struct pf_group *pfg,
}
/* struct pl_struct */
-static struct pf_group *create_pfg(struct proc_filter *filter)
+static struct pf_group *create_pfg(void)
{
struct pf_group *pfg = kmalloc(sizeof(*pfg), GFP_KERNEL);
INIT_LIST_HEAD(&pfg->list);
- pfg->filter = filter;
+ memset(&pfg->filter, 0, sizeof(pfg->filter));
pfg->i_proc = create_img_proc();
INIT_LIST_HEAD(&pfg->proc_list);
@@ -163,15 +163,14 @@ static void del_pfg_by_list(struct pf_group *pfg)
struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv)
{
struct pf_group *pfg;
- struct proc_filter *filter;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_pf_by_dentry(pfg->filter, dentry))
+ if (check_pf_by_dentry(&pfg->filter, dentry))
return pfg;
}
- filter = create_pf_by_dentry(dentry, priv);
- pfg = create_pfg(filter);
+ pfg = create_pfg();
+ set_pf_by_dentry(&pfg->filter, dentry, priv);
add_pfg_by_list(pfg);
@@ -182,15 +181,14 @@ EXPORT_SYMBOL_GPL(get_pf_group_by_dentry);
struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv)
{
struct pf_group *pfg;
- struct proc_filter *filter;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_pf_by_tgid(pfg->filter, tgid))
+ if (check_pf_by_tgid(&pfg->filter, tgid))
return pfg;
}
- filter = create_pf_by_tgid(tgid, priv);
- pfg = create_pfg(filter);
+ pfg = create_pfg();
+ set_pf_by_tgid(&pfg->filter, tgid, priv);
add_pfg_by_list(pfg);
@@ -201,15 +199,14 @@ EXPORT_SYMBOL_GPL(get_pf_group_by_tgid);
struct pf_group *get_pf_group_dumb(void *priv)
{
struct pf_group *pfg;
- struct proc_filter *filter;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_pf_dumb(pfg->filter))
+ if (check_pf_dumb(&pfg->filter))
return pfg;
}
- filter = create_pf_dumb(priv);
- pfg = create_pfg(filter);
+ pfg = create_pfg();
+ set_pf_dumb(&pfg->filter, priv);
add_pfg_by_list(pfg);
@@ -241,7 +238,7 @@ int check_task_on_filters(struct task_struct *task)
struct pf_group *pfg;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_task_f(pfg->filter, task))
+ if (check_task_f(&pfg->filter, task))
return 1;
}
@@ -254,7 +251,7 @@ void call_page_fault(struct task_struct *task, unsigned long page_addr)
struct sspt_proc *proc = NULL;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_task_f(pfg->filter, task) == NULL)
+ if (check_task_f(&pfg->filter, task) == NULL)
continue;
proc = get_proc_by_pfg(pfg, task);
@@ -272,7 +269,7 @@ void call_page_fault(struct task_struct *task, unsigned long page_addr)
if (pfg_first) {
struct dentry *dentry;
- dentry = get_dentry_by_pf(pfg_first->filter);
+ dentry = get_dentry_by_pf(&pfg_first->filter);
if (dentry == NULL) {
dentry = task->mm->exe_file ?
task->mm->exe_file->f_dentry :
diff --git a/us_manager/pf/proc_filters.c b/us_manager/pf/proc_filters.c
index c916625b..66757a4f 100644
--- a/us_manager/pf/proc_filters.c
+++ b/us_manager/pf/proc_filters.c
@@ -77,48 +77,25 @@ static struct task_struct *call_dumb(struct proc_filter *self,
return task;
}
-static struct proc_filter *create_pf(void)
+void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry, void *priv)
{
- struct proc_filter *pf = kmalloc(sizeof(*pf), GFP_KERNEL);
-
- return pf;
-}
-
-struct proc_filter *create_pf_by_dentry(struct dentry *dentry, void *priv)
-{
- struct proc_filter *pf = create_pf();
-
pf->call = &call_by_dentry;
pf->data = (void *)dentry;
pf->priv = priv;
-
- return pf;
}
-struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv)
-{
- struct proc_filter *pf = create_pf();
+void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv)
+{
pf->call = &call_by_tgid;
pf->data = (void *)tgid;
pf->priv = priv;
-
- return pf;
}
-struct proc_filter *create_pf_dumb(void *priv)
+void set_pf_dumb(struct proc_filter *pf, void *priv)
{
- struct proc_filter *pf = create_pf();
-
pf->call = &call_dumb;
pf->data = NULL;
pf->priv = priv;
-
- return pf;
-}
-
-void free_pf(struct proc_filter *pf)
-{
- kfree(pf);
}
int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry)
diff --git a/us_manager/pf/proc_filters.h b/us_manager/pf/proc_filters.h
index 2a007d00..8c0e0102 100644
--- a/us_manager/pf/proc_filters.h
+++ b/us_manager/pf/proc_filters.h
@@ -38,12 +38,13 @@ struct proc_filter {
void *priv;
};
-#define check_task_f(filter, task) filter->call(filter, task)
+#define check_task_f(filter, task) (filter)->call(filter, task)
+
+void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry,
+ void *priv);
+void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv);
+void set_pf_dumb(struct proc_filter *pf, void *priv);
-struct proc_filter *create_pf_by_dentry(struct dentry *dentry, void *priv);
-struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv);
-struct proc_filter *create_pf_dumb(void *priv);
-void free_pf(struct proc_filter *pf);
int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry);
int check_pf_by_tgid(struct proc_filter *filter, pid_t tgid);