From: Vasiliy Ulyanov Date: Mon, 20 Jul 2015 10:12:30 +0000 (+0300) Subject: [FIX] Init/uninit task_data at start/stop X-Git-Tag: submit/tizen_2.4/20150912.103527~52 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F44281%2F2;p=kernel%2Fswap-modules.git [FIX] Init/uninit task_data at start/stop task_data uses kernel probes to track all tasks, hence it is not correct to initialize it at module load time. Change-Id: Ibb23d055cc9d0ae2703db8b09fb4d27e6d91e2c8 Signed-off-by: Vasiliy Ulyanov --- diff --git a/task_data/task_data.c b/task_data/task_data.c index 0599f23..51f1578 100644 --- a/task_data/task_data.c +++ b/task_data/task_data.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "task_data.h" /* lower bits are used as flags */ @@ -26,6 +27,9 @@ struct task_data { #define get_magic(td) ((td)->magic & TD_MAGIC_MASK) #define get_flags(td) ((td)->magic & TD_FLAGS_MASK) +static int __task_data_cbs_start_h = -1; +static int __task_data_cbs_stop_h = -1; + static inline struct task_data *__td(struct task_struct *task) { return (struct task_data *)(end_of_stack(task) + TD_OFFSET); @@ -167,7 +171,7 @@ static int __task_data_exit(void *data) return 0; } -static int task_data_init(void) +static void task_data_start(void) { int ret; @@ -175,11 +179,9 @@ static int task_data_init(void) ret = stop_machine(__task_data_init, NULL, NULL); if (ret) printk(TD_PREFIX "task data initialization failed: %d\n", ret); - - return ret; } -static void task_data_exit(void) +static void task_data_stop(void) { int ret; @@ -194,6 +196,36 @@ static void task_data_exit(void) } } +static int task_data_init(void) +{ + int ret = 0; + + __task_data_cbs_start_h = us_manager_reg_cb(START_CB, task_data_start); + + if (__task_data_cbs_start_h < 0) { + ret = __task_data_cbs_start_h; + printk(KERN_ERR TD_PREFIX "start_cb registration failed\n"); + goto out; + } + + __task_data_cbs_stop_h = us_manager_reg_cb(STOP_CB, task_data_stop); + + if (__task_data_cbs_stop_h < 0) { + ret = __task_data_cbs_stop_h; + us_manager_unreg_cb(__task_data_cbs_start_h); + printk(KERN_ERR TD_PREFIX "stop_cb registration failed\n"); + } + +out: + return ret; +} + +static void task_data_exit(void) +{ + us_manager_unreg_cb(__task_data_cbs_start_h); + us_manager_unreg_cb(__task_data_cbs_stop_h); +} + SWAP_LIGHT_INIT_MODULE(NULL, task_data_init, task_data_exit, NULL, NULL);