uprobes: Turn add_utask() into get_utask()
Rename add_utask() into get_utask() and change it to allocate on demand to simplify the caller. Like get_xol_area() it will have more users. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Anton Arapov <anton@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
This commit is contained in:
parent
9b545df809
commit
5a2df662aa
1 changed files with 9 additions and 18 deletions
|
@ -1290,23 +1290,18 @@ void uprobe_copy_process(struct task_struct *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a uprobe_task object for the task.
|
* Allocate a uprobe_task object for the task if if necessary.
|
||||||
* Called when the thread hits a breakpoint for the first time.
|
* Called when the thread hits a breakpoint.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* - pointer to new uprobe_task on success
|
* - pointer to new uprobe_task on success
|
||||||
* - NULL otherwise
|
* - NULL otherwise
|
||||||
*/
|
*/
|
||||||
static struct uprobe_task *add_utask(void)
|
static struct uprobe_task *get_utask(void)
|
||||||
{
|
{
|
||||||
struct uprobe_task *utask;
|
if (!current->utask)
|
||||||
|
current->utask = kzalloc(sizeof(struct uprobe_task), GFP_KERNEL);
|
||||||
utask = kzalloc(sizeof *utask, GFP_KERNEL);
|
return current->utask;
|
||||||
if (unlikely(!utask))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
current->utask = utask;
|
|
||||||
return utask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare to single-step probed instruction out of line. */
|
/* Prepare to single-step probed instruction out of line. */
|
||||||
|
@ -1505,13 +1500,9 @@ 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 = current->utask;
|
utask = get_utask();
|
||||||
if (!utask) {
|
if (!utask)
|
||||||
utask = add_utask();
|
goto out; /* re-execute the instruction. */
|
||||||
/* Cannot allocate; re-execute the instruction. */
|
|
||||||
if (!utask)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
handler_chain(uprobe, regs);
|
handler_chain(uprobe, regs);
|
||||||
if (can_skip_sstep(uprobe, regs))
|
if (can_skip_sstep(uprobe, regs))
|
||||||
|
|
Loading…
Add table
Reference in a new issue