Change set_xol_ip() to use uprobe_xol_slots[] per-cpu array to "allocate" the insn slot. We do not care if the task migrates to another CPU before executing xol insn, set_xol_ip() will be called again by uprobe_switch_to(). Likewise, we do not care if the task is simply preempted or sleeps. IOW, uprobe_xol_slots[CPU] is "owned" by cpu_curr(CPU). This makes xol_get_insn_slot/xol_free_insn_slot unnecessary, but uprobe_notify_resume() should set utask->vaddr. The patch updates the callers but doesn't remove this code to simplify the review. Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx> --- kernel/uprobes.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/uprobes.c b/kernel/uprobes.c index 20007da..c9e2f65 100644 --- a/kernel/uprobes.c +++ b/kernel/uprobes.c @@ -1285,7 +1285,6 @@ void free_uprobe_utask(struct task_struct *tsk) if (utask->active_uprobe) put_uprobe(utask->active_uprobe); - xol_free_insn_slot(tsk); kfree(utask); tsk->utask = NULL; } @@ -1347,7 +1346,15 @@ uprobe_xol_slots[UPROBES_XOL_SLOT_BYTES][NR_CPUS] __page_aligned_bss; void __weak set_xol_ip(struct pt_regs *regs) { - set_instruction_pointer(regs, current->utask->xol_vaddr); + int cpu = smp_processor_id(); + struct uprobe_task *utask = current->utask; + struct uprobe *uprobe = utask->active_uprobe; + + memcpy(uprobe_xol_slots[cpu], uprobe->insn, MAX_UINSN_BYTES); + + utask->xol_vaddr = fix_to_virt(UPROBE_XOL_FIRST_PAGE) + + UPROBES_XOL_SLOT_BYTES * cpu; + set_instruction_pointer(regs, utask->xol_vaddr); } /* @@ -1390,14 +1397,12 @@ void uprobe_notify_resume(struct pt_regs *regs) goto cleanup_ret; } utask->active_uprobe = u; + utask->vaddr = probept; handler_chain(u, regs); if (u->flags & UPROBES_SKIP_SSTEP && can_skip_xol(regs, u)) goto cleanup_ret; - if (!xol_get_insn_slot(u, probept)) - goto cleanup_ret; - if (pre_xol(u, regs)) goto cleanup_ret; @@ -1419,7 +1424,6 @@ void uprobe_notify_resume(struct pt_regs *regs) utask->active_uprobe = NULL; utask->state = UTASK_RUNNING; user_disable_single_step(current); - xol_free_insn_slot(current); spin_lock_irq(¤t->sighand->siglock); recalc_sigpending(); /* see uprobe_deny_signal() */ -- 1.5.5.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>