}
}
-#ifdef CONFIG_SWAP_HOOK_SWITCH_TO
-
-static void handler_switch(struct task_struct *prev,
- struct task_struct *next)
+static void switch_handler(struct task_struct *prev, struct task_struct *next)
{
int cpu = smp_processor_id();
switch_handler_next(next, cpu);
}
+#ifdef CONFIG_SWAP_HOOK_SWITCH_TO
+
static struct swap_hook_ctx switch_to_hook = {
- .hook = handler_switch
+ .hook = switch_handler
};
static int switch_to_enable(void)
#else /* CONFIG_SWAP_HOOK_SWITCH_TO */
-static int ret_handler_switch(struct kretprobe_instance *ri,
- struct pt_regs *regs)
+static int kp_switch_handler(struct kprobe *p, struct pt_regs *regs)
{
- switch_handler_next(current, smp_processor_id());
- return 0;
-}
+ struct task_struct *prev = swap_switch_to_prev(regs);
+ struct task_struct *next = swap_switch_to_next(regs);
+
+ switch_handler(prev, next);
-static int entry_handler_switch(struct kretprobe_instance *ri,
- struct pt_regs *regs)
-{
- switch_handler_prev(current, smp_processor_id());
return 0;
}
-static struct kretprobe switch_to_krp = {
- .entry_handler = entry_handler_switch,
- .handler = ret_handler_switch,
+static struct kprobe switch_to_kp = {
+ .pre_handler = kp_switch_handler,
};
static int switch_to_once(void)
{
const char *sym = "__switch_to";
- switch_to_krp.kp.addr = swap_ksyms(sym);
- if (switch_to_krp.kp.addr == 0) {
+ switch_to_kp.addr = swap_ksyms(sym);
+ if (switch_to_kp.addr == 0) {
pr_err("ERROR: symbol '%s' not found\n", sym);
return -ESRCH;
}
static int switch_to_enable(void)
{
- return swap_register_kretprobe(&switch_to_krp);
+ return swap_register_kprobe(&switch_to_kp);
}
static void switch_to_disable(void)
{
- swap_unregister_kretprobe(&switch_to_krp);
+ swap_unregister_kprobe(&switch_to_kp);
}
#endif /* !CONFIG_SWAP_HOOK_SWITCH_TO */