Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 362605
b: refs/heads/master
c: 5c51543
h: refs/heads/master
i:
  362603: 053c990
v: v3
  • Loading branch information
Masami Hiramatsu authored and Linus Torvalds committed Apr 18, 2013
1 parent 85e3fc9 commit 25ad5a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 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: d202f05158442396033f416df376f8ece1f563df
refs/heads/master: 5c51543b0ae45967cfa99ca16748dc72888cc265
19 changes: 13 additions & 6 deletions trunk/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,16 +794,16 @@ static __kprobes void try_to_optimize_kprobe(struct kprobe *p)
}

#ifdef CONFIG_SYSCTL
/* This should be called with kprobe_mutex locked */
static void __kprobes optimize_all_kprobes(void)
{
struct hlist_head *head;
struct kprobe *p;
unsigned int i;

mutex_lock(&kprobe_mutex);
/* If optimization is already allowed, just return */
if (kprobes_allow_optimization)
return;
goto out;

kprobes_allow_optimization = true;
for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
Expand All @@ -813,18 +813,22 @@ static void __kprobes optimize_all_kprobes(void)
optimize_kprobe(p);
}
printk(KERN_INFO "Kprobes globally optimized\n");
out:
mutex_unlock(&kprobe_mutex);
}

/* This should be called with kprobe_mutex locked */
static void __kprobes unoptimize_all_kprobes(void)
{
struct hlist_head *head;
struct kprobe *p;
unsigned int i;

mutex_lock(&kprobe_mutex);
/* If optimization is already prohibited, just return */
if (!kprobes_allow_optimization)
if (!kprobes_allow_optimization) {
mutex_unlock(&kprobe_mutex);
return;
}

kprobes_allow_optimization = false;
for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
Expand All @@ -834,27 +838,30 @@ static void __kprobes unoptimize_all_kprobes(void)
unoptimize_kprobe(p, false);
}
}
mutex_unlock(&kprobe_mutex);

/* Wait for unoptimizing completion */
wait_for_kprobe_optimizer();
printk(KERN_INFO "Kprobes globally unoptimized\n");
}

static DEFINE_MUTEX(kprobe_sysctl_mutex);
int sysctl_kprobes_optimization;
int proc_kprobes_optimization_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length,
loff_t *ppos)
{
int ret;

mutex_lock(&kprobe_mutex);
mutex_lock(&kprobe_sysctl_mutex);
sysctl_kprobes_optimization = kprobes_allow_optimization ? 1 : 0;
ret = proc_dointvec_minmax(table, write, buffer, length, ppos);

if (sysctl_kprobes_optimization)
optimize_all_kprobes();
else
unoptimize_all_kprobes();
mutex_unlock(&kprobe_mutex);
mutex_unlock(&kprobe_sysctl_mutex);

return ret;
}
Expand Down

0 comments on commit 25ad5a2

Please sign in to comment.