[IMPROVE] remove atomic context for sspt_proc.filter
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 31 Mar 2016 18:48:36 +0000 (21:48 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Tue, 12 Apr 2016 08:07:37 +0000 (11:07 +0300)
Change-Id: I8884fabacf97760c1f4c955117896dbdcea77ebb
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
us_manager/pf/pf_group.c
us_manager/sspt/sspt_proc.c
us_manager/sspt/sspt_proc.h

index 16fee13..5bafc1b 100644 (file)
@@ -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();
index ad02a0e..2a45014 100644 (file)
@@ -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);
 }
 
index 77b6438..740c9c2 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/mutex.h>
 #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 */