Skip to contentSkip to conversation

Linux Kernel Markers (redux)

PATCH In review Mathieu Desnoyers 4 participants 13 messages Sep 25, 2007

Subsystems (16)
lore
Share & tools
lore
#0 lore raw

cover Linux Kernel Markers (redux)

Hi!

Following Christoph's usual nitpicking and Randy's suggestions to put the sample code in the new samples/ kernel directory, I made modifications to the markers. The result is that the marker code holds into a single patch; other patches are for menus, documentation and samples.

Here is the updated version for 2.6.23-rc8-mm1.

It applies in this order:

kconfig-instrumentation.patch
linux-kernel-markers.patch
add-samples-subdir.patch
linux-kernel-markers-samples.patch
linux-kernel-markers-documentation.patch

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
#1 lore raw

PATCH 1/5 Combine instrumentation menus in kernel/Kconfig.instrumentation

Quoting Randy:

"It seems sad that this patch sources Kconfig.marker, a 7-line file, 20-something times. Yes, you (we) don't want to put those 7 lines into 20-something different files, so sourcing is the right thing.

However, what you did for avr32 seems more on the right track to me:
make _one_ Instrumentation support menu that includes PROFILING, OPROFILE, KPROBES, and MARKERS and then use (source) that in all of the arches."

---
 arch/alpha/Kconfig             |    2 -
 arch/alpha/oprofile/Kconfig    |   23 ---------------------
 arch/arm/Kconfig               |    2 -
 arch/arm/oprofile/Kconfig      |   42 ----------------------------------------
 arch/blackfin/Kconfig          |    2 -
 arch/blackfin/oprofile/Kconfig |   29 ---------------------------
 arch/cris/Kconfig              |    2 +
 arch/frv/Kconfig               |    2 +
 arch/h8300/Kconfig             |    2 +
 arch/i386/Kconfig              |   25 -----------------------
 arch/i386/oprofile/Kconfig     |   17 ----------------
 arch/ia64/Kconfig              |   15 --------------
 arch/ia64/oprofile/Kconfig     |   20 -------------------
 arch/m32r/Kconfig              |    2 -
 arch/m32r/oprofile/Kconfig     |   23 ---------------------
 arch/m68k/Kconfig              |    2 +
 arch/m68knommu/Kconfig         |    2 +
 arch/mips/Kconfig              |    2 -
 arch/mips/oprofile/Kconfig     |   23 ---------------------
 arch/parisc/Kconfig            |    2 -
 arch/parisc/oprofile/Kconfig   |   23 ---------------------
 arch/powerpc/Kconfig           |   15 --------------
 arch/powerpc/oprofile/Kconfig  |   24 ----------------------
 arch/ppc/Kconfig               |    2 -
 arch/s390/Kconfig              |   16 ---------------
 arch/s390/oprofile/Kconfig     |   22 --------------------
 arch/sh/Kconfig                |    2 -
 arch/sh/oprofile/Kconfig       |   23 ---------------------
 arch/sh64/Kconfig              |    2 -
 arch/sh64/oprofile/Kconfig     |   23 ---------------------
 arch/sparc/Kconfig             |    6 -----
 arch/sparc/oprofile/Kconfig    |   17 ----------------
 arch/sparc64/Kconfig           |   15 --------------
 arch/sparc64/oprofile/Kconfig  |   17 ----------------
 arch/um/Kconfig                |    2 +
 arch/v850/Kconfig              |    2 +
 arch/x86_64/Kconfig            |   15 --------------
 arch/x86_64/oprofile/Kconfig   |   17 ----------------
 arch/xtensa/Kconfig            |    2 +
 kernel/Kconfig.instrumentation |   43 +++++++++++++++++++++++++++++++++++++++++
 40 files changed, 75 insertions(+), 452 deletions(-)
arch/alpha/oprofile/Kconfig deleted +0 -23
Index: linux-2.6-lttng/arch/alpha/oprofile/Kconfig
===================================================================
@@ -1,23 +0,0 @@
-
-menu "Profiling support"
-	depends on EXPERIMENTAL
-
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-	  
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-endmenu
-
arch/arm/oprofile/Kconfig deleted +0 -42

42 lines not on this page · raw message

arch/blackfin/oprofile/Kconfig deleted +0 -29
Index: linux-2.6-lttng/arch/blackfin/oprofile/Kconfig
===================================================================
@@ -1,29 +0,0 @@
-menu "Profiling support"
-depends on EXPERIMENTAL
-
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-config HARDWARE_PM
-	tristate "Hardware Performance Monitor Profiling"
-	depends on PROFILING
-	help
-	  take use of hardware performance monitor to profiling the kernel
-	  and application.
-
-	  If unsure, say N.
-
-endmenu
arch/i386/oprofile/Kconfig deleted +0 -17
Index: linux-2.6-lttng/arch/i386/oprofile/Kconfig
===================================================================
@@ -1,17 +0,0 @@
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-	  
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
arch/ia64/oprofile/Kconfig deleted +0 -20
Index: linux-2.6-lttng/arch/ia64/oprofile/Kconfig
===================================================================
@@ -1,20 +0,0 @@
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  Due to firmware bugs, you may need to use the "nohalt" boot
-	  option if you're using OProfile with the hardware performance
-	  counters.
-
-	  If unsure, say N.
-
arch/m32r/oprofile/Kconfig deleted +0 -23
Index: linux-2.6-lttng/arch/m32r/oprofile/Kconfig
===================================================================
@@ -1,23 +0,0 @@
-
-menu "Profiling support"
-	depends on EXPERIMENTAL
-
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-endmenu
-
arch/mips/oprofile/Kconfig deleted +0 -23
Index: linux-2.6-lttng/arch/mips/oprofile/Kconfig
===================================================================
@@ -1,23 +0,0 @@
-
-menu "Profiling support"
-	depends on EXPERIMENTAL
-
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING && !MIPS_MT_SMTC && EXPERIMENTAL
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-endmenu
-
arch/parisc/oprofile/Kconfig deleted +0 -23
Index: linux-2.6-lttng/arch/parisc/oprofile/Kconfig
===================================================================
@@ -1,23 +0,0 @@
-
-menu "Profiling support"
-	depends on EXPERIMENTAL
-
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-	  
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-endmenu
-
arch/powerpc/oprofile/Kconfig deleted +0 -24
Index: linux-2.6-lttng/arch/powerpc/oprofile/Kconfig
===================================================================
@@ -1,24 +0,0 @@
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-config OPROFILE_CELL
-	bool "OProfile for Cell Broadband Engine"
-	depends on (SPU_FS = y && OPROFILE = m) || (SPU_FS = y && OPROFILE = y) || (SPU_FS = m && OPROFILE = m)
-	default y
-	help
-	  Profiling of Cell BE SPUs requires special support enabled
-	  by this option.
arch/s390/oprofile/Kconfig deleted +0 -22
Index: linux-2.6-lttng/arch/s390/oprofile/Kconfig
===================================================================
@@ -1,22 +0,0 @@
-
-menu "Profiling support"
-
-config PROFILING
-	bool "Profiling support"
-	help
-	  Say Y here to enable profiling support mechanisms used by
-	  profilers such as readprofile or OProfile.
-
-
-config OPROFILE
-	tristate "OProfile system profiling"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-endmenu
-
arch/sh/oprofile/Kconfig deleted +0 -23
Index: linux-2.6-lttng/arch/sh/oprofile/Kconfig
===================================================================
@@ -1,23 +0,0 @@
-
-menu "Profiling support"
-	depends on EXPERIMENTAL
-
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-	  
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-endmenu
-
arch/sh64/oprofile/Kconfig deleted +0 -23
Index: linux-2.6-lttng/arch/sh64/oprofile/Kconfig
===================================================================
@@ -1,23 +0,0 @@
-
-menu "Profiling support"
-	depends on EXPERIMENTAL
-
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
-endmenu
-
arch/sparc/oprofile/Kconfig deleted +0 -17
Index: linux-2.6-lttng/arch/sparc/oprofile/Kconfig
===================================================================
@@ -1,17 +0,0 @@
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-	  
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
arch/sparc64/oprofile/Kconfig deleted +0 -17
Index: linux-2.6-lttng/arch/sparc64/oprofile/Kconfig
===================================================================
@@ -1,17 +0,0 @@
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-	  
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
arch/x86_64/oprofile/Kconfig deleted +0 -17
Index: linux-2.6-lttng/arch/x86_64/oprofile/Kconfig
===================================================================
@@ -1,17 +0,0 @@
-config PROFILING
-	bool "Profiling support (EXPERIMENTAL)"
-	help
-	  Say Y here to enable the extended profiling support mechanisms used
-	  by profilers such as OProfile.
-	  
-
-config OPROFILE
-	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING
-	help
-	  OProfile is a profiling system capable of profiling the
-	  whole system, include the kernel, kernel modules, libraries,
-	  and applications.
-
-	  If unsure, say N.
-
kernel/Kconfig.instrumentation new file +43 -0

43 lines not on this page · raw message

arch/i386/Kconfig +1 -24
Index: linux-2.6-lttng/arch/i386/Kconfig
===================================================================
@@ -1251,30 +1251,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-menuconfig INSTRUMENTATION
-	bool "Instrumentation Support"
-	default y
-	---help---
-	  Say Y here to get to see options related to performance measurement,
-	  debugging, and testing. This option alone does not add any kernel code.
-
-	  If you say N, all options in this submenu will be skipped and disabled.
-
-if INSTRUMENTATION
-
-source "arch/i386/oprofile/Kconfig"
-
-config KPROBES
-	bool "Kprobes"
-	depends on KALLSYMS && MODULES
-	help
-	  Kprobes allows you to trap at almost any kernel address and
-	  execute a callback function.  register_kprobe() establishes
-	  a probepoint and specifies the callback.  Kprobes is useful
-	  for kernel debugging, non-intrusive instrumentation and testing.
-	  If in doubt, say "N".
-
-endif # INSTRUMENTATION
+source "kernel/Kconfig.instrumentation"
 
 source "arch/i386/Kconfig.debug"
 
arch/alpha/Kconfig +1 -1
Index: linux-2.6-lttng/arch/alpha/Kconfig
===================================================================
@@ -654,7 +654,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-source "arch/alpha/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/alpha/Kconfig.debug"
 
arch/arm/Kconfig +1 -1
Index: linux-2.6-lttng/arch/arm/Kconfig
===================================================================
@@ -1061,7 +1061,7 @@ endmenu
 
 source "fs/Kconfig"
 
-source "arch/arm/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/arm/Kconfig.debug"
 
arch/blackfin/Kconfig +1 -1
Index: linux-2.6-lttng/arch/blackfin/Kconfig
===================================================================
@@ -914,7 +914,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-source "arch/blackfin/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 menu "Kernel hacking"
 
arch/cris/Kconfig +2 -0
Index: linux-2.6-lttng/arch/cris/Kconfig
===================================================================
@@ -196,6 +196,8 @@ source "sound/Kconfig"
 
 source "drivers/usb/Kconfig"
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/cris/Kconfig.debug"
 
 source "security/Kconfig"
arch/frv/Kconfig +2 -0
Index: linux-2.6-lttng/arch/frv/Kconfig
===================================================================
@@ -375,6 +375,8 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/frv/Kconfig.debug"
 
 source "security/Kconfig"
arch/h8300/Kconfig +2 -0
Index: linux-2.6-lttng/arch/h8300/Kconfig
===================================================================
@@ -223,6 +223,8 @@ endmenu
 
 source "fs/Kconfig"
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/h8300/Kconfig.debug"
 
 source "security/Kconfig"
arch/ia64/Kconfig +1 -14
Index: linux-2.6-lttng/arch/ia64/Kconfig
===================================================================
@@ -579,20 +579,7 @@ config IRQ_PER_CPU
 
 source "arch/ia64/hp/sim/Kconfig"
 
-menu "Instrumentation Support"
-
-source "arch/ia64/oprofile/Kconfig"
-
-config KPROBES
-	bool "Kprobes"
-	depends on KALLSYMS && MODULES
-	help
-	  Kprobes allows you to trap at almost any kernel address and
-	  execute a callback function.  register_kprobe() establishes
-	  a probepoint and specifies the callback.  Kprobes is useful
-	  for kernel debugging, non-intrusive instrumentation and testing.
-	  If in doubt, say "N".
-endmenu
+source "kernel/Kconfig.instrumentation"
 
 source "arch/ia64/Kconfig.debug"
 
arch/m32r/Kconfig +1 -1
Index: linux-2.6-lttng/arch/m32r/Kconfig
===================================================================
@@ -426,7 +426,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-source "arch/m32r/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/m32r/Kconfig.debug"
 
arch/m68k/Kconfig +2 -0
Index: linux-2.6-lttng/arch/m68k/Kconfig
===================================================================
@@ -683,6 +683,8 @@ endmenu
 
 source "fs/Kconfig"
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/m68k/Kconfig.debug"
 
 source "security/Kconfig"
arch/m68knommu/Kconfig +2 -0
Index: linux-2.6-lttng/arch/m68knommu/Kconfig
===================================================================
@@ -696,6 +696,8 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/m68knommu/Kconfig.debug"
 
 source "security/Kconfig"
arch/mips/Kconfig +1 -1
Index: linux-2.6-lttng/arch/mips/Kconfig
===================================================================
@@ -1961,7 +1961,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-source "arch/mips/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/mips/Kconfig.debug"
 
arch/parisc/Kconfig +1 -1
Index: linux-2.6-lttng/arch/parisc/Kconfig
===================================================================
@@ -267,7 +267,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-source "arch/parisc/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/parisc/Kconfig.debug"
 
arch/powerpc/Kconfig +1 -14
Index: linux-2.6-lttng/arch/powerpc/Kconfig
===================================================================
@@ -638,20 +638,7 @@ source "arch/powerpc/sysdev/qe_lib/Kconf
 
 source "lib/Kconfig"
 
-menu "Instrumentation Support"
-
-source "arch/powerpc/oprofile/Kconfig"
-
-config KPROBES
-	bool "Kprobes"
-	depends on !BOOKE && !4xx && KALLSYMS && MODULES
-	help
-	  Kprobes allows you to trap at almost any kernel address and
-	  execute a callback function.  register_kprobe() establishes
-	  a probepoint and specifies the callback.  Kprobes is useful
-	  for kernel debugging, non-intrusive instrumentation and testing.
-	  If in doubt, say "N".
-endmenu
+source "kernel/Kconfig.instrumentation"
 
 source "arch/powerpc/Kconfig.debug"
 
arch/ppc/Kconfig +1 -1
Index: linux-2.6-lttng/arch/ppc/Kconfig
===================================================================
@@ -1307,7 +1307,7 @@ endmenu
 
 source "lib/Kconfig"
 
-source "arch/powerpc/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/ppc/Kconfig.debug"
 
arch/s390/Kconfig +1 -15
Index: linux-2.6-lttng/arch/s390/Kconfig
===================================================================
@@ -529,21 +529,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-menu "Instrumentation Support"
-
-source "arch/s390/oprofile/Kconfig"
-
-config KPROBES
-	bool "Kprobes (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && MODULES
-	help
-	  Kprobes allows you to trap at almost any kernel address and
-	  execute a callback function.	register_kprobe() establishes
-	  a probepoint and specifies the callback.  Kprobes is useful
-	  for kernel debugging, non-intrusive instrumentation and testing.
-	  If in doubt, say "N".
-
-endmenu
+source "kernel/Kconfig.instrumentation"
 
 source "arch/s390/Kconfig.debug"
 
arch/sh/Kconfig +1 -1
Index: linux-2.6-lttng/arch/sh/Kconfig
===================================================================
@@ -749,7 +749,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-source "arch/sh/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/sh/Kconfig.debug"
 
arch/sh64/Kconfig +1 -1
Index: linux-2.6-lttng/arch/sh64/Kconfig
===================================================================
@@ -285,7 +285,7 @@ source "drivers/Kconfig"
 
 source "fs/Kconfig"
 
-source "arch/sh64/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
 
 source "arch/sh64/Kconfig.debug"
 
arch/sparc/Kconfig +1 -5
Index: linux-2.6-lttng/arch/sparc/Kconfig
===================================================================
@@ -320,11 +320,7 @@ endmenu
 
 source "fs/Kconfig"
 
-menu "Instrumentation Support"
-
-source "arch/sparc/oprofile/Kconfig"
-
-endmenu
+source "kernel/Kconfig.instrumentation"
 
 source "arch/sparc/Kconfig.debug"
 
arch/sparc64/Kconfig +1 -14
Index: linux-2.6-lttng/arch/sparc64/Kconfig
===================================================================
@@ -460,20 +460,7 @@ source "drivers/fc4/Kconfig"
 
 source "fs/Kconfig"
 
-menu "Instrumentation Support"
-
-source "arch/sparc64/oprofile/Kconfig"
-
-config KPROBES
-	bool "Kprobes (EXPERIMENTAL)"
-	depends on KALLSYMS && EXPERIMENTAL && MODULES
-	help
-	  Kprobes allows you to trap at almost any kernel address and
-	  execute a callback function.  register_kprobe() establishes
-	  a probepoint and specifies the callback.  Kprobes is useful
-	  for kernel debugging, non-intrusive instrumentation and testing.
-	  If in doubt, say "N".
-endmenu
+source "kernel/Kconfig.instrumentation"
 
 source "arch/sparc64/Kconfig.debug"
 
arch/um/Kconfig +2 -0
Index: linux-2.6-lttng/arch/um/Kconfig
===================================================================
@@ -289,4 +289,6 @@ config INPUT
 	bool
 	default n
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/um/Kconfig.debug"
arch/v850/Kconfig +2 -0
Index: linux-2.6-lttng/arch/v850/Kconfig
===================================================================
@@ -331,6 +331,8 @@ source "sound/Kconfig"
 
 source "drivers/usb/Kconfig"
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/v850/Kconfig.debug"
 
 source "security/Kconfig"
arch/x86_64/Kconfig +1 -14
Index: linux-2.6-lttng/arch/x86_64/Kconfig
===================================================================
@@ -833,20 +833,7 @@ source "drivers/firmware/Kconfig"
 
 source fs/Kconfig
 
-menu "Instrumentation Support"
-
-source "arch/x86_64/oprofile/Kconfig"
-
-config KPROBES
-	bool "Kprobes"
-	depends on KALLSYMS && MODULES
-	help
-	  Kprobes allows you to trap at almost any kernel address and
-	  execute a callback function.  register_kprobe() establishes
-	  a probepoint and specifies the callback.  Kprobes is useful
-	  for kernel debugging, non-intrusive instrumentation and testing.
-	  If in doubt, say "N".
-endmenu
+source "kernel/Kconfig.instrumentation"
 
 source "arch/x86_64/Kconfig.debug"
 
arch/xtensa/Kconfig +2 -0
Index: linux-2.6-lttng/arch/xtensa/Kconfig
===================================================================
@@ -251,6 +251,8 @@ config EMBEDDED_RAMDISK_IMAGE
 	  provide one yourself.
 endmenu
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/xtensa/Kconfig.debug"
 
 source "security/Kconfig"
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 2/5 Linux Kernel Markers

In reply to Mathieu Desnoyers

The marker activation functions sits in kernel/marker.c. A hash table is used to keep track of the registered probes and armed markers, so the markers within a newly loaded module that should be active can be activated at module load time.

marker_query has been removed. marker_get_first, marker_get_next and marker_release should be used as iterators on the markers.

Changelog:
- markers_mutex now nests inside module_mutex rather than the opposite.
- Iteration on modules is now done in module.c.
- module_mutex is not exported anymore.
- Don't declare a __markers_strings section.
- Simplified: do not use immediate values, just a simple variable read. (removed dependency on immediate values).
- Removed the args field in the marker structure : it was not used.
- Removed the iterators. Will come back with the actual users.
- Merge the markers menu entry.

---

 include/asm-generic/vmlinux.lds.h |    7 
 include/linux/marker.h            |  130 +++++++++
 include/linux/module.h            |   12 
 kernel/Kconfig.instrumentation    |    6 
 kernel/Makefile                   |    1 
 kernel/marker.c                   |  527 ++++++++++++++++++++++++++++++++++++++
 kernel/module.c                   |   30 ++
 7 files changed, 711 insertions(+), 2 deletions(-)
include/asm-generic/vmlinux.lds.h +6 -1
Index: linux-2.6-lttng/include/asm-generic/vmlinux.lds.h
===================================================================
@@ -12,7 +12,11 @@
 /* .data section */
 #define DATA_DATA							\
 	*(.data)							\
-	*(.data.init.refok)
+	*(.data.init.refok)						\
+	. = ALIGN(8);							\
+	VMLINUX_SYMBOL(__start___markers) = .;				\
+	*(__markers)							\
+	VMLINUX_SYMBOL(__stop___markers) = .;
 
 #define RO_DATA(align)							\
 	. = ALIGN((align));						\
@@ -20,6 +24,7 @@
 		VMLINUX_SYMBOL(__start_rodata) = .;			\
 		*(.rodata) *(.rodata.*)					\
 		*(__vermagic)		/* Kernel version magic */	\
+		*(__markers_strings)	/* Markers: strings */		\
 	}								\
 									\
 	.rodata1          : AT(ADDR(.rodata1) - LOAD_OFFSET) {		\
include/linux/marker.h new file +130 -0

130 lines not on this page · raw message

include/linux/module.h +12 -0
Index: linux-2.6-lttng/include/linux/module.h
===================================================================
@@ -15,6 +15,7 @@
 #include <linux/stringify.h>
 #include <linux/kobject.h>
 #include <linux/moduleparam.h>
+#include <linux/marker.h>
 #include <asm/local.h>
 
 #include <asm/module.h>
@@ -370,6 +371,10 @@ struct module
 	/* The command line arguments (may be mangled).  People like
 	   keeping pointers to this stuff */
 	char *args;
+#ifdef CONFIG_MARKERS
+	struct __mark_marker *markers;
+	unsigned int num_markers;
+#endif
 };
 #ifndef MODULE_ARCH_INIT
 #define MODULE_ARCH_INIT {}
@@ -473,6 +478,8 @@ int unregister_module_notifier(struct no
 
 extern void print_modules(void);
 
+extern void module_update_markers(struct module *probe_module, int *refcount);
+
 #else /* !CONFIG_MODULES... */
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
@@ -572,6 +579,11 @@ static inline void print_modules(void)
 {
 }
 
+static inline void module_update_markers(struct module *probe_module,
+		int *refcount)
+{
+}
+
 #endif /* CONFIG_MODULES */
 
 struct device_driver;
kernel/module.c +29 -1
Index: linux-2.6-lttng/kernel/module.c
===================================================================
@@ -1717,6 +1717,8 @@ static struct module *load_module(void _
 	unsigned int unusedcrcindex;
 	unsigned int unusedgplindex;
 	unsigned int unusedgplcrcindex;
+	unsigned int markersindex;
+	unsigned int markersstringsindex;
 	struct module *mod;
 	long err = 0;
 	void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -1982,6 +1984,8 @@ static struct module *load_module(void _
 		add_taint_module(mod, TAINT_FORCED_MODULE);
 	}
 #endif
+	markersindex = find_sec(hdr, sechdrs, secstrings, "__markers");
+ 	markersstringsindex = find_sec(hdr, sechdrs, secstrings, "__markers_strings");
 
 	/* Now do relocations. */
 	for (i = 1; i < hdr->e_shnum; i++) {
@@ -2004,6 +2008,11 @@ static struct module *load_module(void _
 		if (err < 0)
 			goto cleanup;
 	}
+#ifdef CONFIG_MARKERS
+	mod->markers = (void *)sechdrs[markersindex].sh_addr;
+	mod->num_markers =
+		sechdrs[markersindex].sh_size / sizeof(*mod->markers);
+#endif
 
         /* Find duplicate symbols */
 	err = verify_export_symbols(mod);
@@ -2027,7 +2036,11 @@ static struct module *load_module(void _
 	 if (err < 0)
 		 goto nomodsectinfo;
 #endif
-
+#ifdef CONFIG_MARKERS
+	if (!mod->taints)
+		marker_update_probe_range(mod->markers,
+			mod->markers + mod->num_markers, NULL, NULL);
+#endif
 	err = module_finalize(hdr, sechdrs, mod);
 	if (err < 0)
 		goto cleanup;
@@ -2629,3 +2642,18 @@ EXPORT_SYMBOL(module_remove_driver);
 void struct_module(struct module *mod) { return; }
 EXPORT_SYMBOL(struct_module);
 #endif
+
+#ifdef CONFIG_MARKERS
+void module_update_markers(struct module *probe_module, int *refcount)
+{
+	struct module *mod;
+
+	mutex_lock(&module_mutex);
+	list_for_each_entry(mod, &modules, list)
+		if (!mod->taints)
+			marker_update_probe_range(mod->markers,
+				mod->markers + mod->num_markers,
+				probe_module, refcount);
+	mutex_unlock(&module_mutex);
+}
+#endif
kernel/marker.c new file +527 -0

527 lines not on this page · raw message

kernel/Kconfig.instrumentation +6 -0
Index: linux-2.6-lttng/kernel/Kconfig.instrumentation
===================================================================
@@ -40,4 +40,10 @@ config KPROBES
 	  for kernel debugging, non-intrusive instrumentation and testing.
 	  If in doubt, say "N".
 
+config MARKERS
+	bool "Activate markers"
+	help
+	  Place an empty function call at each marker site. Can be
+	  dynamically changed for a probe function.
+
 endif # INSTRUMENTATION
kernel/Makefile +1 -0
Index: linux-2.6-lttng/kernel/Makefile
===================================================================
@@ -61,6 +61,7 @@ obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
 obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
 obj-$(CONFIG_RESOURCE_COUNTERS) += res_counter.o
+obj-$(CONFIG_MARKERS) += marker.o
 
 ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
 # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
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 3/5 Add samples subdir

In reply to Mathieu Desnoyers

From: Randy Dunlap <[email protected]>

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.
Source its Kconfig file in all arch/ Kconfigs.

---
 Makefile               |   10 +++++++---
 arch/alpha/Kconfig     |    2 ++
 arch/arm/Kconfig       |    2 ++
 arch/avr32/Kconfig     |    2 ++
 arch/blackfin/Kconfig  |    2 ++
 arch/cris/Kconfig      |    2 ++
 arch/frv/Kconfig       |    2 ++
 arch/h8300/Kconfig     |    2 ++
 arch/i386/Kconfig      |    2 ++
 arch/ia64/Kconfig      |    2 ++
 arch/m32r/Kconfig      |    2 ++
 arch/m68k/Kconfig      |    2 ++
 arch/m68knommu/Kconfig |    2 ++
 arch/mips/Kconfig      |    2 ++
 arch/parisc/Kconfig    |    2 ++
 arch/powerpc/Kconfig   |    2 ++
 arch/ppc/Kconfig       |    2 ++
 arch/s390/Kconfig      |    2 ++
 arch/sh/Kconfig        |    2 ++
 arch/sh64/Kconfig      |    2 ++
 arch/sparc/Kconfig     |    2 ++
 arch/sparc64/Kconfig   |    2 ++
 arch/um/Kconfig        |    2 ++
 arch/v850/Kconfig      |    2 ++
 arch/x86_64/Kconfig    |    2 ++
 arch/xtensa/Kconfig    |    3 ++-
 samples/Kconfig        |   11 +++++++++++
 27 files changed, 68 insertions(+), 4 deletions(-)
Makefile +7 -3
Index: linux-2.6-lttng/Makefile
===================================================================
@@ -436,6 +436,7 @@ drivers-y	:= drivers/ sound/
 net-y		:= net/
 libs-y		:= lib/
 core-y		:= usr/
+samples-y	:= samples/
 endif # KBUILD_EXTMOD
 
 ifeq ($(dot-config),1)
@@ -574,10 +575,12 @@ core-y		+= kernel/ mm/ fs/ ipc/ security
 
 vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
-		     $(net-y) $(net-m) $(libs-y) $(libs-m)))
+		     $(net-y) $(net-m) $(libs-y) $(libs-m))	\
+		     $(samples-y) $(samples-m))
+
 
 vmlinux-alldirs	:= $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
-		     $(init-n) $(init-) \
+		     $(init-n) $(init-) $(samples-n) $(samples-) \
 		     $(core-n) $(core-) $(drivers-n) $(drivers-) \
 		     $(net-n)  $(net-)  $(libs-n)    $(libs-))))
 
@@ -588,6 +591,7 @@ net-y		:= $(patsubst %/, %/built-in.o, $
 libs-y1		:= $(patsubst %/, %/lib.a, $(libs-y))
 libs-y2		:= $(patsubst %/, %/built-in.o, $(libs-y))
 libs-y		:= $(libs-y1) $(libs-y2)
+samples-y	:= $(patsubst %/, %/built-in.o, $(samples-y))
 
 # Build vmlinux
 # ---------------------------------------------------------------------------
@@ -617,7 +621,7 @@ libs-y		:= $(libs-y1) $(libs-y2)
 # System.map is generated to document addresses of all kernel symbols
 
 vmlinux-init := $(head-y) $(init-y)
-vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y)
+vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) $(samples-y)
 vmlinux-all  := $(vmlinux-init) $(vmlinux-main)
 vmlinux-lds  := arch/$(ARCH)/kernel/vmlinux.lds
 export KBUILD_VMLINUX_OBJS := $(vmlinux-all)
samples/Kconfig new file +11 -0
Index: linux-2.6-lttng/samples/Kconfig
===================================================================
@@ -0,0 +1,11 @@
+# samples/Kconfig
+
+menuconfig SAMPLES
+	bool "Sample kernel code"
+	help
+	  You can build and test sample kernel code here.
+
+if SAMPLES
+
+
+endif # SAMPLES
arch/alpha/Kconfig +2 -0
Index: linux-2.6-lttng/arch/alpha/Kconfig
===================================================================
@@ -669,5 +669,7 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
 
arch/arm/Kconfig +2 -0
Index: linux-2.6-lttng/arch/arm/Kconfig
===================================================================
@@ -1069,4 +1069,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/avr32/Kconfig +2 -0
Index: linux-2.6-lttng/arch/avr32/Kconfig
===================================================================
@@ -237,4 +237,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/blackfin/Kconfig +2 -0
Index: linux-2.6-lttng/arch/blackfin/Kconfig
===================================================================
@@ -1012,4 +1012,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/cris/Kconfig +2 -0
Index: linux-2.6-lttng/arch/cris/Kconfig
===================================================================
@@ -204,4 +204,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/frv/Kconfig +2 -0
Index: linux-2.6-lttng/arch/frv/Kconfig
===================================================================
@@ -383,4 +383,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/h8300/Kconfig +2 -0
Index: linux-2.6-lttng/arch/h8300/Kconfig
===================================================================
@@ -231,4 +231,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/i386/Kconfig +2 -0
Index: linux-2.6-lttng/arch/i386/Kconfig
===================================================================
@@ -1259,6 +1259,8 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
 
 #
arch/ia64/Kconfig +2 -0
Index: linux-2.6-lttng/arch/ia64/Kconfig
===================================================================
@@ -586,3 +586,5 @@ source "arch/ia64/Kconfig.debug"
 source "security/Kconfig"
 
 source "crypto/Kconfig"
+
+source "samples/Kconfig"
arch/m32r/Kconfig +2 -0
Index: linux-2.6-lttng/arch/m32r/Kconfig
===================================================================
@@ -434,4 +434,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/m68k/Kconfig +2 -0
Index: linux-2.6-lttng/arch/m68k/Kconfig
===================================================================
@@ -691,4 +691,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/m68knommu/Kconfig +2 -0
Index: linux-2.6-lttng/arch/m68knommu/Kconfig
===================================================================
@@ -704,4 +704,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/mips/Kconfig +2 -0
Index: linux-2.6-lttng/arch/mips/Kconfig
===================================================================
@@ -1969,4 +1969,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/parisc/Kconfig +2 -0
Index: linux-2.6-lttng/arch/parisc/Kconfig
===================================================================
@@ -275,4 +275,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/powerpc/Kconfig +2 -0
Index: linux-2.6-lttng/arch/powerpc/Kconfig
===================================================================
@@ -650,3 +650,5 @@ config KEYS_COMPAT
 	default y
 
 source "crypto/Kconfig"
+
+source "samples/Kconfig"
arch/ppc/Kconfig +2 -0
Index: linux-2.6-lttng/arch/ppc/Kconfig
===================================================================
@@ -1314,3 +1314,5 @@ source "arch/ppc/Kconfig.debug"
 source "security/Kconfig"
 
 source "crypto/Kconfig"
+
+source "samples/Kconfig"
arch/s390/Kconfig +2 -0
Index: linux-2.6-lttng/arch/s390/Kconfig
===================================================================
@@ -537,4 +537,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/sh/Kconfig +2 -0
Index: linux-2.6-lttng/arch/sh/Kconfig
===================================================================
@@ -757,4 +757,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/sh64/Kconfig +2 -0
Index: linux-2.6-lttng/arch/sh64/Kconfig
===================================================================
@@ -293,6 +293,8 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
 
 #
arch/sparc/Kconfig +2 -0
Index: linux-2.6-lttng/arch/sparc/Kconfig
===================================================================
@@ -328,4 +328,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/sparc64/Kconfig +2 -0
Index: linux-2.6-lttng/arch/sparc64/Kconfig
===================================================================
@@ -468,4 +468,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/um/Kconfig +2 -0
Index: linux-2.6-lttng/arch/um/Kconfig
===================================================================
@@ -274,6 +274,8 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
 
 source "drivers/scsi/Kconfig"
arch/v850/Kconfig +2 -0
Index: linux-2.6-lttng/arch/v850/Kconfig
===================================================================
@@ -339,6 +339,8 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
 
 #############################################################################
arch/x86_64/Kconfig +2 -0
Index: linux-2.6-lttng/arch/x86_64/Kconfig
===================================================================
@@ -841,4 +841,6 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
+source "samples/Kconfig"
+
 source "lib/Kconfig"
arch/xtensa/Kconfig +2 -1
Index: linux-2.6-lttng/arch/xtensa/Kconfig
===================================================================
@@ -259,6 +259,7 @@ source "security/Kconfig"
 
 source "crypto/Kconfig"
 
-source "lib/Kconfig"
+source "samples/Kconfig"
 
+source "lib/Kconfig"
 
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

Re: [patch 3/5] Add samples subdir

Hi Mathieu & Randy.

Quoted 5 lines · Mathieu Desnoyers

From: Randy Dunlap <[email protected]>

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.
Source its Kconfig file in all arch/ Kconfigs.

Sorry for not commenting on this before...
The samples directory contains sample code so it is wrong to actually include it as part of the kernel IMHO.
We only want to keep the samples buildable and to do so
we can make a much simpler hack in the top-level Makefile. Consider following patch:

@@ -760,6 +760,9 @@ vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) vmlinux.o
ifdef CONFIG_HEADERS_CHECK

        $(Q)$(MAKE) -f $(srctree)/Makefile headers_check

endif
+ifdef CONFIG_SAMPLES
+ $(Q)$(MAKE) $(build)=samples
+endif

        $(call vmlinux-modpost)
        $(call if_changed_rule,vmlinux__)
        $(Q)rm -f .old_version

With this we build the samples when CONFIG_SAMPLES are selected and when the kernel is about to be linked.

As for the Kconfig file I am in favour of it but think a much more natural place is to source it in lib/Kconfig.debug. Then it will appear in "Kernel hacking" and the smaples are used for kernel hacking and not for regular people building their own kernel.

Sourcing samples/Kconfig from lib/Kconfig.debug will then take effect for all archs so the result is a much simpler Kconfig patch too.

Sam

#5 lore raw

Re: [patch 3/5] Add samples subdir

On Tue, 25 Sep 2007 21:00:36 +0200 Sam Ravnborg wrote:

Hi Sam,

Thanks for looking. I was hoping that you would find time to look/comment on it.

Quoted 38 lines

Hi Mathieu & Randy.

Quoted 5 lines · Mathieu Desnoyers

From: Randy Dunlap <[email protected]>

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.
Source its Kconfig file in all arch/ Kconfigs.

Sorry for not commenting on this before...
The samples directory contains sample code so it is wrong to actually include it as part of the kernel IMHO.
We only want to keep the samples buildable and to do so
we can make a much simpler hack in the top-level Makefile. Consider following patch:

(quoted diff) +3 -0
@@ -760,6 +760,9 @@ vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) vmlinux.o
 ifdef CONFIG_HEADERS_CHECK
        $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
 endif
+ifdef CONFIG_SAMPLES
+       $(Q)$(MAKE) $(build)=samples
+endif
        $(call vmlinux-modpost)
        $(call if_changed_rule,vmlinux__)
        $(Q)rm -f .old_version

With this we build the samples when CONFIG_SAMPLES are selected and when the kernel is about to be linked.

As for the Kconfig file I am in favour of it but think a much more natural place is to source it in lib/Kconfig.debug. Then it will appear in "Kernel hacking" and the smaples are used for kernel hacking and not for regular people building their own kernel.

Quoted 3 lines

Sourcing samples/Kconfig from lib/Kconfig.debug will then take effect for all archs so the result is a much simpler Kconfig patch too.

These changes all sound good to me.

Mathieu, can you find time to do this or should I do it?

---
~Randy
Phaedrus says that Quality is about caring.

#6 lore raw

Re: [patch 3/5] Add samples subdir

Quoted 45 lines · * Randy Dunlap ([email protected]) wrote:

On Tue, 25 Sep 2007 21:00:36 +0200 Sam Ravnborg wrote:

Hi Sam,

Thanks for looking. I was hoping that you would find time to look/comment on it.

Quoted 38 lines

Hi Mathieu & Randy.

Quoted 5 lines · Mathieu Desnoyers

From: Randy Dunlap <[email protected]>

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.
Source its Kconfig file in all arch/ Kconfigs.

Sorry for not commenting on this before...
The samples directory contains sample code so it is wrong to actually include it as part of the kernel IMHO.
We only want to keep the samples buildable and to do so
we can make a much simpler hack in the top-level Makefile. Consider following patch:

(quoted diff) +3 -0
@@ -760,6 +760,9 @@ vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) vmlinux.o
 ifdef CONFIG_HEADERS_CHECK
        $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
 endif
+ifdef CONFIG_SAMPLES
+       $(Q)$(MAKE) $(build)=samples
+endif
        $(call vmlinux-modpost)
        $(call if_changed_rule,vmlinux__)
        $(Q)rm -f .old_version

With this we build the samples when CONFIG_SAMPLES are selected and when the kernel is about to be linked.

As for the Kconfig file I am in favour of it but think a much more natural place is to source it in lib/Kconfig.debug. Then it will appear in "Kernel hacking" and the smaples are used for kernel hacking and not for regular people building their own kernel.

Quoted 8 lines
Quoted 3 lines

Sourcing samples/Kconfig from lib/Kconfig.debug will then take effect for all archs so the result is a much simpler Kconfig patch too.

These changes all sound good to me.

Mathieu, can you find time to do this or should I do it?

I'll take care of it.

Quoted 3 lines

---
~Randy
Phaedrus says that Quality is about caring.

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

Re: [patch 3/5] Add samples subdir (updated)

In reply to Randy Dunlap

Randy, since I did big changes to the patch, I removed your Signed-off-by. Tell me if you want me to add it back... (Is the From:
still valid ?)

Mathieu

Add samples subdir (updated)

From: Randy Dunlap <[email protected]>

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.

Changelog:
- Move menu to Kernel Hacking
- Don't build with the kernel image

---
 Makefile          |    3 +++
 lib/Kconfig.debug |    2 ++
 samples/Kconfig   |   11 +++++++++++
 3 files changed, 16 insertions(+)
Makefile +3 -0
Index: linux-2.6-lttng/Makefile
===================================================================
@@ -770,6 +770,9 @@ vmlinux: $(vmlinux-lds) $(vmlinux-init) 
 ifdef CONFIG_HEADERS_CHECK
 	$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
 endif
+ifdef CONFIG_SAMPLES
+	$(Q)$(MAKE) $(build)=samples
+endif
 	$(call vmlinux-modpost)
 	$(call if_changed_rule,vmlinux__)
 	$(Q)rm -f .old_version
samples/Kconfig new file +11 -0
Index: linux-2.6-lttng/samples/Kconfig
===================================================================
@@ -0,0 +1,11 @@
+# samples/Kconfig
+
+menuconfig SAMPLES
+	bool "Sample kernel code"
+	help
+	  You can build and test sample kernel code here.
+
+if SAMPLES
+
+
+endif # SAMPLES
lib/Kconfig.debug +2 -0
Index: linux-2.6-lttng/lib/Kconfig.debug
===================================================================
@@ -558,3 +558,5 @@ config FAULT_INJECTION_STACKTRACE_FILTER
 	  Provide stacktrace filter for fault-injection capabilities
 
 source "lib/Kconfig.kgdb"
+
+source "samples/Kconfig"
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

Re: [patch 3/5] Add samples subdir (updated)

Quoted 5 lines · On Tue, 25 Sep 2007 16:50:21 -0400 Mathieu Desnoyers wrote:

Randy, since I did big changes to the patch, I removed your Signed-off-by. Tell me if you want me to add it back... (Is the From:
still valid ?)

Mathieu

Heck, I dunno.
Just make it from you and SOB by me, if that works_for_you.

Quoted 61 lines

Add samples subdir (updated)

From: Randy Dunlap <[email protected]>

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.

Changelog:
- Move menu to Kernel Hacking
- Don't build with the kernel image

---
 Makefile          |    3 +++
 lib/Kconfig.debug |    2 ++
 samples/Kconfig   |   11 +++++++++++
 3 files changed, 16 insertions(+)

Index: linux-2.6-lttng/Makefile
===================================================================

Makefile +3 -0
@@ -770,6 +770,9 @@ vmlinux: $(vmlinux-lds) $(vmlinux-init) 
 ifdef CONFIG_HEADERS_CHECK
 	$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
 endif
+ifdef CONFIG_SAMPLES
+	$(Q)$(MAKE) $(build)=samples
+endif
 	$(call vmlinux-modpost)
 	$(call if_changed_rule,vmlinux__)
 	$(Q)rm -f .old_version

Index: linux-2.6-lttng/samples/Kconfig
===================================================================

samples/Kconfig new file +11 -0
@@ -0,0 +1,11 @@
+# samples/Kconfig
+
+menuconfig SAMPLES
+	bool "Sample kernel code"
+	help
+	  You can build and test sample kernel code here.
+
+if SAMPLES
+
+
+endif # SAMPLES

Index: linux-2.6-lttng/lib/Kconfig.debug
===================================================================

lib/Kconfig.debug +2 -0
@@ -558,3 +558,5 @@ config FAULT_INJECTION_STACKTRACE_FILTER
 	  Provide stacktrace filter for fault-injection capabilities
 
 source "lib/Kconfig.kgdb"
+
+source "samples/Kconfig"
Signature · 1 line
-- 

---
~Randy
Phaedrus says that Quality is about caring.

#9 lore raw

Re: [patch 3/5] Add samples subdir (updated)

In reply to Mathieu Desnoyers
Quoted 5 lines · Mathieu Desnoyers

Randy, since I did big changes to the patch, I removed your Signed-off-by. Tell me if you want me to add it back... (Is the From:
still valid ?)

Mathieu

How about from: you and add

Thanks.

Quoted 59 lines

Add samples subdir (updated)

From: Randy Dunlap <[email protected]>

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.

Changelog:
- Move menu to Kernel Hacking
- Don't build with the kernel image

---
 Makefile          |    3 +++
 lib/Kconfig.debug |    2 ++
 samples/Kconfig   |   11 +++++++++++
 3 files changed, 16 insertions(+)

Index: linux-2.6-lttng/Makefile
===================================================================

Makefile +3 -0
@@ -770,6 +770,9 @@ vmlinux: $(vmlinux-lds) $(vmlinux-init) 
 ifdef CONFIG_HEADERS_CHECK
 	$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
 endif
+ifdef CONFIG_SAMPLES
+	$(Q)$(MAKE) $(build)=samples
+endif
 	$(call vmlinux-modpost)
 	$(call if_changed_rule,vmlinux__)
 	$(Q)rm -f .old_version

Index: linux-2.6-lttng/samples/Kconfig
===================================================================

samples/Kconfig new file +11 -0
@@ -0,0 +1,11 @@
+# samples/Kconfig
+
+menuconfig SAMPLES
+	bool "Sample kernel code"
+	help
+	  You can build and test sample kernel code here.
+
+if SAMPLES
+
+
+endif # SAMPLES

Index: linux-2.6-lttng/lib/Kconfig.debug
===================================================================

lib/Kconfig.debug +2 -0
@@ -558,3 +558,5 @@ config FAULT_INJECTION_STACKTRACE_FILTER
 	  Provide stacktrace filter for fault-injection capabilities
 
 source "lib/Kconfig.kgdb"
+
+source "samples/Kconfig"
Signature · 2 lines
~Randy
Phaedrus says that Quality is about caring.
#10 lore raw

Re: [patch 3/5] Add samples subdir

In reply to Sam Ravnborg

* Tue, 25 Sep 2007 21:00:36 +0200

Quoted 6 lines

Hi Mathieu & Randy.

Quoted 2 lines · Mathieu Desnoyers

From: Randy Dunlap <[email protected]>

Quoted 7 lines
Quoted 3 lines

Begin infrastructure for kernel code samples in the samples/ directory. Add its Kconfig and Kbuild files.
Source its Kconfig file in all arch/ Kconfigs.

Sorry for not commenting on this before...
The samples directory contains sample code so it is wrong to actually include it as part of the kernel IMHO.

Count my HO too.

Kernel isn't school desk at first place. It's already bloated as with various 2+y obsolete changelogs (that have content, that even older), with unsorted documentation (hypertext and http are better on this).

Up to date test cases and example code must be on developer's site, not as burden in the sources. Yea, linux tar ball is a popular one. But sorry, it already has too much unneeded stuff for most of the freelance users and testers. This tarball must have good end result with propper changelogs and pointers to *fresh* information. --
-o--=O`C
#oo'L O
<___=E M

#11 lore raw

PATCH 4/5 Linux Kernel Markers - Samples

In reply to Mathieu Desnoyers

Module example showing how to use the Linux Kernel Markers.

---
 samples/Kconfig                  |    5 +
 samples/Makefile                 |    3 +
 samples/markers/Makefile         |    4 +
 samples/markers/marker-example.c |   55 +++++++++++++++++++++
 samples/markers/probe-example.c  |   98 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 165 insertions(+)
samples/markers/Makefile new file +4 -0
Index: linux-2.6-lttng/samples/markers/Makefile
===================================================================
@@ -0,0 +1,4 @@
+# builds the kprobes example kernel modules;
+# then to use one (as root):  insmod <module_name.ko>
+
+obj-$(CONFIG_SAMPLE_MARKERS) += probe-example.o marker-example.o
samples/markers/marker-example.c new file +55 -0

55 lines not on this page · raw message

samples/markers/probe-example.c new file +98 -0

98 lines not on this page · raw message

samples/Makefile new file +3 -0
Index: linux-2.6-lttng/samples/Makefile
===================================================================
@@ -0,0 +1,3 @@
+# Makefile for Linux samples code
+
+obj-$(CONFIG_SAMPLES)	+= markers/
samples/Kconfig +5 -0
Index: linux-2.6-lttng/samples/Kconfig
===================================================================
@@ -7,5 +7,10 @@ menuconfig SAMPLES
 
 if SAMPLES
 
+config SAMPLE_MARKERS
+	tristate "Build markers examples -- loadable modules only"
+	depends on MARKERS && m
+	help
+	  This build markers example modules.
 
 endif # SAMPLES
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 5/5 Linux Kernel Markers - Documentation

In reply to Mathieu Desnoyers

Here is some documentation explaining what is/how to use the Linux Kernel Markers.

Changelog:
- Move the examples to a separate "samples" patch.

---

 Documentation/markers.txt |   81 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
Documentation/markers.txt new file +81 -0
Index: linux-2.6-lttng/Documentation/markers.txt
===================================================================
@@ -0,0 +1,81 @@
+ 	             Using the Linux Kernel Markers
+
+			    Mathieu Desnoyers
+
+
+This document introduces Linux Kernel Markers and their use. It provides
+examples of how to insert markers in the kernel and connect probe functions to
+them and provides some examples of probe functions.
+
+
+* Purpose of markers
+
+A marker placed in code provides a hook to call a function (probe) that you can
+provide at runtime. A marker can be "on" (a probe is connected to it) or "off"
+(no probe is attached). When a marker is "off" it has no effect, except for
+adding a tiny time penalty (checking a condition for a branch) and space
+penalty (adding a few bytes for the function call at the end of the
+instrumented function and adds a data structure in a separate section).  When a
+marker is "on", the function you provide is called each time the marker is
+executed, in the execution context of the caller. When the function provided
+ends its execution, it returns to the caller (continuing from the marker site).
+
+You can put markers at important locations in the code. Markers are
+lightweight hooks that can pass an arbitrary number of parameters,
+described in a printk-like format string, to the attached probe function.
+
+They can be used for tracing and performance accounting.
+
+
+* Usage
+
+In order to use the macro trace_mark, you should include linux/marker.h.
+
+#include <linux/marker.h>
+
+And,
+
+trace_mark(subsystem_event, "%d %s", someint, somestring);
+Where :
+- subsystem_event is an identifier unique to your event
+    - subsystem is the name of your subsystem.
+    - event is the name of the event to mark.
+- "%d %s" is the formatted string for the serializer.
+- someint is an integer.
+- somestring is a char pointer.
+
+Connecting a function (probe) to a marker is done by providing a probe (function
+to call) for the specific marker through marker_probe_register() and can be
+activated by calling marker_arm(). Marker deactivation can be done by calling
+marker_disarm() as many times as marker_arm() has been called. Removing a probe
+is done through marker_probe_unregister(); it will disarm the probe and make
+sure there is no caller left using the probe when it returns. Probe removal is
+preempt-safe because preemption is disabled around the probe call. See the
+"Probe example" section below for a sample probe module.
+
+The marker mechanism supports inserting multiple instances of the same marker.
+Markers can be put in inline functions, inlined static functions, and
+unrolled loops as well as regular functions.
+
+The naming scheme "subsystem_event" is suggested here as a convention intended
+to limit collisions. Marker names are global to the kernel: they are considered
+as being the same whether they are in the core kernel image or in modules.
+Conflicting format strings for markers with the same name will cause the markers
+to be detected to have a different format string not to be armed and will output
+a printk warning which identifies the inconsistency:
+
+"Format mismatch for probe probe_name (format), marker (format)"
+
+
+* Probe / marker example
+
+See the example provided in samples/markers/src
+
+Compile them with your kernel.
+
+Run, as root :
+modprobe marker-example (insmod order is not important)
+modprobe probe-example
+cat /proc/marker-example (returns an expected error)
+rmmod marker-example probe-example
+dmesg
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