Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223884
b: refs/heads/master
c: 0490cd1
h: refs/heads/master
v: v3
  • Loading branch information
Masami Hiramatsu authored and Ingo Molnar committed Dec 6, 2010
1 parent 8462665 commit 865e13e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6274de4984a630b45c6934b3ee62e5692c745328
refs/heads/master: 0490cd1f9d99569d3bd64e17adc88db06a5007be
32 changes: 30 additions & 2 deletions trunk/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,27 @@ static __kprobes void unoptimize_kprobe(struct kprobe *p, bool force)
}
}

/* Cancel unoptimizing for reusing */
static void reuse_unused_kprobe(struct kprobe *ap)
{
struct optimized_kprobe *op;

BUG_ON(!kprobe_unused(ap));
/*
* Unused kprobe MUST be on the way of delayed unoptimizing (means
* there is still a relative jump) and disabled.
*/
op = container_of(ap, struct optimized_kprobe, kp);
if (unlikely(list_empty(&op->list)))
printk(KERN_WARNING "Warning: found a stray unused "
"aggrprobe@%p\n", ap->addr);
/* Enable the probe again */
ap->flags &= ~KPROBE_FLAG_DISABLED;
/* Optimize it again (remove from op->list) */
BUG_ON(!kprobe_optready(ap));
optimize_kprobe(ap);
}

/* Remove optimized instructions */
static void __kprobes kill_optimized_kprobe(struct kprobe *p)
{
Expand Down Expand Up @@ -872,6 +893,13 @@ static void __kprobes __disarm_kprobe(struct kprobe *p, bool reopt)
#define kprobe_disarmed(p) kprobe_disabled(p)
#define wait_for_kprobe_optimizer() do {} while (0)

/* There should be no unused kprobes can be reused without optimization */
static void reuse_unused_kprobe(struct kprobe *ap)
{
printk(KERN_ERR "Error: There should be no unused kprobe here.\n");
BUG_ON(kprobe_unused(ap));
}

static __kprobes void free_aggr_kprobe(struct kprobe *p)
{
arch_remove_kprobe(p);
Expand Down Expand Up @@ -1173,8 +1201,8 @@ static int __kprobes register_aggr_kprobe(struct kprobe *orig_p,
return -ENOMEM;
init_aggr_kprobe(ap, orig_p);
} else if (kprobe_unused(ap))
/* Busy to die */
return -EBUSY;
/* This probe is going to die. Rescue it */
reuse_unused_kprobe(ap);

if (kprobe_gone(ap)) {
/*
Expand Down

0 comments on commit 865e13e

Please sign in to comment.