Skip to contentSkip to conversation

Linux Kernel Markers 0.3 for Linux 2.6.17

PATCH New Mathieu Desnoyers 1 participant 1 message Sep 20, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Linux Kernel Markers 0.3 for Linux 2.6.17

Hi,

Following the advices I received, and reusing Frank's marker mechanism, I made a much simplified, yet very very low impact, version of markers.

Only two modes (can be both enabled) :

* Replace markers by a symbol
* Replace markers by a jump over an inactive call

Absolutely no code polymorphism is necessary and it is fully portable. Dynamically overriding addresses at those symbols at runtime (both the jump target and the function call address) permits dynamic activation of instrumentation. On-the-fly removal of the instrumentation is possible, as well as unloading of its module.

Jump impact : 1.16 cycles (see tests below)

Comments are welcome. :)

Mathieu

* Tests

Tests (load value, test and predicted branch in a loop vs load value and jump to this address) show that there is a performance amelioration with the approach I propose. (tests done in user space (upper-bound))

This is on a 3Ghz Pentium 4 with hyperthreading enabled

No instrumentation at all, simply running a loop:
Cycles for 1000000000 loops : 6595327792
(avg. 6.59 cycles per loop)

This load+jump approach :
Cycles for 1000000000 loops of load+jump : 7756373910 (avg. 7.75 cycles per loop)

Frank "predicted branch" approach :
Cycles for 1000000000 loops of load,test+predicted branch : 10036469235 (avg. 10.03 cycles per loop)

So, Frank's approach seems to add a 3.44 cycles each time the sleeping probe is hit, while my approach adds 1.16 cycles.

--- BEGIN ---

arch/i386/Kconfig +2 -0
@@ -1082,6 +1082,8 @@ config KPROBES
 	  for kernel debugging, non-intrusive instrumentation and testing.
 	  If in doubt, say "N".
 
+source "kernel/Kconfig.marker"
+
 source "ltt/Kconfig"
 
 endmenu
include/linux/marker.h new file +76 -0

76 lines not on this page · raw message

init/main.c +7 -0
@@ -737,3 +737,10 @@ static int init(void * unused)
 
 	panic("No init found.  Try passing init= option to kernel.");
 }
+
+#ifdef CONFIG_MARK_JUMP
+void __mark_empty_function(const char *fmt, ...)
+{
+}
+EXPORT_SYMBOL(__mark_empty_function);
+#endif
kernel/Kconfig.marker new file +18 -0
@@ -0,0 +1,18 @@
+# Code markers configuration
+
+menu "Marker configuration"
+
+
+config MARK_SYMBOL
+	bool "Replace markers with symbols"
+	default n
+	help
+	  Put symbols in place of markers, useful for kprobe.
+
+config MARK_JUMP
+	bool "Replace markers with a jump over an inactive function call"
+	default n
+	help
+	  Put a jump over a call in place of markers.
+
+endmenu

--- END ---

OpenPGP public key:              http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint:     8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68