Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 615d0ebb authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Ingo Molnar
Browse files

kprobes: Disable booster when CONFIG_PREEMPT=y



Disable kprobe booster when CONFIG_PREEMPT=y at this time,
because it can't ensure that all kernel threads preempted on
kprobe's boosted slot run out from the slot even using
freeze_processes().

The booster on preemptive kernel will be resumed if
synchronize_tasks() or something like that is introduced.

Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Mathieu Desnoyers <compudj@krystal.dyndns.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20100202214904.4694.24330.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 57d81889
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -870,7 +870,7 @@ static int __kprobes pre_kprobes_handler(struct die_args *args)
		return 1;
		return 1;


ss_probe:
ss_probe:
#if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER)
#if !defined(CONFIG_PREEMPT)
	if (p->ainsn.inst_flag == INST_FLAG_BOOSTABLE && !p->post_handler) {
	if (p->ainsn.inst_flag == INST_FLAG_BOOSTABLE && !p->post_handler) {
		/* Boost up -- we can execute copied instructions directly */
		/* Boost up -- we can execute copied instructions directly */
		ia64_psr(regs)->ri = p->ainsn.slot;
		ia64_psr(regs)->ri = p->ainsn.slot;
+1 −1
Original line number Original line Diff line number Diff line
@@ -429,7 +429,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
				       struct kprobe_ctlblk *kcb)
				       struct kprobe_ctlblk *kcb)
{
{
#if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER)
#if !defined(CONFIG_PREEMPT)
	if (p->ainsn.boostable == 1 && !p->post_handler) {
	if (p->ainsn.boostable == 1 && !p->post_handler) {
		/* Boost up -- we can execute copied instructions directly */
		/* Boost up -- we can execute copied instructions directly */
		reset_current_kprobe();
		reset_current_kprobe();
+2 −27
Original line number Original line Diff line number Diff line
@@ -124,30 +124,6 @@ static LIST_HEAD(kprobe_insn_pages);
static int kprobe_garbage_slots;
static int kprobe_garbage_slots;
static int collect_garbage_slots(void);
static int collect_garbage_slots(void);


static int __kprobes check_safety(void)
{
	int ret = 0;
#if defined(CONFIG_PREEMPT) && defined(CONFIG_FREEZER)
	ret = freeze_processes();
	if (ret == 0) {
		struct task_struct *p, *q;
		do_each_thread(p, q) {
			if (p != current && p->state == TASK_RUNNING &&
			    p->pid != 0) {
				printk("Check failed: %s is running\n",p->comm);
				ret = -1;
				goto loop_end;
			}
		} while_each_thread(p, q);
	}
loop_end:
	thaw_processes();
#else
	synchronize_sched();
#endif
	return ret;
}

/**
/**
 * __get_insn_slot() - Find a slot on an executable page for an instruction.
 * __get_insn_slot() - Find a slot on an executable page for an instruction.
 * We allocate an executable page if there's no room on existing ones.
 * We allocate an executable page if there's no room on existing ones.
@@ -235,9 +211,8 @@ static int __kprobes collect_garbage_slots(void)
{
{
	struct kprobe_insn_page *kip, *next;
	struct kprobe_insn_page *kip, *next;


	/* Ensure no-one is preepmted on the garbages */
	/* Ensure no-one is interrupted on the garbages */
	if (check_safety())
	synchronize_sched();
		return -EAGAIN;


	list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) {
	list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) {
		int i;
		int i;