aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events/uprobes.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-12-31 11:03:32 -0500
committerOleg Nesterov <oleg@redhat.com>2013-02-08 11:47:12 -0500
commit5a2df662aafdabffb2cf3adb780a5adf66dfb3bc (patch)
tree758f73ec4d1a89c1e7ab416503732c59fd7839ee /kernel/events/uprobes.c
parent9b545df809644912552360054c7bbe8b8a9e01fa (diff)
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>
Diffstat (limited to 'kernel/events/uprobes.c')
-rw-r--r--kernel/events/uprobes.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 7e3e5c5b0d88..16e54d63a9fd 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1290,23 +1290,18 @@ void uprobe_copy_process(struct task_struct *t)
1290} 1290}
1291 1291
1292/* 1292/*
1293 * Allocate a uprobe_task object for the task. 1293 * Allocate a uprobe_task object for the task if if necessary.
1294 * Called when the thread hits a breakpoint for the first time. 1294 * Called when the thread hits a breakpoint.
1295 * 1295 *
1296 * Returns: 1296 * Returns:
1297 * - pointer to new uprobe_task on success 1297 * - pointer to new uprobe_task on success
1298 * - NULL otherwise 1298 * - NULL otherwise
1299 */ 1299 */
1300static struct uprobe_task *add_utask(void) 1300static struct uprobe_task *get_utask(void)
1301{ 1301{
1302 struct uprobe_task *utask; 1302 if (!current->utask)
1303 1303 current->utask = kzalloc(sizeof(struct uprobe_task), GFP_KERNEL);
1304 utask = kzalloc(sizeof *utask, GFP_KERNEL); 1304 return current->utask;
1305 if (unlikely(!utask))
1306 return NULL;
1307
1308 current->utask = utask;
1309 return utask;
1310} 1305}
1311 1306
1312/* Prepare to single-step probed instruction out of line. */ 1307/* Prepare to single-step probed instruction out of line. */
@@ -1505,13 +1500,9 @@ static void handle_swbp(struct pt_regs *regs)
1505 if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags))) 1500 if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
1506 goto out; 1501 goto out;
1507 1502
1508 utask = current->utask; 1503 utask = get_utask();
1509 if (!utask) { 1504 if (!utask)
1510 utask = add_utask(); 1505 goto out; /* re-execute the instruction. */
1511 /* Cannot allocate; re-execute the instruction. */
1512 if (!utask)
1513 goto out;
1514 }
1515 1506
1516 handler_chain(uprobe, regs); 1507 handler_chain(uprobe, regs);
1517 if (can_skip_sstep(uprobe, regs)) 1508 if (can_skip_sstep(uprobe, regs))