Skip to content

Commit c5356ab

Browse files
oleg-nesterovPeter Zijlstra
authored andcommitted
uprobes: pass utask to xol_get_insn_slot() and xol_free_insn_slot()
Add the "struct uprobe_task *utask" argument to xol_get_insn_slot() and xol_free_insn_slot(), their callers already have it so we can avoid the unnecessary dereference and simplify the code. Kill the "tsk" argument of xol_free_insn_slot(), it is always current. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1cee988 commit c5356ab

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

kernel/events/uprobes.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,9 +1647,8 @@ static unsigned long xol_take_insn_slot(struct xol_area *area)
16471647
/*
16481648
* xol_get_insn_slot - allocate a slot for xol.
16491649
*/
1650-
static bool xol_get_insn_slot(struct uprobe *uprobe)
1650+
static bool xol_get_insn_slot(struct uprobe *uprobe, struct uprobe_task *utask)
16511651
{
1652-
struct uprobe_task *utask = current->utask;
16531652
struct xol_area *area = get_xol_area();
16541653

16551654
if (!area)
@@ -1664,12 +1663,12 @@ static bool xol_get_insn_slot(struct uprobe *uprobe)
16641663
/*
16651664
* xol_free_insn_slot - free the slot allocated by xol_get_insn_slot()
16661665
*/
1667-
static void xol_free_insn_slot(struct task_struct *tsk)
1666+
static void xol_free_insn_slot(struct uprobe_task *utask)
16681667
{
1669-
struct xol_area *area = tsk->mm->uprobes_state.xol_area;
1670-
unsigned long offset = tsk->utask->xol_vaddr - area->vaddr;
1668+
struct xol_area *area = current->mm->uprobes_state.xol_area;
1669+
unsigned long offset = utask->xol_vaddr - area->vaddr;
16711670

1672-
tsk->utask->xol_vaddr = 0;
1671+
utask->xol_vaddr = 0;
16731672
/*
16741673
* xol_vaddr must fit into [area->vaddr, area->vaddr + PAGE_SIZE).
16751674
* This check can only fail if the "[uprobes]" vma was mremap'ed.
@@ -1951,15 +1950,15 @@ pre_ssout(struct uprobe *uprobe, struct pt_regs *regs, unsigned long bp_vaddr)
19511950
if (!try_get_uprobe(uprobe))
19521951
return -EINVAL;
19531952

1954-
if (!xol_get_insn_slot(uprobe)) {
1953+
if (!xol_get_insn_slot(uprobe, utask)) {
19551954
err = -ENOMEM;
19561955
goto err_out;
19571956
}
19581957

19591958
utask->vaddr = bp_vaddr;
19601959
err = arch_uprobe_pre_xol(&uprobe->arch, regs);
19611960
if (unlikely(err)) {
1962-
xol_free_insn_slot(current);
1961+
xol_free_insn_slot(utask);
19631962
goto err_out;
19641963
}
19651964

@@ -2307,7 +2306,7 @@ static void handle_singlestep(struct uprobe_task *utask, struct pt_regs *regs)
23072306
put_uprobe(uprobe);
23082307
utask->active_uprobe = NULL;
23092308
utask->state = UTASK_RUNNING;
2310-
xol_free_insn_slot(current);
2309+
xol_free_insn_slot(utask);
23112310

23122311
spin_lock_irq(&current->sighand->siglock);
23132312
recalc_sigpending(); /* see uprobe_deny_signal() */

0 commit comments

Comments
 (0)