[FIX] Kprobe: new task_data 62/51862/3
authorAlexander Aksenov <a.aksenov@samsung.com>
Mon, 16 Nov 2015 14:26:17 +0000 (17:26 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Thu, 19 Nov 2015 11:29:45 +0000 (14:29 +0300)
Issue:
- Modules aren't built for kernels older than 3.1, cause
there is no jobctl in task_struct.
- Old task_data module mention remained in spec file

Solution:
- Make jobctl using version-dependent
- Remove remained task_data module from spec

Change-Id: Ie7ae6fc2dc38b221c3780846d1c1ca9fd163efaa
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
kprobe/swap_kprobes_deps.h
kprobe/swap_ktd.c

index 2a4bc69..e555ecb 100644 (file)
@@ -89,6 +89,14 @@ do { \
 #endif /* !(defined(MODULE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
 
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 1, 0)
+    #define task_job(task) (task->jobctl)
+#else /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 1, 0) */
+    #define task_job(task) (task->group_stop)
+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 1, 0) */
+
+
+
 /* --------------------- Declaration of module dependencies ----------------- */
 
 #define DECLARE_MOD_FUNC_DEP(name, ret, ...) ret(*__ref_##name)(__VA_ARGS__)
index 79d1ef0..2eb333f 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <kprobe/swap_kprobes.h>
+#include <kprobe/swap_kprobes_deps.h>
 #include <ksyms/ksyms.h>
 #include "swap_ktd.h"
 #include "swap_td_raw.h"
@@ -110,13 +111,13 @@ static void ktd_exit_all(struct td *td, struct task_struct *task)
 
 static bool task_prepare_is(struct task_struct *task)
 {
-       return !!(task->jobctl & kTD_JOBCTL_PREPARE);
+       return !!(task_job(task) & kTD_JOBCTL_PREPARE);
 }
 
 static void task_prepare_set(struct task_struct *task)
 {
-       if (!(task->jobctl & kTD_JOBCTL_PREPARE))
-               task->jobctl |= kTD_JOBCTL_PREPARE;
+       if (!(task_job(task) & kTD_JOBCTL_PREPARE))
+               task_job(task) |= kTD_JOBCTL_PREPARE;
        else
                WARN(1, KTD_PREFIX "already prepare");
 
@@ -125,8 +126,8 @@ static void task_prepare_set(struct task_struct *task)
 
 static void task_prepare_clear(struct task_struct *task)
 {
-       if (task->jobctl & kTD_JOBCTL_PREPARE)
-               task->jobctl &= ~kTD_JOBCTL_PREPARE;
+       if (task_job(task) & kTD_JOBCTL_PREPARE)
+               task_job(task) &= ~kTD_JOBCTL_PREPARE;
        else
                WARN(1, KTD_PREFIX "is not prepare");