Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350265
b: refs/heads/master
c: ad72b3b
h: refs/heads/master
i:
  350263: 32df3be
v: v3
  • Loading branch information
Tejun Heo committed Feb 9, 2013
1 parent f883ff4 commit 6c0681c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 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: 7c99e0bf86fdc1dee238eb6e213b980f887b68f1
refs/heads/master: ad72b3bea744b4db01c89af0f86f3e8920d354df
23 changes: 15 additions & 8 deletions trunk/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ static LIST_HEAD(unoptimizing_list);

static void kprobe_optimizer(struct work_struct *work);
static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer);
static DECLARE_COMPLETION(optimizer_comp);
#define OPTIMIZE_DELAY 5

/*
Expand Down Expand Up @@ -552,8 +551,7 @@ static __kprobes void do_free_cleaned_kprobes(struct list_head *free_list)
/* Start optimizer after OPTIMIZE_DELAY passed */
static __kprobes void kick_kprobe_optimizer(void)
{
if (!delayed_work_pending(&optimizing_work))
schedule_delayed_work(&optimizing_work, OPTIMIZE_DELAY);
schedule_delayed_work(&optimizing_work, OPTIMIZE_DELAY);
}

/* Kprobe jump optimizer */
Expand Down Expand Up @@ -592,16 +590,25 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)
/* Step 5: Kick optimizer again if needed */
if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
kick_kprobe_optimizer();
else
/* Wake up all waiters */
complete_all(&optimizer_comp);
}

/* Wait for completing optimization and unoptimization */
static __kprobes void wait_for_kprobe_optimizer(void)
{
if (delayed_work_pending(&optimizing_work))
wait_for_completion(&optimizer_comp);
mutex_lock(&kprobe_mutex);

while (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list)) {
mutex_unlock(&kprobe_mutex);

/* this will also make optimizing_work execute immmediately */
flush_delayed_work(&optimizing_work);
/* @optimizing_work might not have been queued yet, relax */
cpu_relax();

mutex_lock(&kprobe_mutex);
}

mutex_unlock(&kprobe_mutex);
}

/* Optimize kprobe if p is ready to be optimized */
Expand Down

0 comments on commit 6c0681c

Please sign in to comment.