aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-12-31 12:20:42 -0500
committerOleg Nesterov <oleg@redhat.com>2013-02-08 11:47:12 -0500
commit608e7427c0a06de0d70374a9fd7defc8eb228b7e (patch)
treefa9d008fc34cd270613b63bbd9fd724c563daa44 /kernel/events
parentaba51024e7159c93914557caaa2b8cda26331091 (diff)
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>
Diffstat (limited to 'kernel/events')
-rw-r--r--kernel/events/uprobes.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 0527379dac5b..071edcb3e62d 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1308,7 +1308,9 @@ pre_ssout(struct uprobe *uprobe, struct pt_regs *regs, unsigned long bp_vaddr)
1308 unsigned long xol_vaddr; 1308 unsigned long xol_vaddr;
1309 int err; 1309 int err;
1310 1310
1311 utask = current->utask; 1311 utask = get_utask();
1312 if (!utask)
1313 return -ENOMEM;
1312 1314
1313 xol_vaddr = xol_get_insn_slot(uprobe); 1315 xol_vaddr = xol_get_insn_slot(uprobe);
1314 if (!xol_vaddr) 1316 if (!xol_vaddr)
@@ -1323,6 +1325,8 @@ pre_ssout(struct uprobe *uprobe, struct pt_regs *regs, unsigned long bp_vaddr)
1323 return err; 1325 return err;
1324 } 1326 }
1325 1327
1328 utask->active_uprobe = uprobe;
1329 utask->state = UTASK_SSTEP;
1326 return 0; 1330 return 0;
1327} 1331}
1328 1332
@@ -1474,7 +1478,6 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
1474 */ 1478 */
1475static void handle_swbp(struct pt_regs *regs) 1479static void handle_swbp(struct pt_regs *regs)
1476{ 1480{
1477 struct uprobe_task *utask;
1478 struct uprobe *uprobe; 1481 struct uprobe *uprobe;
1479 unsigned long bp_vaddr; 1482 unsigned long bp_vaddr;
1480 int uninitialized_var(is_swbp); 1483 int uninitialized_var(is_swbp);
@@ -1512,19 +1515,12 @@ static void handle_swbp(struct pt_regs *regs)
1512 if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags))) 1515 if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
1513 goto out; 1516 goto out;
1514 1517
1515 utask = get_utask();
1516 if (!utask)
1517 goto out; /* re-execute the instruction. */
1518
1519 handler_chain(uprobe, regs); 1518 handler_chain(uprobe, regs);
1520 if (can_skip_sstep(uprobe, regs)) 1519 if (can_skip_sstep(uprobe, regs))
1521 goto out; 1520 goto out;
1522 1521
1523 if (!pre_ssout(uprobe, regs, bp_vaddr)) { 1522 if (!pre_ssout(uprobe, regs, bp_vaddr))
1524 utask->active_uprobe = uprobe;
1525 utask->state = UTASK_SSTEP;
1526 return; 1523 return;
1527 }
1528 1524
1529 /* can_skip_sstep() succeeded, or restart if can't singlestep */ 1525 /* can_skip_sstep() succeeded, or restart if can't singlestep */
1530out: 1526out: