[FIX] add proc_probes_list usage synchronization 89/48689/1
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 24 Sep 2015 18:45:25 +0000 (21:45 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 24 Sep 2015 18:45:25 +0000 (21:45 +0300)
Change-Id: I0422bbc212db8f63d7ee61ec703b5fc104af0b24
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
us_manager/helper.c
us_manager/pf/pf_group.c
us_manager/sspt/sspt_proc.c
us_manager/sspt/sspt_proc.h
us_manager/us_manager.c

index 16fd584..51b4566 100644 (file)
@@ -266,7 +266,7 @@ static void rm_uprobes_child(struct kretprobe_instance *ri,
        };
 
        sspt_proc_write_lock();
-       proc = sspt_proc_get_by_task(current);
+       proc = sspt_proc_get_by_task_no_lock(current);
        if (proc) {
                sspt_proc_on_each_ip(proc, func_uinst_creare, (void *)&cdata.head);
                urinst_info_get_current_hlist(&cdata.rhead, false);
@@ -425,7 +425,7 @@ static unsigned long mr_cb(void *data)
                /* if the thread is killed we need to discard pending
                 * uretprobe instances which have not triggered yet */
                sspt_proc_write_lock();
-               proc = sspt_proc_get_by_task(task);
+               proc = sspt_proc_get_by_task_no_lock(task);
                if (proc) {
                        urinst_info_get_current_hlist(&head, true);
                }
@@ -563,7 +563,7 @@ static void remove_unmap_probes(struct task_struct *task,
 
        sspt_proc_write_lock();
 
-       proc = sspt_proc_get_by_task(task);
+       proc = sspt_proc_get_by_task_no_lock(task);
        if (proc)
                __remove_unmap_probes(proc, umd);
 
index bed4849..0f397c5 100644 (file)
@@ -590,7 +590,7 @@ void call_mm_release(struct task_struct *task)
        struct sspt_proc *proc;
 
        sspt_proc_write_lock();
-       proc = sspt_proc_get_by_task(task);
+       proc = sspt_proc_get_by_task_no_lock(task);
        if (proc)
                list_del(&proc->list);
        sspt_proc_write_unlock();
index 1c066ce..6a19022 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/list.h>
 #include <us_manager/us_slot_manager.h>
 
-
 static LIST_HEAD(proc_probes_list);
 static DEFINE_RWLOCK(sspt_proc_rwlock);
 
@@ -169,13 +168,25 @@ void sspt_proc_put(struct sspt_proc *proc)
        }
 }
 
+struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task)
+{
+       struct sspt_proc *proc;
+
+       sspt_proc_read_lock();
+       proc = sspt_proc_get_by_task_no_lock(task);
+       sspt_proc_read_unlock();
+
+       return proc;
+}
+EXPORT_SYMBOL_GPL(sspt_proc_get_by_task);
+
 /**
  * @brief Get sspt_proc by task
  *
  * @param task Pointer on the task_struct struct
  * @return Pointer on the sspt_proc struct
  */
-struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task)
+struct sspt_proc *sspt_proc_get_by_task_no_lock(struct task_struct *task)
 {
        struct sspt_proc *proc, *tmp;
 
@@ -186,7 +197,7 @@ struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task)
 
        return NULL;
 }
-EXPORT_SYMBOL_GPL(sspt_proc_get_by_task);
+EXPORT_SYMBOL_GPL(sspt_proc_get_by_task_no_lock);
 
 /**
  * @brief Call func() on each proc (no lock)
@@ -228,9 +239,13 @@ EXPORT_SYMBOL_GPL(on_each_proc);
  */
 struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task)
 {
-       struct sspt_proc *proc = sspt_proc_get_by_task(task);
+       struct sspt_proc *proc;
+
+       sspt_proc_write_lock();
+       proc = sspt_proc_get_by_task_no_lock(task);
        if (proc == NULL)
                proc = sspt_proc_create(task);
+       sspt_proc_write_unlock();
 
        return proc;
 }
index 03a1db1..ef49948 100644 (file)
@@ -81,6 +81,7 @@ void on_each_proc_no_lock(void (*func)(struct sspt_proc *, void *),
 void on_each_proc(void (*func)(struct sspt_proc *, void *), void *data);
 
 struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task);
+struct sspt_proc *sspt_proc_get_by_task_no_lock(struct task_struct *task);
 struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task);
 void sspt_proc_free_all(void);
 
index 9638114..51e9110 100644 (file)
@@ -201,7 +201,8 @@ static int us_filter(struct task_struct *task)
 {
        struct sspt_proc *proc;
 
-       proc = sspt_proc_get_by_task(task);
+       /* FIXME: add read lock (deadlock in sampler) */
+       proc = sspt_proc_get_by_task_no_lock(task);
        if (proc)
                return sspt_proc_is_send_event(proc);