[FIX] Call call_mm_release using kjump 48/46848/4
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 20 Aug 2015 21:37:24 +0000 (00:37 +0300)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Fri, 28 Aug 2015 06:05:31 +0000 (23:05 -0700)
Needed to move the call out of atomic context.

Change-Id: I3688814f09fa5be082fc3e5a203241b1c1eb77e0
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
us_manager/helper.c

index 8d9882f..b762e08 100644 (file)
@@ -324,24 +324,38 @@ static void unregister_cp(void)
  ******************************************************************************
  */
 
+/* FIXME: sync with stop */
+static unsigned long mr_cb(void *data)
+{
+       struct task_struct *task = *(struct task_struct **)data;
+
+       if (task->tgid != task->pid) {
+               /* if the thread is killed we need to discard pending
+                * uretprobe instances which have not triggered yet */
+               swap_discard_pending_uretprobes(task);
+       } else {
+               call_mm_release(task);
+       }
+
+       return 0;
+}
+
 /* Detects when target process removes IPs. */
 static int mr_pre_handler(struct kprobe *p, struct pt_regs *regs)
 {
+       int ret = 0;
        struct task_struct *task = (struct task_struct *)swap_get_karg(regs, 0);
 
        if (is_kthread(task))
                goto out;
 
-       if (task->tgid != task->pid) {
-               /* if the thread is killed we need to discard pending
-                * uretprobe instances which have not triggered yet */
-               swap_discard_pending_uretprobes(task);
-               goto out;
+       ret = set_kjump_cb(regs, mr_cb, (void *)&task, sizeof(task));
+       if (ret < 0) {
+               printk("##### ERROR: mr_pre_handler, ret=%d\n", ret);
+               ret = 0;
        }
-
-       call_mm_release(task);
 out:
-       return 0;
+       return ret;
 }
 
 static struct kprobe mr_kprobe = {