* [patch 0/5] Linux Kernel Markers (redux)
@ 2007-09-25 12:11 Mathieu Desnoyers
2007-09-25 12:11 ` [patch 1/5] Combine instrumentation menus in kernel/Kconfig.instrumentation Mathieu Desnoyers
` (4 more replies)
0 siblings, 5 replies; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 12:11 UTC (permalink / raw)
To: akpm, linux-kernel; +Cc: Christoph Hellwig, Randy Dunlap
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
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 1/5] Combine instrumentation menus in kernel/Kconfig.instrumentation
2007-09-25 12:11 [patch 0/5] Linux Kernel Markers (redux) Mathieu Desnoyers
@ 2007-09-25 12:11 ` Mathieu Desnoyers
2007-09-25 12:11 ` [patch 2/5] Linux Kernel Markers Mathieu Desnoyers
` (3 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 12:11 UTC (permalink / raw)
To: akpm, linux-kernel; +Cc: Christoph Hellwig, Randy Dunlap, Mathieu Desnoyers
[-- Attachment #1: kconfig-instrumentation.patch --]
[-- Type: text/plain, Size: 30555 bytes --]
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."
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
---
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(-)
Index: linux-2.6-lttng/arch/alpha/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/alpha/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
-
Index: linux-2.6-lttng/arch/arm/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/arm/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +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.
-
-if OPROFILE
-
-config OPROFILE_ARMV6
- bool
- depends on CPU_V6 && !SMP
- default y
- select OPROFILE_ARM11_CORE
-
-config OPROFILE_MPCORE
- bool
- depends on CPU_V6 && SMP
- default y
- select OPROFILE_ARM11_CORE
-
-config OPROFILE_ARM11_CORE
- bool
-
-endif
-
-endmenu
-
Index: linux-2.6-lttng/arch/blackfin/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/blackfin/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
Index: linux-2.6-lttng/arch/i386/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/i386/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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.
-
Index: linux-2.6-lttng/arch/ia64/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/ia64/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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.
-
Index: linux-2.6-lttng/arch/m32r/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/m32r/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
-
Index: linux-2.6-lttng/arch/mips/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/mips/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
-
Index: linux-2.6-lttng/arch/parisc/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/parisc/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
-
Index: linux-2.6-lttng/arch/powerpc/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/powerpc/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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.
Index: linux-2.6-lttng/arch/s390/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/s390/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
-
Index: linux-2.6-lttng/arch/sh/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sh/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
-
Index: linux-2.6-lttng/arch/sh64/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sh64/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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
-
Index: linux-2.6-lttng/arch/sparc/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sparc/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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.
-
Index: linux-2.6-lttng/arch/sparc64/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sparc64/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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.
-
Index: linux-2.6-lttng/arch/x86_64/oprofile/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/x86_64/oprofile/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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.
-
Index: linux-2.6-lttng/kernel/Kconfig.instrumentation
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/kernel/Kconfig.instrumentation 2007-09-25 07:18:40.000000000 -0400
@@ -0,0 +1,43 @@
+menuconfig INSTRUMENTATION
+ bool "Instrumentation Support"
+ default y
+ ---help---
+ Say Y here to get to see options related to performance measurement,
+ system-wide 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 you're trying to debug the kernel itself, go see the
+ Kernel Hacking menu.
+
+if INSTRUMENTATION
+
+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
+ depends on ALPHA || ARM || BLACKFIN || X86_32 || IA64 || M32R || MIPS || PARISC || PPC || S390 || SUPERH || SPARC || X86_64
+ 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 KPROBES
+ bool "Kprobes"
+ depends on KALLSYMS && MODULES
+ depends on X86_32 || IA64 || PPC || S390 || SPARC64 || X86_64 || AVR32
+ 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
Index: linux-2.6-lttng/arch/i386/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/i386/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/i386/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -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"
Index: linux-2.6-lttng/arch/alpha/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/alpha/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/alpha/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -654,7 +654,7 @@ source "drivers/Kconfig"
source "fs/Kconfig"
-source "arch/alpha/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/alpha/Kconfig.debug"
Index: linux-2.6-lttng/arch/arm/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/arm/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/arm/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -1061,7 +1061,7 @@ endmenu
source "fs/Kconfig"
-source "arch/arm/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/arm/Kconfig.debug"
Index: linux-2.6-lttng/arch/blackfin/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/blackfin/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/blackfin/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -914,7 +914,7 @@ source "drivers/Kconfig"
source "fs/Kconfig"
-source "arch/blackfin/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
menu "Kernel hacking"
Index: linux-2.6-lttng/arch/cris/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/cris/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/cris/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -196,6 +196,8 @@ source "sound/Kconfig"
source "drivers/usb/Kconfig"
+source "kernel/Kconfig.instrumentation"
+
source "arch/cris/Kconfig.debug"
source "security/Kconfig"
Index: linux-2.6-lttng/arch/frv/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/frv/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/frv/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -375,6 +375,8 @@ source "drivers/Kconfig"
source "fs/Kconfig"
+source "kernel/Kconfig.instrumentation"
+
source "arch/frv/Kconfig.debug"
source "security/Kconfig"
Index: linux-2.6-lttng/arch/h8300/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/h8300/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/h8300/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -223,6 +223,8 @@ endmenu
source "fs/Kconfig"
+source "kernel/Kconfig.instrumentation"
+
source "arch/h8300/Kconfig.debug"
source "security/Kconfig"
Index: linux-2.6-lttng/arch/ia64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/ia64/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/ia64/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -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"
Index: linux-2.6-lttng/arch/m32r/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/m32r/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/m32r/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -426,7 +426,7 @@ source "drivers/Kconfig"
source "fs/Kconfig"
-source "arch/m32r/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/m32r/Kconfig.debug"
Index: linux-2.6-lttng/arch/m68k/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/m68k/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/m68k/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -683,6 +683,8 @@ endmenu
source "fs/Kconfig"
+source "kernel/Kconfig.instrumentation"
+
source "arch/m68k/Kconfig.debug"
source "security/Kconfig"
Index: linux-2.6-lttng/arch/m68knommu/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/m68knommu/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/m68knommu/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -696,6 +696,8 @@ source "drivers/Kconfig"
source "fs/Kconfig"
+source "kernel/Kconfig.instrumentation"
+
source "arch/m68knommu/Kconfig.debug"
source "security/Kconfig"
Index: linux-2.6-lttng/arch/mips/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/mips/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/mips/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -1961,7 +1961,7 @@ source "drivers/Kconfig"
source "fs/Kconfig"
-source "arch/mips/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/mips/Kconfig.debug"
Index: linux-2.6-lttng/arch/parisc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/parisc/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/parisc/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -267,7 +267,7 @@ source "drivers/Kconfig"
source "fs/Kconfig"
-source "arch/parisc/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/parisc/Kconfig.debug"
Index: linux-2.6-lttng/arch/powerpc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/powerpc/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/powerpc/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -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"
Index: linux-2.6-lttng/arch/ppc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/ppc/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/ppc/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -1307,7 +1307,7 @@ endmenu
source "lib/Kconfig"
-source "arch/powerpc/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/ppc/Kconfig.debug"
Index: linux-2.6-lttng/arch/s390/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/s390/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/s390/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -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"
Index: linux-2.6-lttng/arch/sh/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sh/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/sh/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -749,7 +749,7 @@ source "drivers/Kconfig"
source "fs/Kconfig"
-source "arch/sh/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/sh/Kconfig.debug"
Index: linux-2.6-lttng/arch/sh64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sh64/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/sh64/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -285,7 +285,7 @@ source "drivers/Kconfig"
source "fs/Kconfig"
-source "arch/sh64/oprofile/Kconfig"
+source "kernel/Kconfig.instrumentation"
source "arch/sh64/Kconfig.debug"
Index: linux-2.6-lttng/arch/sparc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sparc/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/sparc/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -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"
Index: linux-2.6-lttng/arch/sparc64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sparc64/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/sparc64/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -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"
Index: linux-2.6-lttng/arch/um/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/um/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/um/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -289,4 +289,6 @@ config INPUT
bool
default n
+source "kernel/Kconfig.instrumentation"
+
source "arch/um/Kconfig.debug"
Index: linux-2.6-lttng/arch/v850/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/v850/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/v850/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -331,6 +331,8 @@ source "sound/Kconfig"
source "drivers/usb/Kconfig"
+source "kernel/Kconfig.instrumentation"
+
source "arch/v850/Kconfig.debug"
source "security/Kconfig"
Index: linux-2.6-lttng/arch/x86_64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/x86_64/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/x86_64/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -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"
Index: linux-2.6-lttng/arch/xtensa/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/xtensa/Kconfig 2007-09-24 15:00:24.000000000 -0400
+++ linux-2.6-lttng/arch/xtensa/Kconfig 2007-09-25 07:17:48.000000000 -0400
@@ -251,6 +251,8 @@ config EMBEDDED_RAMDISK_IMAGE
provide one yourself.
endmenu
+source "kernel/Kconfig.instrumentation"
+
source "arch/xtensa/Kconfig.debug"
source "security/Kconfig"
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 2/5] Linux Kernel Markers
2007-09-25 12:11 [patch 0/5] Linux Kernel Markers (redux) Mathieu Desnoyers
2007-09-25 12:11 ` [patch 1/5] Combine instrumentation menus in kernel/Kconfig.instrumentation Mathieu Desnoyers
@ 2007-09-25 12:11 ` Mathieu Desnoyers
2007-09-25 12:11 ` [patch 3/5] Add samples subdir Mathieu Desnoyers
` (2 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 12:11 UTC (permalink / raw)
To: akpm, linux-kernel
Cc: Christoph Hellwig, Randy Dunlap, Mathieu Desnoyers,
Frank Ch. Eigler, Rusty Russell
[-- Attachment #1: linux-kernel-markers.patch --]
[-- Type: text/plain, Size: 26133 bytes --]
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.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Acked-by: "Frank Ch. Eigler" <fche@redhat.com>
CC: Christoph Hellwig <hch@infradead.org>
CC: Rusty Russell <rusty@rustcorp.com.au>
---
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(-)
Index: linux-2.6-lttng/include/asm-generic/vmlinux.lds.h
===================================================================
--- linux-2.6-lttng.orig/include/asm-generic/vmlinux.lds.h 2007-09-25 07:17:49.000000000 -0400
+++ linux-2.6-lttng/include/asm-generic/vmlinux.lds.h 2007-09-25 07:18:50.000000000 -0400
@@ -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) { \
Index: linux-2.6-lttng/include/linux/marker.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/include/linux/marker.h 2007-09-25 07:18:50.000000000 -0400
@@ -0,0 +1,130 @@
+#ifndef _LINUX_MARKER_H
+#define _LINUX_MARKER_H
+
+/*
+ * Code markup for dynamic and static tracing.
+ *
+ * See Documentation/marker.txt.
+ *
+ * (C) Copyright 2006 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ * This file is released under the GPLv2.
+ * See the file COPYING for more details.
+ */
+
+#include <linux/types.h>
+
+struct module;
+struct __mark_marker;
+
+/**
+ * marker_probe_func - Type of a marker probe function
+ * @mdata: pointer of type struct __mark_marker
+ * @private_data: caller site private data
+ * @fmt: format string
+ * @...: variable argument list
+ *
+ * Type of marker probe functions. They receive the mdata and need to parse the
+ * format string to recover the variable argument list.
+ */
+typedef void marker_probe_func(const struct __mark_marker *mdata,
+ void *private_data, const char *fmt, ...);
+
+struct __mark_marker {
+ const char *name; /* Marker name */
+ const char *format; /* Marker format string, describing the
+ * variable argument list.
+ */
+ char state; /* Marker state. */
+ marker_probe_func *call;/* Probe handler function pointer */
+ void *private; /* Private probe data */
+} __attribute__((aligned(8)));
+
+#ifdef CONFIG_MARKERS
+
+/*
+ * Note : the empty asm volatile with read constraint is used here instead of a
+ * "used" attribute to fix a gcc 4.1.x bug.
+ * Make sure the alignment of the structure in the __markers section will
+ * not add unwanted padding between the beginning of the section and the
+ * structure. Force alignment to the same alignment as the section start.
+ */
+#define __trace_mark(name, call_data, format, args...) \
+ do { \
+ static const char __mstrtab_name_##name[] \
+ __attribute__((section("__markers_strings"))) \
+ = #name; \
+ static const char __mstrtab_format_##name[] \
+ __attribute__((section("__markers_strings"))) \
+ = format; \
+ static struct __mark_marker __mark_##name \
+ __attribute__((section("__markers"))) = \
+ { __mstrtab_name_##name, __mstrtab_format_##name, \
+ 0, __mark_empty_function, NULL }; \
+ asm volatile ( "" : : "i" (&__mark_##name)); \
+ __mark_check_format(format, ## args); \
+ if (unlikely(__mark_##name.state)) { \
+ preempt_disable(); \
+ (*__mark_##name.call) \
+ (&__mark_##name, call_data, \
+ format, ## args); \
+ preempt_enable(); \
+ } \
+ } while (0)
+
+extern void marker_update_probe_range(struct __mark_marker *begin,
+ struct __mark_marker *end, struct module *probe_module, int *refcount);
+#else /* !CONFIG_MARKERS */
+#define __trace_mark(name, call_data, format, args...) \
+ __mark_check_format(format, ## args)
+static inline void marker_update_probe_range(struct __mark_marker *begin,
+ struct __mark_marker *end, struct module *probe_module, int *refcount)
+{ }
+#endif /* CONFIG_MARKERS */
+
+/**
+ * trace_mark - Marker
+ * @name: marker name, not quoted.
+ * @format: format string
+ * @args...: variable argument list
+ *
+ * Places a marker.
+ */
+#define trace_mark(name, format, args...) \
+ __trace_mark(name, NULL, format, ## args)
+
+#define MARK_MAX_FORMAT_LEN 1024
+
+/**
+ * MARK_NOARGS - Format string for a marker with no argument.
+ */
+#define MARK_NOARGS " "
+
+/* To be used for string format validity checking with gcc */
+static inline void __printf(1, 2) __mark_check_format(const char *fmt, ...)
+{
+}
+
+extern marker_probe_func __mark_empty_function;
+
+/*
+ * Connect a probe to a marker.
+ * private data pointer must be a valid allocated memory address, or NULL.
+ */
+extern int marker_probe_register(const char *name, const char *format,
+ marker_probe_func *probe, void *private);
+
+/*
+ * Returns the private data given to marker_probe_register.
+ */
+extern void *marker_probe_unregister(const char *name);
+/*
+ * Unregister a marker by providing the registered private data.
+ */
+extern void *marker_probe_unregister_private_data(void *private);
+
+extern int marker_arm(const char *name);
+extern int marker_disarm(const char *name);
+extern void *marker_get_private_data(const char *name);
+
+#endif
Index: linux-2.6-lttng/include/linux/module.h
===================================================================
--- linux-2.6-lttng.orig/include/linux/module.h 2007-09-25 07:17:49.000000000 -0400
+++ linux-2.6-lttng/include/linux/module.h 2007-09-25 07:18:50.000000000 -0400
@@ -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;
Index: linux-2.6-lttng/kernel/module.c
===================================================================
--- linux-2.6-lttng.orig/kernel/module.c 2007-09-25 07:17:49.000000000 -0400
+++ linux-2.6-lttng/kernel/module.c 2007-09-25 07:18:50.000000000 -0400
@@ -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
Index: linux-2.6-lttng/kernel/marker.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/kernel/marker.c 2007-09-25 07:18:50.000000000 -0400
@@ -0,0 +1,527 @@
+/*
+ * Copyright (C) 2007 Mathieu Desnoyers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/types.h>
+#include <linux/jhash.h>
+#include <linux/list.h>
+#include <linux/rcupdate.h>
+#include <linux/marker.h>
+#include <linux/err.h>
+
+extern struct __mark_marker __start___markers[];
+extern struct __mark_marker __stop___markers[];
+
+/*
+ * module_mutex nests inside markers_mutex. Markers mutex protects the builtin
+ * and module markers, the hash table and deferred_sync.
+ */
+DEFINE_MUTEX(markers_mutex);
+
+/*
+ * Marker deferred synchronization.
+ * Upon marker probe_unregister, we delay call to synchronize_sched() to
+ * accelerate mass unregistration (only when there is no more reference to a
+ * given module do we call synchronize_sched()). However, we need to make sure
+ * every critical region has ended before we re-arm a marker that has been
+ * unregistered and then registered back with a different probe data.
+ */
+static int deferred_sync;
+
+/*
+ * Marker hash table, containing the active markers.
+ * Protected by module_mutex.
+ */
+#define MARKER_HASH_BITS 6
+#define MARKER_TABLE_SIZE (1 << MARKER_HASH_BITS)
+
+struct marker_entry {
+ struct hlist_node hlist;
+ char *format;
+ marker_probe_func *probe;
+ void *private;
+ int refcount; /* Number of times armed. 0 if disarmed. */
+ char name[0]; /* Contains name'\0'format'\0' */
+};
+
+static struct hlist_head marker_table[MARKER_TABLE_SIZE];
+
+/**
+ * __mark_empty_function - Empty probe callback
+ * @mdata: pointer of type const struct __mark_marker
+ * @fmt: format string
+ * @...: variable argument list
+ *
+ * Empty callback provided as a probe to the markers. By providing this to a
+ * disabled marker, we make sure the execution flow is always valid even
+ * though the function pointer change and the marker enabling are two distinct
+ * operations that modifies the execution flow of preemptible code.
+ */
+void __mark_empty_function(const struct __mark_marker *mdata,
+ void *private_data,
+ const char *fmt, ...)
+{
+}
+EXPORT_SYMBOL_GPL(__mark_empty_function);
+
+/*
+ * Get marker if the marker is present in the marker hash table.
+ * Must be called with markers_mutex held.
+ * Returns NULL if not present.
+ */
+static struct marker_entry *get_marker(const char *name)
+{
+ struct hlist_head *head;
+ struct hlist_node *node;
+ struct marker_entry *e;
+ u32 hash = jhash(name, strlen(name), 0);
+
+ head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
+ hlist_for_each_entry(e, node, head, hlist) {
+ if (!strcmp(name, e->name))
+ return e;
+ }
+ return NULL;
+}
+
+/*
+ * Add the marker to the marker hash table. Must be called with markers_mutex
+ * held.
+ */
+static int add_marker(const char *name, const char *format,
+ marker_probe_func *probe, void *private)
+{
+ struct hlist_head *head;
+ struct hlist_node *node;
+ struct marker_entry *e;
+ size_t name_len = strlen(name) + 1;
+ size_t format_len = 0;
+ u32 hash = jhash(name, name_len-1, 0);
+
+ if (format)
+ format_len = strlen(format) + 1;
+ head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
+ hlist_for_each_entry(e, node, head, hlist) {
+ if (!strcmp(name, e->name)) {
+ printk(KERN_NOTICE
+ "Marker %s busy, probe %p already installed\n",
+ name, e->probe);
+ return -EBUSY; /* Already there */
+ }
+ }
+ /*
+ * Using kmalloc here to allocate a variable length element. Could
+ * cause some memory fragmentation if overused.
+ */
+ e = kmalloc(sizeof(struct marker_entry) + name_len + format_len,
+ GFP_KERNEL);
+ if (!e)
+ return -ENOMEM;
+ memcpy(&e->name[0], name, name_len);
+ if (format) {
+ e->format = &e->name[name_len];
+ memcpy(e->format, format, format_len);
+ trace_mark(core_marker_format, "name %s format %s",
+ e->name, e->format);
+ } else
+ e->format = NULL;
+ e->probe = probe;
+ e->private = private;
+ e->refcount = 0;
+ hlist_add_head(&e->hlist, head);
+ return 0;
+}
+
+/*
+ * Remove the marker from the marker hash table. Must be called with mutex_lock
+ * held.
+ */
+static void *remove_marker(const char *name)
+{
+ struct hlist_head *head;
+ struct hlist_node *node;
+ struct marker_entry *e;
+ int found = 0;
+ size_t len = strlen(name) + 1;
+ void *private = NULL;
+ u32 hash = jhash(name, len-1, 0);
+
+ head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
+ hlist_for_each_entry(e, node, head, hlist) {
+ if (!strcmp(name, e->name)) {
+ found = 1;
+ break;
+ }
+ }
+ if (found) {
+ private = e->private;
+ hlist_del(&e->hlist);
+ kfree(e);
+ }
+ return private;
+}
+
+/*
+ * Set the mark_entry format to the format found in the element.
+ */
+static int marker_set_format(struct marker_entry **entry, const char *format)
+{
+ struct marker_entry *e;
+ size_t name_len = strlen((*entry)->name) + 1;
+ size_t format_len = strlen(format) + 1;
+
+ e = kmalloc(sizeof(struct marker_entry) + name_len + format_len,
+ GFP_KERNEL);
+ if (!e)
+ return -ENOMEM;
+ memcpy(&e->name[0], (*entry)->name, name_len);
+ e->format = &e->name[name_len];
+ memcpy(e->format, format, format_len);
+ e->probe = (*entry)->probe;
+ e->private = (*entry)->private;
+ e->refcount = (*entry)->refcount;
+ hlist_add_before(&e->hlist, &(*entry)->hlist);
+ hlist_del(&(*entry)->hlist);
+ kfree(*entry);
+ *entry = e;
+ trace_mark(core_marker_format, "name %s format %s",
+ e->name, e->format);
+ return 0;
+}
+
+/*
+ * Sets the probe callback corresponding to one marker.
+ */
+static int set_marker(struct marker_entry **entry,
+ struct __mark_marker *elem)
+{
+ int ret;
+ WARN_ON(strcmp((*entry)->name, elem->name) != 0);
+
+ if ((*entry)->format) {
+ if (strcmp((*entry)->format, elem->format) != 0) {
+ printk(KERN_NOTICE
+ "Format mismatch for probe %s "
+ "(%s), marker (%s)\n",
+ (*entry)->name,
+ (*entry)->format,
+ elem->format);
+ return -EPERM;
+ }
+ } else {
+ ret = marker_set_format(entry, elem->format);
+ if (ret)
+ return ret;
+ }
+ elem->call = (*entry)->probe;
+ elem->private = (*entry)->private;
+ elem->state = 1;
+ return 0;
+}
+
+/*
+ * Disable a marker and its probe callback.
+ * Note: only after a synchronize_sched() issued after setting elem->call to the
+ * empty function insures that the original callback is not used anymore. This
+ * insured by preemption disabling around the call site.
+ */
+static void disable_marker(struct __mark_marker *elem)
+{
+ elem->state = 0;
+ elem->call = __mark_empty_function;
+ /*
+ * Leave the private data and id there, because removal is racy and
+ * should be done only after a synchronize_sched(). These are never used
+ * until the next initialization anyway.
+ */
+}
+
+/**
+ * marker_update_probe_range - Update a probe range
+ * @begin: beginning of the range
+ * @end: end of the range
+ * @probe_module: module address of the probe being updated
+ * @refcount: number of references left to the given probe_module (out)
+ *
+ * Updates the probe callback corresponding to a range of markers.
+ * Must be called with markers_mutex held.
+ */
+void marker_update_probe_range(struct __mark_marker *begin,
+ struct __mark_marker *end, struct module *probe_module,
+ int *refcount)
+{
+ struct __mark_marker *iter;
+ struct marker_entry *mark_entry;
+
+ for (iter = begin; iter < end; iter++) {
+ mark_entry = get_marker(iter->name);
+ if (mark_entry && mark_entry->refcount) {
+ set_marker(&mark_entry, iter);
+ /*
+ * ignore error, continue
+ */
+ if (probe_module)
+ if (probe_module ==
+ __module_text_address((unsigned long)mark_entry->probe))
+ (*refcount)++;
+ } else {
+ disable_marker(iter);
+ }
+ }
+}
+
+/*
+ * Update probes, removing the faulty probes.
+ * Issues a synchronize_sched() when no reference to the module passed
+ * as parameter is found in the probes so the probe module can be
+ * safely unloaded from now on.
+ */
+static void marker_update_probes(struct module *probe_module)
+{
+ int refcount = 0;
+
+ mutex_lock(&markers_mutex);
+ /* Core kernel markers */
+ marker_update_probe_range(__start___markers,
+ __stop___markers, probe_module, &refcount);
+ /* Markers in modules. */
+ module_update_markers(probe_module, &refcount);
+ if (probe_module && refcount == 0) {
+ synchronize_sched();
+ deferred_sync = 0;
+ }
+ mutex_unlock(&markers_mutex);
+}
+
+/**
+ * marker_probe_register - Connect a probe to a marker
+ * @name: marker name
+ * @format: format string
+ * @probe: probe handler
+ * @private: probe private data
+ *
+ * private data must be a valid allocated memory address, or NULL.
+ * Returns 0 if ok, error value on error.
+ */
+int marker_probe_register(const char *name, const char *format,
+ marker_probe_func *probe, void *private)
+{
+ struct marker_entry *entry;
+ int ret = 0, need_update = 0;
+
+ mutex_lock(&markers_mutex);
+ entry = get_marker(name);
+ if (entry && entry->refcount) {
+ ret = -EBUSY;
+ goto end;
+ }
+ if (deferred_sync) {
+ synchronize_sched();
+ deferred_sync = 0;
+ }
+ ret = add_marker(name, format, probe, private);
+ if (ret)
+ goto end;
+ need_update = 1;
+end:
+ mutex_unlock(&markers_mutex);
+ if (need_update)
+ marker_update_probes(NULL);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(marker_probe_register);
+
+/**
+ * marker_probe_unregister - Disconnect a probe from a marker
+ * @name: marker name
+ *
+ * Returns the private data given to marker_probe_register, or an ERR_PTR().
+ */
+void *marker_probe_unregister(const char *name)
+{
+ struct module *probe_module;
+ struct marker_entry *entry;
+ void *private;
+ int need_update = 0;
+
+ mutex_lock(&markers_mutex);
+ entry = get_marker(name);
+ if (!entry) {
+ private = ERR_PTR(-ENOENT);
+ goto end;
+ }
+ entry->refcount = 0;
+ /* In what module is the probe handler ? */
+ probe_module = __module_text_address((unsigned long)entry->probe);
+ private = remove_marker(name);
+ deferred_sync = 1;
+ need_update = 1;
+end:
+ mutex_unlock(&markers_mutex);
+ if (need_update)
+ marker_update_probes(probe_module);
+ return private;
+}
+EXPORT_SYMBOL_GPL(marker_probe_unregister);
+
+/**
+ * marker_probe_unregister_private_data - Disconnect a probe from a marker
+ * @private: probe private data
+ *
+ * Unregister a marker by providing the registered private data.
+ * Returns the private data given to marker_probe_register, or an ERR_PTR().
+ */
+void *marker_probe_unregister_private_data(void *private)
+{
+ struct module *probe_module;
+ struct hlist_head *head;
+ struct hlist_node *node;
+ struct marker_entry *entry;
+ int found = 0;
+ unsigned int i;
+ int need_update = 0;
+
+ mutex_lock(&markers_mutex);
+ for (i = 0; i < MARKER_TABLE_SIZE; i++) {
+ head = &marker_table[i];
+ hlist_for_each_entry(entry, node, head, hlist) {
+ if (entry->private == private) {
+ found = 1;
+ goto iter_end;
+ }
+ }
+ }
+iter_end:
+ if (!found) {
+ private = ERR_PTR(-ENOENT);
+ goto end;
+ }
+ entry->refcount = 0;
+ /* In what module is the probe handler ? */
+ probe_module = __module_text_address((unsigned long)entry->probe);
+ private = remove_marker(entry->name);
+ deferred_sync = 1;
+ need_update = 1;
+end:
+ mutex_unlock(&markers_mutex);
+ if (need_update)
+ marker_update_probes(probe_module);
+ return private;
+}
+EXPORT_SYMBOL_GPL(marker_probe_unregister_private_data);
+
+/**
+ * marker_arm - Arm a marker
+ * @name: marker name
+ *
+ * Activate a marker. It keeps a reference count of the number of
+ * arming/disarming done.
+ * Returns 0 if ok, error value on error.
+ */
+int marker_arm(const char *name)
+{
+ struct marker_entry * entry;
+ int ret = 0, need_update = 0;
+
+ mutex_lock(&markers_mutex);
+ entry = get_marker(name);
+ if (!entry) {
+ ret = -ENOENT;
+ goto end;
+ }
+ /*
+ * Only need to update probes when refcount passes from 0 to 1.
+ */
+ if (entry->refcount++)
+ goto end;
+ need_update = 1;
+end:
+ mutex_unlock(&markers_mutex);
+ if (need_update)
+ marker_update_probes(NULL);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(marker_arm);
+
+/**
+ * marker_disarm - Disarm a marker
+ * @name: marker name
+ *
+ * Disarm a marker. It keeps a reference count of the number of arming/disarming
+ * done.
+ * Returns 0 if ok, error value on error.
+ */
+int marker_disarm(const char *name)
+{
+ struct marker_entry * entry;
+ int ret = 0, need_update = 0;
+
+ mutex_lock(&markers_mutex);
+ entry = get_marker(name);
+ if (!entry) {
+ ret = -ENOENT;
+ goto end;
+ }
+ /*
+ * Only permit decrement refcount if higher than 0.
+ * Do probe update only on 1 -> 0 transition.
+ */
+ if (entry->refcount) {
+ if (--entry->refcount)
+ goto end;
+ } else {
+ ret = -EPERM;
+ goto end;
+ }
+ need_update = 1;
+end:
+ mutex_unlock(&markers_mutex);
+ if (need_update)
+ marker_update_probes(NULL);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(marker_disarm);
+
+/**
+ * marker_get_private_data - Get a marker's probe private data
+ * @name: marker name
+ *
+ * Returns the private data pointer, or an ERR_PTR.
+ * The private data pointer should _only_ be dereferenced if the caller is the
+ * owner of the data, or its content could vanish. This is mostly used to
+ * confirm that a caller is the owner of a registered probe.
+ */
+void *marker_get_private_data(const char *name)
+{
+ struct hlist_head *head;
+ struct hlist_node *node;
+ struct marker_entry *e;
+ size_t name_len = strlen(name) + 1;
+ u32 hash = jhash(name, name_len-1, 0);
+ int found = 0;
+
+ head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
+ hlist_for_each_entry(e, node, head, hlist) {
+ if (!strcmp(name, e->name)) {
+ found = 1;
+ return e->private;
+ }
+ }
+ return ERR_PTR(-ENOENT);
+}
+EXPORT_SYMBOL_GPL(marker_get_private_data);
Index: linux-2.6-lttng/kernel/Kconfig.instrumentation
===================================================================
--- linux-2.6-lttng.orig/kernel/Kconfig.instrumentation 2007-09-25 07:18:40.000000000 -0400
+++ linux-2.6-lttng/kernel/Kconfig.instrumentation 2007-09-25 07:18:50.000000000 -0400
@@ -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
Index: linux-2.6-lttng/kernel/Makefile
===================================================================
--- linux-2.6-lttng.orig/kernel/Makefile 2007-09-25 07:17:49.000000000 -0400
+++ linux-2.6-lttng/kernel/Makefile 2007-09-25 07:18:50.000000000 -0400
@@ -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 <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 3/5] Add samples subdir
2007-09-25 12:11 [patch 0/5] Linux Kernel Markers (redux) Mathieu Desnoyers
2007-09-25 12:11 ` [patch 1/5] Combine instrumentation menus in kernel/Kconfig.instrumentation Mathieu Desnoyers
2007-09-25 12:11 ` [patch 2/5] Linux Kernel Markers Mathieu Desnoyers
@ 2007-09-25 12:11 ` Mathieu Desnoyers
2007-09-25 19:00 ` Sam Ravnborg
2007-09-25 12:11 ` [patch 4/5] Linux Kernel Markers - Samples Mathieu Desnoyers
2007-09-25 12:11 ` [patch 5/5] Linux Kernel Markers - Documentation Mathieu Desnoyers
4 siblings, 1 reply; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 12:11 UTC (permalink / raw)
To: akpm, linux-kernel; +Cc: Christoph Hellwig, Randy Dunlap, Mathieu Desnoyers
[-- Attachment #1: add-samples-subdir.patch --]
[-- Type: text/plain, Size: 13561 bytes --]
From: Randy Dunlap <randy.dunlap@oracle.com>
Begin infrastructure for kernel code samples in the samples/ directory.
Add its Kconfig and Kbuild files.
Source its Kconfig file in all arch/ Kconfigs.
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
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(-)
Index: linux-2.6-lttng/Makefile
===================================================================
--- linux-2.6-lttng.orig/Makefile 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/Makefile 2007-09-24 18:21:06.000000000 -0400
@@ -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)
Index: linux-2.6-lttng/samples/Kconfig
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/Kconfig 2007-09-24 18:20:40.000000000 -0400
@@ -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/arch/alpha/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/alpha/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/alpha/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -669,5 +669,7 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/arm/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/arm/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/arm/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -1069,4 +1069,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/avr32/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/avr32/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/avr32/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -237,4 +237,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/blackfin/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/blackfin/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/blackfin/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -1012,4 +1012,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/cris/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/cris/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/cris/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -204,4 +204,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/frv/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/frv/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/frv/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -383,4 +383,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/h8300/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/h8300/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/h8300/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -231,4 +231,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/i386/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/i386/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/i386/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -1259,6 +1259,8 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
#
Index: linux-2.6-lttng/arch/ia64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/ia64/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/ia64/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -586,3 +586,5 @@ source "arch/ia64/Kconfig.debug"
source "security/Kconfig"
source "crypto/Kconfig"
+
+source "samples/Kconfig"
Index: linux-2.6-lttng/arch/m32r/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/m32r/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/m32r/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -434,4 +434,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/m68k/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/m68k/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/m68k/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -691,4 +691,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/m68knommu/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/m68knommu/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/m68knommu/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -704,4 +704,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/mips/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/mips/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/mips/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -1969,4 +1969,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/parisc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/parisc/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/parisc/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -275,4 +275,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/powerpc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/powerpc/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/powerpc/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -650,3 +650,5 @@ config KEYS_COMPAT
default y
source "crypto/Kconfig"
+
+source "samples/Kconfig"
Index: linux-2.6-lttng/arch/ppc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/ppc/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/ppc/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -1314,3 +1314,5 @@ source "arch/ppc/Kconfig.debug"
source "security/Kconfig"
source "crypto/Kconfig"
+
+source "samples/Kconfig"
Index: linux-2.6-lttng/arch/s390/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/s390/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/s390/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -537,4 +537,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/sh/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sh/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/sh/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -757,4 +757,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/sh64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sh64/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/sh64/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -293,6 +293,8 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
#
Index: linux-2.6-lttng/arch/sparc/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sparc/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/sparc/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -328,4 +328,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/sparc64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/sparc64/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/sparc64/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -468,4 +468,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/um/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/um/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/um/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -274,6 +274,8 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
source "drivers/scsi/Kconfig"
Index: linux-2.6-lttng/arch/v850/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/v850/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/v850/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -339,6 +339,8 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
#############################################################################
Index: linux-2.6-lttng/arch/x86_64/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/x86_64/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/x86_64/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -841,4 +841,6 @@ source "security/Kconfig"
source "crypto/Kconfig"
+source "samples/Kconfig"
+
source "lib/Kconfig"
Index: linux-2.6-lttng/arch/xtensa/Kconfig
===================================================================
--- linux-2.6-lttng.orig/arch/xtensa/Kconfig 2007-09-24 18:12:11.000000000 -0400
+++ linux-2.6-lttng/arch/xtensa/Kconfig 2007-09-24 18:12:12.000000000 -0400
@@ -259,6 +259,7 @@ source "security/Kconfig"
source "crypto/Kconfig"
-source "lib/Kconfig"
+source "samples/Kconfig"
+source "lib/Kconfig"
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 4/5] Linux Kernel Markers - Samples
2007-09-25 12:11 [patch 0/5] Linux Kernel Markers (redux) Mathieu Desnoyers
` (2 preceding siblings ...)
2007-09-25 12:11 ` [patch 3/5] Add samples subdir Mathieu Desnoyers
@ 2007-09-25 12:11 ` Mathieu Desnoyers
2007-09-25 12:11 ` [patch 5/5] Linux Kernel Markers - Documentation Mathieu Desnoyers
4 siblings, 0 replies; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 12:11 UTC (permalink / raw)
To: akpm, linux-kernel; +Cc: Christoph Hellwig, Randy Dunlap, Mathieu Desnoyers
[-- Attachment #1: linux-kernel-markers-samples.patch --]
[-- Type: text/plain, Size: 5926 bytes --]
Module example showing how to use the Linux Kernel Markers.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
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(+)
Index: linux-2.6-lttng/samples/markers/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/markers/Makefile 2007-09-24 18:41:08.000000000 -0400
@@ -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
Index: linux-2.6-lttng/samples/markers/marker-example.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/markers/marker-example.c 2007-09-24 18:41:08.000000000 -0400
@@ -0,0 +1,55 @@
+/* marker-example.c
+ *
+ * Executes a marker when /proc/marker-example is opened.
+ *
+ * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ * This file is released under the GPLv2.
+ * See the file COPYING for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/marker.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+
+struct proc_dir_entry *pentry_example = NULL;
+
+static int my_open(struct inode *inode, struct file *file)
+{
+ int i;
+
+ trace_mark(subsystem_event, "%d %s", 123, "example string");
+ for (i=0; i<10; i++) {
+ trace_mark(subsystem_eventb, MARK_NOARGS);
+ }
+ return -EPERM;
+}
+
+static struct file_operations mark_ops = {
+ .open = my_open,
+};
+
+static int example_init(void)
+{
+ printk(KERN_ALERT "example init\n");
+ pentry_example = create_proc_entry("marker-example", 0444, NULL);
+ if (pentry_example)
+ pentry_example->proc_fops = &mark_ops;
+ else
+ return -EPERM;
+ return 0;
+}
+
+static void example_exit(void)
+{
+ printk(KERN_ALERT "example exit\n");
+ remove_proc_entry("marker-example", NULL);
+}
+
+module_init(example_init)
+module_exit(example_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Marker example");
Index: linux-2.6-lttng/samples/markers/probe-example.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/markers/probe-example.c 2007-09-24 18:41:08.000000000 -0400
@@ -0,0 +1,98 @@
+/* probe-example.c
+ *
+ * Connects two functions to marker call sites.
+ *
+ * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ * This file is released under the GPLv2.
+ * See the file COPYING for more details.
+ */
+
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/marker.h>
+#include <asm/atomic.h>
+
+struct probe_data {
+ const char *name;
+ const char *format;
+ marker_probe_func *probe_func;
+};
+
+void probe_subsystem_event(const struct __mark_marker *mdata,
+ void *private, const char *format, ...)
+{
+ va_list ap;
+ /* Declare args */
+ unsigned int value;
+ const char *mystr;
+
+ /* Assign args */
+ va_start(ap, format);
+ value = va_arg(ap, typeof(value));
+ mystr = va_arg(ap, typeof(mystr));
+
+ /* Call printk */
+ printk("Value %u, string %s\n", value, mystr);
+
+ /* or count, check rights, serialize data in a buffer */
+
+ va_end(ap);
+}
+
+atomic_t eventb_count = ATOMIC_INIT(0);
+
+void probe_subsystem_eventb(const struct __mark_marker *mdata,
+ void *private, const char *format, ...)
+{
+ /* Increment counter */
+ atomic_inc(&eventb_count);
+}
+
+static struct probe_data probe_array[] =
+{
+ { .name = "subsystem_event",
+ .format = "%d %s",
+ .probe_func = probe_subsystem_event },
+ { .name = "subsystem_eventb",
+ .format = MARK_NOARGS,
+ .probe_func = probe_subsystem_eventb },
+};
+
+static int __init probe_init(void)
+{
+ int result;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(probe_array); i++) {
+ result = marker_probe_register(probe_array[i].name,
+ probe_array[i].format,
+ probe_array[i].probe_func, &probe_array[i]);
+ if (result)
+ printk(KERN_INFO "Unable to register probe %s\n",
+ probe_array[i].name);
+ result = marker_arm(probe_array[i].name);
+ if (result)
+ printk(KERN_INFO "Unable to arm probe %s\n",
+ probe_array[i].name);
+ }
+ return 0;
+}
+
+static void __exit probe_fini(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(probe_array); i++) {
+ marker_probe_unregister(probe_array[i].name);
+ }
+ printk("Number of event b : %u\n", atomic_read(&eventb_count));
+}
+
+module_init(probe_init);
+module_exit(probe_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("SUBSYSTEM Probe");
Index: linux-2.6-lttng/samples/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/Makefile 2007-09-24 18:43:41.000000000 -0400
@@ -0,0 +1,3 @@
+# Makefile for Linux samples code
+
+obj-$(CONFIG_SAMPLES) += markers/
Index: linux-2.6-lttng/samples/Kconfig
===================================================================
--- linux-2.6-lttng.orig/samples/Kconfig 2007-09-24 18:20:40.000000000 -0400
+++ linux-2.6-lttng/samples/Kconfig 2007-09-24 18:41:08.000000000 -0400
@@ -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
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 5/5] Linux Kernel Markers - Documentation
2007-09-25 12:11 [patch 0/5] Linux Kernel Markers (redux) Mathieu Desnoyers
` (3 preceding siblings ...)
2007-09-25 12:11 ` [patch 4/5] Linux Kernel Markers - Samples Mathieu Desnoyers
@ 2007-09-25 12:11 ` Mathieu Desnoyers
4 siblings, 0 replies; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 12:11 UTC (permalink / raw)
To: akpm, linux-kernel
Cc: Christoph Hellwig, Randy Dunlap, Mathieu Desnoyers,
Frank Ch. Eigler
[-- Attachment #1: linux-kernel-markers-documentation.patch --]
[-- Type: text/plain, Size: 4250 bytes --]
Here is some documentation explaining what is/how to use the Linux
Kernel Markers.
Changelog:
- Move the examples to a separate "samples" patch.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Acked-by: "Frank Ch. Eigler" <fche@redhat.com>
CC: Christoph Hellwig <hch@infradead.org>
---
Documentation/markers.txt | 81 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
Index: linux-2.6-lttng/Documentation/markers.txt
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/Documentation/markers.txt 2007-09-24 17:44:56.000000000 -0400
@@ -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
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 3/5] Add samples subdir
2007-09-25 12:11 ` [patch 3/5] Add samples subdir Mathieu Desnoyers
@ 2007-09-25 19:00 ` Sam Ravnborg
2007-09-25 20:32 ` Randy Dunlap
2007-09-25 21:28 ` [patch 3/5] Add samples subdir Oleg Verych
0 siblings, 2 replies; 17+ messages in thread
From: Sam Ravnborg @ 2007-09-25 19:00 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: akpm, linux-kernel, Christoph Hellwig, Randy Dunlap
Hi Mathieu & Randy.
On Tue, Sep 25, 2007 at 08:11:48AM -0400, Mathieu Desnoyers wrote:
> From: Randy Dunlap <randy.dunlap@oracle.com>
>
> 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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 3/5] Add samples subdir
2007-09-25 19:00 ` Sam Ravnborg
@ 2007-09-25 20:32 ` Randy Dunlap
2007-09-25 20:40 ` Mathieu Desnoyers
2007-09-25 20:50 ` [patch 3/5] Add samples subdir (updated) Mathieu Desnoyers
2007-09-25 21:28 ` [patch 3/5] Add samples subdir Oleg Verych
1 sibling, 2 replies; 17+ messages in thread
From: Randy Dunlap @ 2007-09-25 20:32 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: Mathieu Desnoyers, akpm, linux-kernel, Christoph Hellwig
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.
> Hi Mathieu & Randy.
>
> On Tue, Sep 25, 2007 at 08:11:48AM -0400, Mathieu Desnoyers wrote:
> > From: Randy Dunlap <randy.dunlap@oracle.com>
> >
> > 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.
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.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 3/5] Add samples subdir
2007-09-25 20:32 ` Randy Dunlap
@ 2007-09-25 20:40 ` Mathieu Desnoyers
2007-09-25 20:50 ` [patch 3/5] Add samples subdir (updated) Mathieu Desnoyers
1 sibling, 0 replies; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 20:40 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Sam Ravnborg, akpm, linux-kernel, Christoph Hellwig
* Randy Dunlap (randy.dunlap@oracle.com) 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.
>
> > Hi Mathieu & Randy.
> >
> > On Tue, Sep 25, 2007 at 08:11:48AM -0400, Mathieu Desnoyers wrote:
> > > From: Randy Dunlap <randy.dunlap@oracle.com>
> > >
> > > 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.
>
> 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.
> ---
> ~Randy
> Phaedrus says that Quality is about caring.
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 3/5] Add samples subdir (updated)
2007-09-25 20:32 ` Randy Dunlap
2007-09-25 20:40 ` Mathieu Desnoyers
@ 2007-09-25 20:50 ` Mathieu Desnoyers
2007-09-25 20:58 ` Randy Dunlap
2007-09-25 21:21 ` Randy Dunlap
1 sibling, 2 replies; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-25 20:50 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Sam Ravnborg, akpm, linux-kernel, Christoph Hellwig
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 <randy.dunlap@oracle.com>
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
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
Makefile | 3 +++
lib/Kconfig.debug | 2 ++
samples/Kconfig | 11 +++++++++++
3 files changed, 16 insertions(+)
Index: linux-2.6-lttng/Makefile
===================================================================
--- linux-2.6-lttng.orig/Makefile 2007-09-25 16:44:44.000000000 -0400
+++ linux-2.6-lttng/Makefile 2007-09-25 16:45:13.000000000 -0400
@@ -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
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/Kconfig 2007-09-25 16:45:13.000000000 -0400
@@ -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
===================================================================
--- linux-2.6-lttng.orig/lib/Kconfig.debug 2007-09-25 16:44:44.000000000 -0400
+++ linux-2.6-lttng/lib/Kconfig.debug 2007-09-25 16:45:13.000000000 -0400
@@ -558,3 +558,5 @@ config FAULT_INJECTION_STACKTRACE_FILTER
Provide stacktrace filter for fault-injection capabilities
source "lib/Kconfig.kgdb"
+
+source "samples/Kconfig"
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 3/5] Add samples subdir (updated)
2007-09-25 20:50 ` [patch 3/5] Add samples subdir (updated) Mathieu Desnoyers
@ 2007-09-25 20:58 ` Randy Dunlap
2007-09-25 21:21 ` Randy Dunlap
1 sibling, 0 replies; 17+ messages in thread
From: Randy Dunlap @ 2007-09-25 20:58 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: Sam Ravnborg, akpm, linux-kernel, Christoph Hellwig
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.
>
> Add samples subdir (updated)
>
> From: Randy Dunlap <randy.dunlap@oracle.com>
>
> 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
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> ---
> Makefile | 3 +++
> lib/Kconfig.debug | 2 ++
> samples/Kconfig | 11 +++++++++++
> 3 files changed, 16 insertions(+)
>
> Index: linux-2.6-lttng/Makefile
> ===================================================================
> --- linux-2.6-lttng.orig/Makefile 2007-09-25 16:44:44.000000000 -0400
> +++ linux-2.6-lttng/Makefile 2007-09-25 16:45:13.000000000 -0400
> @@ -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
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6-lttng/samples/Kconfig 2007-09-25 16:45:13.000000000 -0400
> @@ -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
> ===================================================================
> --- linux-2.6-lttng.orig/lib/Kconfig.debug 2007-09-25 16:44:44.000000000 -0400
> +++ linux-2.6-lttng/lib/Kconfig.debug 2007-09-25 16:45:13.000000000 -0400
> @@ -558,3 +558,5 @@ config FAULT_INJECTION_STACKTRACE_FILTER
> Provide stacktrace filter for fault-injection capabilities
>
> source "lib/Kconfig.kgdb"
> +
> +source "samples/Kconfig"
>
> --
---
~Randy
Phaedrus says that Quality is about caring.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 3/5] Add samples subdir (updated)
2007-09-25 20:50 ` [patch 3/5] Add samples subdir (updated) Mathieu Desnoyers
2007-09-25 20:58 ` Randy Dunlap
@ 2007-09-25 21:21 ` Randy Dunlap
1 sibling, 0 replies; 17+ messages in thread
From: Randy Dunlap @ 2007-09-25 21:21 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: Sam Ravnborg, akpm, linux-kernel, Christoph Hellwig
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
How about from: you and add
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Thanks.
> Add samples subdir (updated)
>
> From: Randy Dunlap <randy.dunlap@oracle.com>
>
> 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
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> ---
> Makefile | 3 +++
> lib/Kconfig.debug | 2 ++
> samples/Kconfig | 11 +++++++++++
> 3 files changed, 16 insertions(+)
>
> Index: linux-2.6-lttng/Makefile
> ===================================================================
> --- linux-2.6-lttng.orig/Makefile 2007-09-25 16:44:44.000000000 -0400
> +++ linux-2.6-lttng/Makefile 2007-09-25 16:45:13.000000000 -0400
> @@ -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
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6-lttng/samples/Kconfig 2007-09-25 16:45:13.000000000 -0400
> @@ -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
> ===================================================================
> --- linux-2.6-lttng.orig/lib/Kconfig.debug 2007-09-25 16:44:44.000000000 -0400
> +++ linux-2.6-lttng/lib/Kconfig.debug 2007-09-25 16:45:13.000000000 -0400
> @@ -558,3 +558,5 @@ config FAULT_INJECTION_STACKTRACE_FILTER
> Provide stacktrace filter for fault-injection capabilities
>
> source "lib/Kconfig.kgdb"
> +
> +source "samples/Kconfig"
>
--
~Randy
Phaedrus says that Quality is about caring.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 3/5] Add samples subdir
2007-09-25 19:00 ` Sam Ravnborg
2007-09-25 20:32 ` Randy Dunlap
@ 2007-09-25 21:28 ` Oleg Verych
1 sibling, 0 replies; 17+ messages in thread
From: Oleg Verych @ 2007-09-25 21:28 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Mathieu Desnoyers, akpm, linux-kernel, Christoph Hellwig,
Randy Dunlap
* Tue, 25 Sep 2007 21:00:36 +0200
>
> Hi Mathieu & Randy.
>
> On Tue, Sep 25, 2007 at 08:11:48AM -0400, Mathieu Desnoyers wrote:
>> From: Randy Dunlap <randy.dunlap@oracle.com>
>>
>> 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
^ permalink raw reply [flat|nested] 17+ messages in thread
* [patch 4/5] Linux Kernel Markers - Samples
2007-09-28 14:28 [patch 0/5] Linux Kernel Markers for 2.6.23-rc8-mm2 Mathieu Desnoyers
@ 2007-09-28 14:28 ` Mathieu Desnoyers
2007-10-11 9:13 ` Andrew Morton
0 siblings, 1 reply; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-09-28 14:28 UTC (permalink / raw)
To: akpm, linux-kernel; +Cc: Mathieu Desnoyers
[-- Attachment #1: linux-kernel-markers-samples.patch --]
[-- Type: text/plain, Size: 5926 bytes --]
Module example showing how to use the Linux Kernel Markers.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
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(+)
Index: linux-2.6-lttng/samples/markers/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/markers/Makefile 2007-09-24 18:41:08.000000000 -0400
@@ -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
Index: linux-2.6-lttng/samples/markers/marker-example.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/markers/marker-example.c 2007-09-24 18:41:08.000000000 -0400
@@ -0,0 +1,55 @@
+/* marker-example.c
+ *
+ * Executes a marker when /proc/marker-example is opened.
+ *
+ * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ * This file is released under the GPLv2.
+ * See the file COPYING for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/marker.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+
+struct proc_dir_entry *pentry_example = NULL;
+
+static int my_open(struct inode *inode, struct file *file)
+{
+ int i;
+
+ trace_mark(subsystem_event, "%d %s", 123, "example string");
+ for (i=0; i<10; i++) {
+ trace_mark(subsystem_eventb, MARK_NOARGS);
+ }
+ return -EPERM;
+}
+
+static struct file_operations mark_ops = {
+ .open = my_open,
+};
+
+static int example_init(void)
+{
+ printk(KERN_ALERT "example init\n");
+ pentry_example = create_proc_entry("marker-example", 0444, NULL);
+ if (pentry_example)
+ pentry_example->proc_fops = &mark_ops;
+ else
+ return -EPERM;
+ return 0;
+}
+
+static void example_exit(void)
+{
+ printk(KERN_ALERT "example exit\n");
+ remove_proc_entry("marker-example", NULL);
+}
+
+module_init(example_init)
+module_exit(example_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Marker example");
Index: linux-2.6-lttng/samples/markers/probe-example.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/markers/probe-example.c 2007-09-24 18:41:08.000000000 -0400
@@ -0,0 +1,98 @@
+/* probe-example.c
+ *
+ * Connects two functions to marker call sites.
+ *
+ * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ * This file is released under the GPLv2.
+ * See the file COPYING for more details.
+ */
+
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/marker.h>
+#include <asm/atomic.h>
+
+struct probe_data {
+ const char *name;
+ const char *format;
+ marker_probe_func *probe_func;
+};
+
+void probe_subsystem_event(const struct __mark_marker *mdata,
+ void *private, const char *format, ...)
+{
+ va_list ap;
+ /* Declare args */
+ unsigned int value;
+ const char *mystr;
+
+ /* Assign args */
+ va_start(ap, format);
+ value = va_arg(ap, typeof(value));
+ mystr = va_arg(ap, typeof(mystr));
+
+ /* Call printk */
+ printk("Value %u, string %s\n", value, mystr);
+
+ /* or count, check rights, serialize data in a buffer */
+
+ va_end(ap);
+}
+
+atomic_t eventb_count = ATOMIC_INIT(0);
+
+void probe_subsystem_eventb(const struct __mark_marker *mdata,
+ void *private, const char *format, ...)
+{
+ /* Increment counter */
+ atomic_inc(&eventb_count);
+}
+
+static struct probe_data probe_array[] =
+{
+ { .name = "subsystem_event",
+ .format = "%d %s",
+ .probe_func = probe_subsystem_event },
+ { .name = "subsystem_eventb",
+ .format = MARK_NOARGS,
+ .probe_func = probe_subsystem_eventb },
+};
+
+static int __init probe_init(void)
+{
+ int result;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(probe_array); i++) {
+ result = marker_probe_register(probe_array[i].name,
+ probe_array[i].format,
+ probe_array[i].probe_func, &probe_array[i]);
+ if (result)
+ printk(KERN_INFO "Unable to register probe %s\n",
+ probe_array[i].name);
+ result = marker_arm(probe_array[i].name);
+ if (result)
+ printk(KERN_INFO "Unable to arm probe %s\n",
+ probe_array[i].name);
+ }
+ return 0;
+}
+
+static void __exit probe_fini(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(probe_array); i++) {
+ marker_probe_unregister(probe_array[i].name);
+ }
+ printk("Number of event b : %u\n", atomic_read(&eventb_count));
+}
+
+module_init(probe_init);
+module_exit(probe_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("SUBSYSTEM Probe");
Index: linux-2.6-lttng/samples/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/samples/Makefile 2007-09-24 18:43:41.000000000 -0400
@@ -0,0 +1,3 @@
+# Makefile for Linux samples code
+
+obj-$(CONFIG_SAMPLES) += markers/
Index: linux-2.6-lttng/samples/Kconfig
===================================================================
--- linux-2.6-lttng.orig/samples/Kconfig 2007-09-24 18:20:40.000000000 -0400
+++ linux-2.6-lttng/samples/Kconfig 2007-09-24 18:41:08.000000000 -0400
@@ -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
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 4/5] Linux Kernel Markers - Samples
2007-09-28 14:28 ` [patch 4/5] Linux Kernel Markers - Samples Mathieu Desnoyers
@ 2007-10-11 9:13 ` Andrew Morton
2007-10-11 13:27 ` Mathieu Desnoyers
0 siblings, 1 reply; 17+ messages in thread
From: Andrew Morton @ 2007-10-11 9:13 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: linux-kernel
On Fri, 28 Sep 2007 10:28:49 -0400 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> wrote:
> Module example showing how to use the Linux Kernel Markers.
s390:
samples/markers/marker-example.c: In function 'my_open':
samples/markers/marker-example.c:22: warning: asm operand 0 probably doesn't match constraints
samples/markers/marker-example.c:24: warning: asm operand 0 probably doesn't match constraints
samples/markers/marker-example.c:22: error: impossible constraint in 'asm'
samples/markers/marker-example.c:24: error: impossible constraint in 'asm'
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 4/5] Linux Kernel Markers - Samples
2007-10-11 9:13 ` Andrew Morton
@ 2007-10-11 13:27 ` Mathieu Desnoyers
2007-10-11 18:32 ` Andrew Morton
0 siblings, 1 reply; 17+ messages in thread
From: Mathieu Desnoyers @ 2007-10-11 13:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
* Andrew Morton (akpm@linux-foundation.org) wrote:
> On Fri, 28 Sep 2007 10:28:49 -0400 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> wrote:
>
> > Module example showing how to use the Linux Kernel Markers.
>
> s390:
>
> samples/markers/marker-example.c: In function 'my_open':
> samples/markers/marker-example.c:22: warning: asm operand 0 probably doesn't match constraints
> samples/markers/marker-example.c:24: warning: asm operand 0 probably doesn't match constraints
> samples/markers/marker-example.c:22: error: impossible constraint in 'asm'
> samples/markers/marker-example.c:24: error: impossible constraint in 'asm'
Hrm, I have s390 gcc-4.1.1 here and cannot reproduce the problem with it.
What compiler are you using ?
This is clearly caused by the :
asm volatile ("" : : "i" (&__mark_##name));
It is there to specify that the __mark_##name variable is used. In the
first implementations, I did not pass it as a parameter to the following
function call, so I had to find a way to tell gcc that it should not go
away. I first planned to use a "__used" attribute, but Jeremy said it
was buggy on some gcc versions. (http://lkml.org/lkml/2006/10/17/235)
He suggested the following:
asm volatile("" : : "m" (thing));
But I guess it ended up not working so well, since I changed it for a
"i" operand. However, if some s390 gccs do not like it, it's better to
figure out another solution.
Well, as a very very simple solution, let's just remove the asm. It is
not needed anymore since the pointer is passed as parameter to the
called function.
The patch follows.
Mathieu
Linux Kernel Markers - Remove Unneeded asm
On s390 (with some compiler) :
> samples/markers/marker-example.c: In function 'my_open':
> samples/markers/marker-example.c:22: warning: asm operand 0 probably doesn't
> match constraints
> samples/markers/marker-example.c:24: warning: asm operand 0 probably doesn't
> match constraints
> samples/markers/marker-example.c:22: error: impossible constraint in 'asm'
> samples/markers/marker-example.c:24: error: impossible constraint in 'asm'
It is there to specify that the __mark_##name variable is used. In the
first implementations, I did not pass it as a parameter to the following
function call, so I had to find a way to tell gcc that it should not go
away. I first planned to use a "__used" attribute, but Jeremy said it
was buggy on some gcc versions. (http://lkml.org/lkml/2006/10/17/235)
He suggested the following:
asm volatile("" : : "m" (thing));
But I guess it ended up not working so well, since I changed it for a
"i" operand. However, if some s390 gccs do not like it, it's better to
figure out another solution.
Well, as a very very simple solution, let's just remove the asm. It is
not needed anymore since the pointer is passed as parameter to the
called function.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
include/linux/marker.h | 1 -
1 file changed, 1 deletion(-)
Index: linux-2.6-lttng/include/linux/marker.h
===================================================================
--- linux-2.6-lttng.orig/include/linux/marker.h 2007-10-11 09:20:04.000000000 -0400
+++ linux-2.6-lttng/include/linux/marker.h 2007-10-11 09:20:23.000000000 -0400
@@ -61,7 +61,6 @@ struct marker {
__attribute__((section("__markers"), aligned(8))) = \
{ __mstrtab_name_##name, __mstrtab_format_##name, \
0, __mark_empty_function, NULL }; \
- asm volatile ("" : : "i" (&__mark_##name)); \
__mark_check_format(format, ## args); \
if (unlikely(__mark_##name.state)) { \
preempt_disable(); \
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch 4/5] Linux Kernel Markers - Samples
2007-10-11 13:27 ` Mathieu Desnoyers
@ 2007-10-11 18:32 ` Andrew Morton
0 siblings, 0 replies; 17+ messages in thread
From: Andrew Morton @ 2007-10-11 18:32 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: linux-kernel
On Thu, 11 Oct 2007 09:27:12 -0400 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> wrote:
> > samples/markers/marker-example.c: In function 'my_open':
> > samples/markers/marker-example.c:22: warning: asm operand 0 probably doesn't match constraints
> > samples/markers/marker-example.c:24: warning: asm operand 0 probably doesn't match constraints
> > samples/markers/marker-example.c:22: error: impossible constraint in 'asm'
> > samples/markers/marker-example.c:24: error: impossible constraint in 'asm'
>
> Hrm, I have s390 gcc-4.1.1 here and cannot reproduce the problem with it.
>
> What compiler are you using ?
4.1.0, from http://userweb.kernel.org/~akpm/cross-compilers/s390-cross.tar.gz
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2007-10-11 18:33 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-25 12:11 [patch 0/5] Linux Kernel Markers (redux) Mathieu Desnoyers
2007-09-25 12:11 ` [patch 1/5] Combine instrumentation menus in kernel/Kconfig.instrumentation Mathieu Desnoyers
2007-09-25 12:11 ` [patch 2/5] Linux Kernel Markers Mathieu Desnoyers
2007-09-25 12:11 ` [patch 3/5] Add samples subdir Mathieu Desnoyers
2007-09-25 19:00 ` Sam Ravnborg
2007-09-25 20:32 ` Randy Dunlap
2007-09-25 20:40 ` Mathieu Desnoyers
2007-09-25 20:50 ` [patch 3/5] Add samples subdir (updated) Mathieu Desnoyers
2007-09-25 20:58 ` Randy Dunlap
2007-09-25 21:21 ` Randy Dunlap
2007-09-25 21:28 ` [patch 3/5] Add samples subdir Oleg Verych
2007-09-25 12:11 ` [patch 4/5] Linux Kernel Markers - Samples Mathieu Desnoyers
2007-09-25 12:11 ` [patch 5/5] Linux Kernel Markers - Documentation Mathieu Desnoyers
-- strict thread matches above, loose matches on Subject: below --
2007-09-28 14:28 [patch 0/5] Linux Kernel Markers for 2.6.23-rc8-mm2 Mathieu Desnoyers
2007-09-28 14:28 ` [patch 4/5] Linux Kernel Markers - Samples Mathieu Desnoyers
2007-10-11 9:13 ` Andrew Morton
2007-10-11 13:27 ` Mathieu Desnoyers
2007-10-11 18:32 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox