.pre_handler = do_exit_handler
};
-static int __task_data_init(void *data)
+static int __set_helper_probes(void)
{
- struct task_struct *g, *t;
unsigned long addr;
int ret;
if (ret)
goto unreg_copy_process;
- do_each_thread(g, t) {
- swap_task_data_clean(t);
- } while_each_thread(g, t);
-
return 0;
unreg_copy_process:
return ret;
}
+static void __remove_helper_probes(void)
+{
+ swap_unregister_kretprobe(©_process_rp);
+ swap_unregister_kprobe(&do_exit_probe);
+}
+
+static int __task_data_init(void *data)
+{
+ struct task_struct *g, *t;
+
+ do_each_thread(g, t) {
+ swap_task_data_clean(t);
+ } while_each_thread(g, t);
+
+ return 0;
+
+
+}
+
static int __task_data_exit(void *data)
{
struct task_struct *g, *t;
struct task_data *td;
- swap_unregister_kprobe(&do_exit_probe);
-
do_each_thread(g, t) {
td = __td(t);
__td_free(td);
{
int ret;
+ ret = __set_helper_probes();
+ if (ret)
+ return;
+
/* stop_machine: cannot get tasklist_lock from module */
ret = stop_machine(__task_data_init, NULL, NULL);
if (ret)
{
int ret;
- swap_unregister_kretprobe(©_process_rp);
+ __remove_helper_probes();
/* stop_machine: the same here */
ret = stop_machine(__task_data_exit, NULL, NULL);