From: Vyacheslav Cherkashin Date: Thu, 31 Mar 2016 18:48:36 +0000 (+0300) Subject: [IMPROVE] remove atomic context for sspt_proc.filter X-Git-Tag: accepted/tizen/common/20160525.155752~1^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b10665f244faa9dfaec6eef277e6aeb7d741847e;p=platform%2Fkernel%2Fswap-modules.git [IMPROVE] remove atomic context for sspt_proc.filter Change-Id: I8884fabacf97760c1f4c955117896dbdcea77ebb Signed-off-by: Vyacheslav Cherkashin --- diff --git a/us_manager/pf/pf_group.c b/us_manager/pf/pf_group.c index 16fee13..5bafc1b 100644 --- a/us_manager/pf/pf_group.c +++ b/us_manager/pf/pf_group.c @@ -506,14 +506,14 @@ static enum pf_inst_flag pfg_check_task(struct task_struct *task) } if (proc) { - write_lock(&proc->filter_lock); + mutex_lock(&proc->filters.mtx); if (sspt_proc_is_filter_new(proc, pfg)) { img_proc_copy_to_sspt(pfg->i_proc, proc); sspt_proc_add_filter(proc, pfg); pfg_add_proc(pfg, proc); flag = flag == PIF_FIRST ? flag : PIF_ADD_PFG; } - write_unlock(&proc->filter_lock); + mutex_unlock(&proc->filters.mtx); } } pfg_list_runlock(); diff --git a/us_manager/sspt/sspt_proc.c b/us_manager/sspt/sspt_proc.c index ad02a0e..2a45014 100644 --- a/us_manager/sspt/sspt_proc.c +++ b/us_manager/sspt/sspt_proc.c @@ -106,8 +106,8 @@ struct sspt_proc *sspt_proc_create(struct task_struct *task) proc->task = task->group_leader; proc->sm = create_sm_us(task); INIT_LIST_HEAD(&proc->file_head); - rwlock_init(&proc->filter_lock); - INIT_LIST_HEAD(&proc->filter_list); + mutex_init(&proc->filters.mtx); + INIT_LIST_HEAD(&proc->filters.head); atomic_set(&proc->usage, 1); get_task_struct(proc->task); @@ -454,7 +454,7 @@ void sspt_proc_add_filter(struct sspt_proc *proc, struct pf_group *pfg) f = sspt_filter_create(proc, pfg); if (f) - list_add(&f->list, &proc->filter_list); + list_add(&f->list, &proc->filters.head); } /** @@ -468,14 +468,14 @@ void sspt_proc_del_filter(struct sspt_proc *proc, struct pf_group *pfg) { struct sspt_filter *fl, *tmp; - write_lock(&proc->filter_lock); - list_for_each_entry_safe(fl, tmp, &proc->filter_list, list) { + mutex_lock(&proc->filters.mtx); + list_for_each_entry_safe(fl, tmp, &proc->filters.head, list) { if (fl->pfg == pfg) { list_del(&fl->list); sspt_filter_free(fl); } } - write_unlock(&proc->filter_lock); + mutex_unlock(&proc->filters.mtx); } /** @@ -488,12 +488,12 @@ void sspt_proc_del_all_filters(struct sspt_proc *proc) { struct sspt_filter *fl, *tmp; - write_lock(&proc->filter_lock); - list_for_each_entry_safe(fl, tmp, &proc->filter_list, list) { + mutex_lock(&proc->filters.mtx); + list_for_each_entry_safe(fl, tmp, &proc->filters.head, list) { list_del(&fl->list); sspt_filter_free(fl); } - write_unlock(&proc->filter_lock); + mutex_unlock(&proc->filters.mtx); } /** @@ -507,7 +507,7 @@ bool sspt_proc_is_filter_new(struct sspt_proc *proc, struct pf_group *pfg) { struct sspt_filter *fl; - list_for_each_entry(fl, &proc->filter_list, list) + list_for_each_entry(fl, &proc->filters.head, list) if (fl->pfg == pfg) return false; @@ -520,7 +520,7 @@ void sspt_proc_on_each_filter(struct sspt_proc *proc, { struct sspt_filter *fl; - list_for_each_entry(fl, &proc->filter_list, list) + list_for_each_entry(fl, &proc->filters.head, list) func(fl, data); } diff --git a/us_manager/sspt/sspt_proc.h b/us_manager/sspt/sspt_proc.h index 77b6438..740c9c2 100644 --- a/us_manager/sspt/sspt_proc.h +++ b/us_manager/sspt/sspt_proc.h @@ -25,6 +25,7 @@ */ #include +#include #include "sspt_file.h" struct slot_manager; @@ -56,8 +57,10 @@ struct sspt_proc { struct task_struct *__task; struct slot_manager *sm; /**< Ptr to the manager slot */ - rwlock_t filter_lock; - struct list_head filter_list; /**< Filter list */ + struct { + struct mutex mtx; /**< Mutex for filter list */ + struct list_head head; /**< Filter head */ + } filters; unsigned first_install:1; /**< Install flag */ struct sspt_feature *feature; /**< Ptr to the feature */