uprobes: Do not allocate current->utask unnecessary
handle_swbp() does get_utask() before can_skip_sstep() for no reason, we do not need ->utask if can_skip_sstep() succeeds. Move get_utask() to pre_ssout() who actually starts to use it. Move the initialization of utask->active_uprobe/state as well. This way the whole initialization is consolidated in pre_ssout(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Anton Arapov <anton@redhat.com>
This commit is contained in:
parent
aba51024e7
commit
608e7427c0
1 changed files with 6 additions and 10 deletions
|
@ -1308,7 +1308,9 @@ pre_ssout(struct uprobe *uprobe, struct pt_regs *regs, unsigned long bp_vaddr)
|
||||||
unsigned long xol_vaddr;
|
unsigned long xol_vaddr;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
utask = current->utask;
|
utask = get_utask();
|
||||||
|
if (!utask)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
xol_vaddr = xol_get_insn_slot(uprobe);
|
xol_vaddr = xol_get_insn_slot(uprobe);
|
||||||
if (!xol_vaddr)
|
if (!xol_vaddr)
|
||||||
|
@ -1323,6 +1325,8 @@ pre_ssout(struct uprobe *uprobe, struct pt_regs *regs, unsigned long bp_vaddr)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utask->active_uprobe = uprobe;
|
||||||
|
utask->state = UTASK_SSTEP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1474,7 +1478,6 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
|
||||||
*/
|
*/
|
||||||
static void handle_swbp(struct pt_regs *regs)
|
static void handle_swbp(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
struct uprobe_task *utask;
|
|
||||||
struct uprobe *uprobe;
|
struct uprobe *uprobe;
|
||||||
unsigned long bp_vaddr;
|
unsigned long bp_vaddr;
|
||||||
int uninitialized_var(is_swbp);
|
int uninitialized_var(is_swbp);
|
||||||
|
@ -1512,19 +1515,12 @@ static void handle_swbp(struct pt_regs *regs)
|
||||||
if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
|
if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
utask = get_utask();
|
|
||||||
if (!utask)
|
|
||||||
goto out; /* re-execute the instruction. */
|
|
||||||
|
|
||||||
handler_chain(uprobe, regs);
|
handler_chain(uprobe, regs);
|
||||||
if (can_skip_sstep(uprobe, regs))
|
if (can_skip_sstep(uprobe, regs))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!pre_ssout(uprobe, regs, bp_vaddr)) {
|
if (!pre_ssout(uprobe, regs, bp_vaddr))
|
||||||
utask->active_uprobe = uprobe;
|
|
||||||
utask->state = UTASK_SSTEP;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* can_skip_sstep() succeeded, or restart if can't singlestep */
|
/* can_skip_sstep() succeeded, or restart if can't singlestep */
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Reference in a new issue