This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] kprobe-booster: boosting multi-probe


Hi,

I developed a patch to enhance boost-ability of multi-probes.
Please review it.

Currently, the boosting process of a kprobe is disabled by
inserting another probe to the same address.
This will be occurred easily, because both of a kprobe and
a kretprobe are inserted to the top of a function when a
SystemTap user would like to measure the processing time
of that function.

One of the reasons of this degradation is the aggregator kprobe
always registers four kind of handlers(pre_handler, post_handler,
break_handler and fault_handler) even if aggregated probes do NOT
have post_handlers and break_handler. The boosted kprobe can
NOT have post_handler and break_handler, because boosting process
skips post processing of probing to accelerate process.
Also, the break_handler is special handler. The execution path of
break_handler skips boosting routine. So, currently the probe that
has break_handler is not boosted.

Multi-probe booster
===================
- Boosting the probes which are inserted to the same address as
  far as those do not have post_handler and break_handler.
- Set post_handler and break_handler of the aggregator probe to
  NULL if the aggregated probe does not have post_handler and
  break_handler.


This patch is elementary against linux-2.6.16-rc2-mm1.
Before applying this patch, you must apply the patch posted by
Mao Bibo which can be accessed from following URL:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=2294#c3

-- 
Masami HIRAMATSU
2nd Research Dept.
Hitachi, Ltd., Systems Development Laboratory
E-mail: hiramatu@sdl.hitachi.co.jp

 kprobes.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)
diff -Narup a/kernel/kprobes.c b/kernel/kprobes.c
--- a/kernel/kprobes.c	2006-02-15 10:48:32.000000000 +0900
+++ b/kernel/kprobes.c	2006-02-16 16:56:12.000000000 +0900
@@ -370,6 +370,11 @@ static int __kprobes add_new_kprobe(stru
 {
         struct kprobe *kp;

+	if (p->post_handler || p->break_handler) { /* For more boostability */
+		old_p->post_handler = aggr_post_handler;
+		old_p->break_handler = aggr_break_handler;
+	}
+
 	if (p->break_handler) {
 		list_for_each_entry_rcu(kp, &old_p->list, list) {
 			if (kp->break_handler)
@@ -390,16 +395,30 @@ static inline void add_aggr_kprobe(struc
 	copy_kprobe(p, ap);
 	ap->addr = p->addr;
 	ap->pre_handler = aggr_pre_handler;
-	ap->post_handler = aggr_post_handler;
 	ap->fault_handler = aggr_fault_handler;
-	ap->break_handler = aggr_break_handler;
-
+	if (p->post_handler || p->break_handler) { /* For more boostability */
+		ap->post_handler = aggr_post_handler;
+		ap->break_handler = aggr_break_handler;
+	}
 	INIT_LIST_HEAD(&ap->list);
 	list_add_rcu(&p->list, &ap->list);

 	hlist_replace_rcu(&p->hlist, &ap->hlist);
 }

+static inline void boost_aggr_kprobe(struct kprobe *ap)
+{
+        struct kprobe *kp;
+	if (ap->post_handler || ap->break_handler) {
+		list_for_each_entry_rcu(kp, &ap->list, list) {
+			if (kp->post_handler || kp->break_handler)
+				return;
+		}
+	}
+	ap->post_handler = NULL;
+	ap->break_handler = NULL;
+}
+
 /*
  * This is the second or subsequent kprobe at the address - handle
  * the intricacies
@@ -536,6 +555,8 @@ valid_p:
 			kfree(old_p);
 		}
 		arch_remove_kprobe(p);
+	} else {
+		boost_aggr_kprobe(old_p);
 	}
 }




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]