Skip to contentSkip to conversation

markers-linker-generic

PATCH In review Mathieu Desnoyers 7 participants 23 messages Apr 10, 2007 – Apr 12, 2007

Subsystems (9)
PowerPC MIPS s390 SuperH +5 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 markers-linker-generic

Defines the linker marcro EXTRA_RWDATA for marker data section. It puts the marker data in a separate section that will not pollute the normal .data section, which minimize the cache impact. Markers need such a special section because they define a lot of spreaded and small data structures at multiple sites.

This patch also creates the __markers_strings section (ro marker strings) and makes sure the __markers section is aligned by putting it before the __ksymtab_strings (not after).

It applies on 2.6.21-rc6-mm1.

include/asm-generic/vmlinux.lds.h +13 -12
@@ -116,21 +116,19 @@
 		*(__kcrctab_gpl_future)					\
 		VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .;	\
 	}								\
-									\
-	/* Kernel symbol table: strings */				\
-        __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) {	\
-		*(__ksymtab_strings)					\
-	}								\
 	/* Kernel markers : pointers */					\
-	.markers : AT(ADDR(.markers) - LOAD_OFFSET) {			\
+	__markers : AT(ADDR(__markers) - LOAD_OFFSET) {			\
 		VMLINUX_SYMBOL(__start___markers) = .;			\
-		*(.markers)						\
+		*(__markers)						\
 		VMLINUX_SYMBOL(__stop___markers) = .;			\
 	}								\
-	.markers.c : AT(ADDR(.markers.c) - LOAD_OFFSET) {		\
-		VMLINUX_SYMBOL(__start___markers_c) = .;		\
-		*(.markers.c)						\
-		VMLINUX_SYMBOL(__stop___markers_c) = .;			\
+	/* Kernel symbol table: strings */				\
+        __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) {	\
+		*(__ksymtab_strings)					\
+	}								\
+	/* Kernel markers : strings */					\
+	__markers_strings : AT(ADDR(__markers_strings) - LOAD_OFFSET) {	\
+		*(__markers_strings)					\
 	}								\
 	__end_rodata = .;						\
 	. = ALIGN(4096);						\
@@ -147,6 +145,10 @@
 									\
 	. = ALIGN(4096);
 
+#define EXTRA_RWDATA							\
+	. = ALIGN(8);							\
+	*(__markers_data)						\
+
 #define SECURITY_INIT							\
 	.security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \
 		VMLINUX_SYMBOL(__security_initcall_start) = .;		\
@@ -263,4 +265,3 @@
   	*(.initcall6s.init)						\
   	*(.initcall7.init)						\
   	*(.initcall7s.init)
-
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#1 lore raw

PATCH 1/1 markers-linker-mips

Add EXTRA_RWDATA to mips.

arch/mips/kernel/vmlinux.lds.S +2 -0
@@ -64,6 +64,8 @@ SECTIONS
 
     *(.data)
 
+    EXTRA_RWDATA
+
     CONSTRUCTORS
   }
   _gp = . + 0x8000;
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#2 lore raw

PATCH 1/1 markers-linker-parisc

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to parisc.

arch/parisc/kernel/vmlinux.lds.S +1 -0
@@ -92,6 +92,7 @@ SECTIONS
   . = ALIGN(L1_CACHE_BYTES);
   .data : {			/* Data */
 	*(.data)
+	EXTRA_RWDATA
 	CONSTRUCTORS
 	}
 
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#3 lore raw

PATCH 1/1 markers-linker-powerpc

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to powerpc.

arch/powerpc/kernel/vmlinux.lds.S +2 -0
@@ -170,11 +170,13 @@ SECTIONS
 		*(.data)
 		*(.sdata)
 		*(.got.plt) *(.got)
+		EXTRA_RWDATA
 	}
 #else
 	.data : {
 		*(.data .data.rel* .toc1)
 		*(.branch_lt)
+		EXTRA_RWDATA
 	}
 
 	.opd : {
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#4 lore raw

PATCH 1/1 markers-linker-ppc

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to ppc.

arch/ppc/kernel/vmlinux.lds.S +1 -0
@@ -73,6 +73,7 @@ SECTIONS
     *(.sdata2)
     *(.got.plt) *(.got)
     *(.dynamic)
+    EXTRA_RWDATA
     CONSTRUCTORS
   }
 
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#5 lore raw

PATCH 1/1 markers-linker-s390

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to s390.

arch/s390/kernel/vmlinux.lds.S +1 -0
@@ -49,6 +49,7 @@ SECTIONS
 
   .data : {			/* Data */
 	*(.data)
+	EXTRA_RWDATA
 	CONSTRUCTORS
 	}
 
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#6 lore raw

PATCH 1/1 markers-linker-m68knommu

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to m68knommu.

arch/m68knommu/kernel/vmlinux.lds.S +1 -0
@@ -134,6 +134,7 @@ SECTIONS {
 		. = ALIGN(4);
 		_sdata = . ;
 		*(.data)
+		EXTRA_RWDATA
 		. = ALIGN(8192) ;
 		*(.data.init_task)
 		_edata = . ;
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#7 lore raw

PATCH 1/1 markers-linker-sh

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to sh.

arch/sh/kernel/vmlinux.lds.S +1 -0
@@ -40,6 +40,7 @@ SECTIONS
 
   .data : {			/* Data */
 	*(.data)
+	EXTRA_RWDATA
 
  	 /* Align the initial ramdisk image (INITRD) on page boundaries. */
  	 . = ALIGN(PAGE_SIZE);
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#8 lore raw

PATCH 1/1 markers-linker-sh64

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to sh64.

arch/sh64/kernel/vmlinux.lds.S +1 -0
@@ -79,6 +79,7 @@ SECTIONS
 
   .data : C_PHYS(.data) {			/* Data */
 	*(.data)
+	EXTRA_RWDATA
 	CONSTRUCTORS
 	}
 
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#9 lore raw

PATCH 1/1 markers-linker-sparc

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to sparc.

arch/sparc/kernel/vmlinux.lds.S +1 -0
@@ -23,6 +23,7 @@ SECTIONS
   .data    :
   {
     *(.data)
+    EXTRA_RWDATA
     CONSTRUCTORS
   }
   .data1   : { *(.data1) }
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#10 lore raw

PATCH 1/1 markers-linker-sparc64

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to sparc64.

arch/sparc64/kernel/vmlinux.lds.S +1 -0
@@ -28,6 +28,7 @@ SECTIONS
   .data    :
   {
     *(.data)
+    EXTRA_RWDATA
     CONSTRUCTORS
   }
   .data1   : { *(.data1) }
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#11 lore raw

PATCH 1/1 markers-linker-um

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to um.

arch/um/kernel/dyn.lds.S +1 -0
@@ -98,6 +98,7 @@ SECTIONS
     . = ALIGN(KERNEL_STACK_SIZE);		/* init_task */
     *(.data.init_task)
     *(.data .data.* .gnu.linkonce.d.*)
+    EXTRA_RWDATA
     SORT(CONSTRUCTORS)
   }
   .data1          : { *(.data1) }
arch/um/kernel/uml.lds.S +1 -0
@@ -61,6 +61,7 @@ SECTIONS
     *(.data.init_task)
     *(.data)
     *(.gnu.linkonce.d*)
+    EXTRA_RWDATA
     CONSTRUCTORS
   }
   .data1   : { *(.data1) }
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#12 lore raw

PATCH 1/1 markers-linker-v850

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to v850.

arch/v850/kernel/vmlinux.lds.S +1 -0
@@ -116,6 +116,7 @@
         	*(.data)						      \
 			*(.exit.data)	/* 2.5 convention */		      \
 			*(.data.exit)	/* 2.4 convention */		      \
+		EXTRA_RWDATA						      \
 		. = ALIGN (16) ;					      \
 		*(.data.cacheline_aligned)				      \
 		. = ALIGN (0x2000) ;					      \
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#13 lore raw

PATCH 1/1 markers-linker-x86_64

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to x86_64.

arch/x86_64/kernel/vmlinux.lds.S +1 -0
@@ -59,6 +59,7 @@ SECTIONS
 				/* Data */
   .data : AT(ADDR(.data) - LOAD_OFFSET) {
 	*(.data)
+	EXTRA_RWDATA
 	CONSTRUCTORS
 	} :data
 
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#14 lore raw

PATCH 1/1 markers-linker-xtensa

In reply to Mathieu Desnoyers

Add EXTRA_RWDATA to xtensa.

arch/xtensa/kernel/vmlinux.lds.S +1 -1
@@ -144,7 +144,7 @@ SECTIONS
   _fdata = .;
   .data :
   {
-    *(.data) CONSTRUCTORS
+    *(.data) EXTRA_RWDATA CONSTRUCTORS
     . = ALIGN(XCHAL_ICACHE_LINESIZE);
     *(.data.cacheline_aligned)
   }
Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#15 lore raw
In reply to Mathieu Desnoyers
Quoted 9 lines · Mathieu Desnoyers

Defines the linker marcro EXTRA_RWDATA for marker data section. It puts the marker data in a separate section that will not pollute the normal .data section, which minimize the cache impact. Markers need such a special section because they define a lot of spreaded and small data structures at multiple sites.

This patch also creates the __markers_strings section (ro marker strings) and makes sure the __markers section is aligned by putting it before the __ksymtab_strings (not after).

What's this marker stuff about?

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
#16 lore raw
Quoted 7 lines · * Russell King ([email protected]) wrote:
Quoted 6 lines · Mathieu Desnoyers

Defines the linker marcro EXTRA_RWDATA for marker data section. It puts the marker data in a separate section that will not pollute the normal .data section, which minimize the cache impact. Markers need such a special section because they define a lot of spreaded and small data structures at multiple sites.

Quoted 6 lines
Quoted 3 lines

This patch also creates the __markers_strings section (ro marker strings) and makes sure the __markers section is aligned by putting it before the __ksymtab_strings (not after).

What's this marker stuff about?

Hi Russel,

Here is an overview :

This marker infrastructure is a hook-callback mechanism. It is meant to have an impact as low as possible on the system performances when no callback (probe) is connected so markers (hooks) can be compiled into a production kernel without noticeable slowdown.

The rationale behind this mechanism the following :
1 - It makes sense to have instrumentation (for tracing, profiling)
within the kernel source tree so that it can follow its evolution. Other options, such as kprobes, imply maintaining an external set of instrumentation that must be adapted to each kernel version. Although it may make sense for distributions, it is not well suited for kernel developers, since they rarely work on a major distribution image.
2 - kprobes, although being a very good attempt at providing a dynamic
hooking mechanism that has no impact when disabled, suffers from important limitations :
a - It cannot access local variables of a function at a particular
point within its body that will be consistent thorough the kernel versions without involving a lot of recurrent hair-pulling.
b - Kprobes is slow, since it involves going though a trap each time
a probe site is executed. Even though the djprobes project made a good effort to make things faster, it cannot currently instrument fully-preemptible kernels and does not solve (1), (2a) and (2c).
c - On the reentrancy side, going though a trap (thus playing with
interrupt enable/disable) and taking spinlocks are not suited to some code paths, i.e. :
kernel/lockdep.c, printk (within the lockdep_on()/lockdep_off()). It must be understood that some code paths interesting for instrumentation often present a particular reentrancy challenge.

Some more details :

The probe callback connection to its markers is done dynamically. A predicted branch is used to skip the hook stack setup and function call when the marker is "disabled" (no probe is connected). Further optimizations can be implemented for each architecture to make this branch faster.

Instrumentation of a subsystem becomes therefore a straightforward task. One has to add instrumentation within the key locations of the kernel code in the following form :

MARK(subsystem_event, "%d %p", myint, myptr);

I will be glad to discuss more specific questions that may arise about the markers.

Regards,

Mathieu

Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#17 lore raw
Quoted 6 lines · On Wed, 11 Apr 2007 13:51:11 -0400 Mathieu Desnoyers…
Quoted 2 lines

What's this marker stuff about?

Hi Russel,

Here is an overview :

I am told that the systemtap developers plan to (or are) using this infrastructure.

If correct: what is their reason for preferring it over kprobes?

Secondly, the code in -mm has no actual backend for delivering anything to userspace or to anywhere else. Why is this? Which backends currently exist, and which ones are envisaged? Is there a plan to merge any backend into the mainline kernel?

#18 lore raw
Quoted 6 lines · * Andrew Morton ([email protected]) wrote:
Quoted 3 lines · On Wed, 11 Apr 2007 13:51:11 -0400 Mathieu Desnoyers…
Quoted 2 lines

What's this marker stuff about?

Quoted 7 lines
Quoted 3 lines

Hi Russel,

Here is an overview :

I am told that the systemtap developers plan to (or are) using this infrastructure.

Quoting Frank Ch. Eigler, from the SystemTAP team :

"The LTTng user-space programs use it today. Systemtap used to support the earlier marker prototype and will be rapidly ported over to this new API upon acceptance."

Quoted 2 lines

If correct: what is their reason for preferring it over kprobes?

I will let them answer on this one..

Quoted 3 lines

Secondly, the code in -mm has no actual backend for delivering anything to userspace or to anywhere else. Why is this?

I wanted the community to come to an agreement regarding the instrumentation mechanism before submitting a data transport backend.

Quoted 4 lines

Which backends currently
exist, and which ones are envisaged? Is there a plan to merge any backend into the mainline kernel?

Yes. The one I envisage to mainline is LTTng, available there :
http://ltt.polymtl.ca. It aims at providing the lowest system disturbance and best performances possible, with reentrancy from almost any kernel call site while keeping the task of adding new instrumentation as easy as possible for the programmer. The current patches are against 2.6.21-rc6-mm1. Is comes in small modules easy to merge incrementally, which should make the whole process easier.

LKET, another tracer built on top of SystemTAP, can also be used to extract the data to user space.

Mathieu

Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#19 lore raw
Quoted 22 lines · Mathieu Desnoyers
Quoted 6 lines · * Andrew Morton ([email protected]) wrote:
Quoted 3 lines · On Wed, 11 Apr 2007 13:51:11 -0400 Mathieu Desnoyers…
Quoted 2 lines

What's this marker stuff about?

Quoted 7 lines
Quoted 3 lines

Hi Russel,

Here is an overview :

I am told that the systemtap developers plan to (or are) using this infrastructure.

Quoting Frank Ch. Eigler, from the SystemTAP team :

"The LTTng user-space programs use it today. Systemtap used to support the earlier marker prototype and will be rapidly ported over to this new API upon acceptance."

Quoted 5 lines
Quoted 2 lines

If correct: what is their reason for preferring it over kprobes?

I will let them answer on this one..

I'll take a shot at this one.

First of all, kprobes remains a vital foundation for SystemTap. But markers are attactive as an alternate source of trace/debug info. Here's why:

1. Markers will live in the kernel and presumably be kept up to date by the maintainers of the enclosing code. We have a growing set of tapsets (probe libraries), each of which "knows" the source code for a certain area of the kernel. Whenever the underlying kernel code changes (e.g., a function or one of its args disappears or is renamed), there's a chance that the tapset will become invalid until we bring it back in sync with the kernel. As you can imagine, maintaining tapsets separate from the kernel source is a maintenance headache. Markers could mitigate this.

2. Because the kernel code is highly optimized, the kernel's dwarf info doesn't always accurately reflect which variables have which values on which lines (sometimes even upon entry to a function). A marker is a way to ensure that values of interest are available to SystemTap at marked points.

3. Sometimes the overhead of a kprobe probepoint is too much (either in terms of time or locking) for the particular hotspot we want to probe.

Jim

#20 lore raw
Quoted 34 lines · Jim Keniston
Quoted 31 lines · Mathieu Desnoyers
Quoted 9 lines · * Andrew Morton ([email protected]) wrote:
Quoted 4 lines · On Wed, 11 Apr 2007 13:51:11 -0400 Mathieu Desnoyers…
Quoted 4 lines

What's this marker stuff about?

Quoted 10 lines
Quoted 5 lines

Hi Russel,

Here is an overview :

I am told that the systemtap developers plan to (or are) using this infrastructure.

Quoting Frank Ch. Eigler, from the SystemTAP team :

"The LTTng user-space programs use it today. Systemtap used to support the earlier marker prototype and will be rapidly ported over to this new API upon acceptance."

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

If correct: what is their reason for preferring it over kprobes?

Markers are not a substitute or preference over kprobes, they augment kprobes by enabling additional functionality.

Quoted 13 lines
Quoted 6 lines
Quoted 2 lines

I will let them answer on this one..

I'll take a shot at this one.

First of all, kprobes remains a vital foundation for SystemTap. But markers are attactive as an alternate source of trace/debug info. Here's why:

Quoted 11 lines

1. Markers will live in the kernel and presumably be kept up to date by the maintainers of the enclosing code. We have a growing set of tapsets (probe libraries), each of which "knows" the source code for a certain area of the kernel. Whenever the underlying kernel code changes (e.g., a function or one of its args disappears or is renamed), there's a chance that the tapset will become invalid until we bring it back in sync with the kernel. As you can imagine, maintaining tapsets separate from the kernel source is a maintenance headache. Markers could mitigate this.

Jim's above stated reason is not a consideration for markers. We don't plan to convert the current tapsets to use markers. We do need to augment tapsets with a few markers in the kernel code where it is not easy to put a kprobe in a maintainable fashion -- e.g in the middle of a function.

Quoted 7 lines

2. Because the kernel code is highly optimized, the kernel's dwarf info doesn't always accurately reflect which variables have which values on which lines (sometimes even upon entry to a function). A marker is a way to ensure that values of interest are available to SystemTap at marked points.

Agreed

Quoted 5 lines

3. Sometimes the overhead of a kprobe probepoint is too much (either in terms of time or locking) for the particular hotspot we want to probe.

Agreed

Quoted 4 lines

Jim

bye,
Vara Prasad

#21 lore raw
In reply to Andrew Morton
Quoted 13 lines · * Andrew Morton ([email protected]) wrote:
Quoted 6 lines · On Wed, 11 Apr 2007 13:51:11 -0400 Mathieu Desnoyers…
Quoted 2 lines

What's this marker stuff about?

Hi Russel,

Here is an overview :

I am told that the systemtap developers plan to (or are) using this infrastructure.

Quoted 8 lines

If correct: what is their reason for preferring it over kprobes?

Secondly, the code in -mm has no actual backend for delivering anything to userspace or to anywhere else. Why is this? Which backends currently exist, and which ones are envisaged? Is there a plan to merge any backend into the mainline kernel?

Here is more context around this :

With the increasing complexity of today's user-space application and the wide deployment of SMP systems, the users need an increasing understanding of the behavior and performances of a system across multiple processes/different execution contexts/multiple CPUs. In applications such as large clusters (Google, IBM), video acquisition (Autodesk), embedded real-time systems (Wind River, Monta Vista, Sony) or sysadmin/programmer-type tasks (SystemTAP from Redhat), a tool that permits tracing of kernel-user space interaction becomes necessary.

Usage of such tools have been made to successfully pinpoint problems such as : latency issues in a user-space video acquisition application, slowdown problems in large clusters due to a switch to a different filesystems with a different cache size, abnormal Linux scheduler latency (just to name a few that I have personally investigated).

The currently existing solutions does not give a system-wide overview of what - and when - things are happening on the system. Ptracing a program works with few processes, but quickly becomes useless when it comes to keeping track of many processes.

Bugs occuring because of bad interaction of such complex systems can be very hard to find due to the fact that they occur rarely (sometimes once a week on hundreds of machines). One can therefore only hope at having the best conditions to statistically reproduce the bug while extracting information from the system. Some bugs have been successfully found at Google using their ktrace tracer only because they could enable it on production machines and therefore recreate the same context where the bug happened.

Therefore, it makes sense to offer an instrumentation set of the most relevant events occurring in the Linux that can have the smallest performance cost possible when not active while not requiring a reboot of a production system to activate. This is essentially what the markers are providing.

Since we cannot limit the growth of the Linux kernel, nor can we pre-determine each and every "interesting" instrumentation within each subsystem and driver, it is sensible to let this task to the persons who knows the best their code. Adding instrumentation should therefore be as easy as adding and maintaining a "printk" in the kernel code from the developer's point of view.

Towards a complete tracing mechanism in the Linux kernel, the markers are only one step forward. The following step is to connect probes to those markers that will record the tracing information in buffers exported to user-space, organized in timestamped "events". Probe callbacks are responsible for serializing the information passed as parameter to the markers (described by the format string) into the events. A control mechanism to activate/stop the tracing is required, as well as a daemon that maps the buffers to write them to disk or send them through the network.

Keeping track of the events also requires a centralized infrastructure :
the idea is to assign a unique ID to each event so they can be later recognized in the trace. Keeping in mind that recording the complete instrumentation site name string for each event would be more that inefficient, assigning a numeric unique identifier makes sense.

Finally, support for gathering events coming from user-space, with a minimal performance impact, is very useful to see the interaction between the system's execution contexts.

The last steps are currently implemented in Linux Trace Toolkit Next Generation (LTTng).

The SystemTAP project could clearly benefit from such an infrastructure for tracing. In addition, they would be providing support for dynamic addition of kernel probes through breakpoints/jumps when possible, with the associated restrictions (accessing local variables, reentrancy, speed).

Mathieu

Signature · 3 lines
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#22 lore raw
In reply to Andrew Morton
Quoted 2 lines · Andrew Morton

[...] I am told that the systemtap developers plan to (or are) using this infrastructure.

Indeed.

Quoted 2 lines

If correct: what is their reason for preferring it over kprobes? [...]

It's not a preference - it's more of a supplement. It's helpful when some combination of such factors exists:

- kprobe int3-fault dispatching overhead orders of magnitude too high
- fault dispatching not permissible in some areas
- local context variables not easily retrievable via dwarf information
- dwarf information not available at all
- costs of permanently placed but passive marker acceptable

Quoted 1 line

From systemtap's point of view, instrumentation hooked to markers,

kprobes, and other facilities like timers, coexist just fine. A greater number of probe-able event sources makes for a richer tool.

- FChE