more updates for TRACE_EVENTS for modules
Subsystems (10)
Steven Rostedt
maintainerPATCH 1/4 tracing/events: fix compile for modules disabled
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: compile fix
The addition of TRACE_EVENT for modules breaks the build for when modules are disabled. This code fixes that.
--- kernel/trace/trace_events.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
kernel/trace/trace_events.c +10 -2
@@ -797,6 +797,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events) (unsigned long )event < (unsigned long )end; \ event++) +#ifdef CONFIG_MODULES static void trace_module_add_events (struct module *mod) {struct ftrace_event_call *call, *start, *end;
@@ -840,8 +841,8 @@ static void trace_module_remove_events(struct module *mod) } } -int trace_module_notify (struct notifier_block *self, -unsigned long val,void *data) +static int trace_module_notify (struct notifier_block *self, +unsigned long val,void *data) {struct module *mod = data;
@@ -858,6 +859,13 @@ int trace_module_notify(struct notifier_block *self,return 0 ; } +#else +static int trace_module_notify (struct notifier_block *self, +unsigned long val,void *data) +{ +return 0 ; +} +#endif /* CONFIG_MODULES */ struct notifier_block trace_module_nb = { .notifier_call = trace_module_notify,
Signature · 3 lines
1.6.2.1 --
Steven Rostedt
maintainerIngo,
Please pull the latest tip/tracing/core tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/core
Steven Rostedt (4):
tracing/events: fix compile for modules disabled tracing/events: fix lockdep system name tracing/events: move trace point headers into include/trace/events tracing/events: add trace-events-sample
----
include/linux/kmemtrace.h | 2 +- include/trace/define_trace.h | 2 +- include/trace/events/irq.h | 57 +++++ include/trace/events/kmem.h | 194 ++++++++++++++++ include/trace/events/lockdep.h | 60 +++++ include/trace/events/sched.h | 339 ++++++++++++++++++++++++++++ include/trace/events/skb.h | 40 ++++ include/trace/irq.h | 57 ----- include/trace/kmem.h | 194 ---------------- include/trace/lockdep.h | 60 ----- include/trace/sched.h | 339 ---------------------------- include/trace/skb.h | 40 ---- kernel/exit.c | 2 +- kernel/fork.c | 3 +- kernel/irq/handle.c | 2 +- kernel/kthread.c | 2 +- kernel/lockdep.c | 2 +- kernel/sched.c | 2 +- kernel/signal.c | 2 +- kernel/softirq.c | 2 +- kernel/trace/ftrace.c | 2 +- kernel/trace/trace_events.c | 12 +- kernel/trace/trace_sched_switch.c | 2 +- kernel/trace/trace_sched_wakeup.c | 2 +- mm/util.c | 2 +- net/core/drop_monitor.c | 2 +- net/core/net-traces.c | 2 +- net/core/skbuff.c | 2 +- samples/Kconfig | 7 + samples/Makefile | 2 +- samples/trace_events/Makefile | 8 + samples/trace_events/trace-events-sample.c | 56 +++++ samples/trace_events/trace-events-sample.h | 124 ++++++++++ 33 files changed, 914 insertions(+), 710 deletions(-)
Steven Rostedt
maintainerPATCH 2/4 tracing/events: fix lockdep system name
From: Steven Rostedt <[email protected]>
Impact: fix compile error of lockdep event tracer
Ingo Molnar pointed out that the system name for the lockdep tracer was "lock" which is used to include the event trace file name. It should be "lockdep"
--- include/trace/lockdep.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/trace/lockdep.h +1 -1
@@ -5,7 +5,7 @@#include <linux/tracepoint.h> #undef TRACE_SYSTEM -#define TRACE_SYSTEM lock +#define TRACE_SYSTEM lockdep#ifdef CONFIG_LOCKDEP
Signature · 3 lines
1.6.2.1 --
Steven Rostedt
maintainerPATCH 3/4 tracing/events: move trace point headers into include/trace/events
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: clean up
Create a sub directory in include/trace called events to keep the trace point headers in their own separate directory. Only headers that declare trace points should be defined in this directory.
--- include/linux/kmemtrace.h | 2 +- include/trace/define_trace.h | 2 +- include/trace/events/irq.h | 57 ++++++ include/trace/events/kmem.h | 194 +++++++++++++++++++++ include/trace/events/lockdep.h | 60 +++++++ include/trace/events/sched.h | 339 +++++++++++++++++++++++++++++++++++++ include/trace/events/skb.h | 40 +++++ include/trace/irq.h | 57 ------ include/trace/kmem.h | 194 --------------------- include/trace/lockdep.h | 60 ------- include/trace/sched.h | 339 ------------------------------------- include/trace/skb.h | 40 ----- kernel/exit.c | 2 +- kernel/fork.c | 3 +- kernel/irq/handle.c | 2 +- kernel/kthread.c | 2 +- kernel/lockdep.c | 2 +- kernel/sched.c | 2 +- kernel/signal.c | 2 +- kernel/softirq.c | 2 +- kernel/trace/ftrace.c | 2 +- kernel/trace/trace_sched_switch.c | 2 +- kernel/trace/trace_sched_wakeup.c | 2 +- mm/util.c | 2 +- net/core/drop_monitor.c | 2 +- net/core/net-traces.c | 2 +- net/core/skbuff.c | 2 +- 27 files changed, 708 insertions(+), 707 deletions(-) create mode 100644 include/trace/events/irq.h create mode 100644 include/trace/events/kmem.h create mode 100644 include/trace/events/lockdep.h create mode 100644 include/trace/events/sched.h create mode 100644 include/trace/events/skb.h delete mode 100644 include/trace/irq.h delete mode 100644 include/trace/kmem.h delete mode 100644 include/trace/lockdep.h delete mode 100644 include/trace/sched.h delete mode 100644 include/trace/skb.h
include/linux/kmemtrace.h +1 -1
@@ -9,7 +9,7 @@#ifdef __KERNEL__ -#include <trace/kmem.h> +#include <trace/events/kmem.h> #ifdef CONFIG_KMEMTRACE extern void kmemtrace_init (void );
include/trace/define_trace.h +1 -1
@@ -43,7 +43,7 @@#endif #ifndef TRACE_INCLUDE_PATH -# define __TRACE_INCLUDE (system) <trace/system.h> +# define __TRACE_INCLUDE (system) <trace/events/system.h># define UNDEF_TRACE_INCLUDE_FILE #else # define __TRACE_INCLUDE (system) __stringify(TRACE_INCLUDE_PATH/system.h)
include/trace/events/irq.h new file +57 -0
57 lines not on this page · raw message
include/trace/events/kmem.h new file +194 -0
194 lines not on this page · raw message
include/trace/events/lockdep.h new file +60 -0
60 lines not on this page · raw message
include/trace/events/sched.h new file +339 -0
339 lines not on this page · raw message
include/trace/events/skb.h new file +40 -0
@@ -0,0 +1,40 @@ +#if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_SKB_H + +#include <linux/skbuff.h> +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM skb + +/* +* Tracepoint for free an sk_buff: +*/ +TRACE_EVENT (kfree_skb, + + TP_PROTO(struct sk_buff *skb, void *location), + +TP_ARGS (skb, location), + +TP_STRUCT__entry ( + __field( void *, skbaddr ) + __field( unsigned short, protocol ) + __field( void *, location ) + ), + +TP_fast_assign ( + __entry->skbaddr = skb; + if (skb) { + __entry->protocol = ntohs(skb->protocol); + } + __entry->location = location; + ), + +TP_printk ("skbaddr=%p protocol=%u location=%p" , + __entry->skbaddr, __entry->protocol, __entry->location) +); + +#endif /* _TRACE_SKB_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>
include/trace/irq.h deleted +0 -57
57 lines not on this page · raw message
include/trace/kmem.h deleted +0 -194
194 lines not on this page · raw message
include/trace/lockdep.h deleted +0 -60
60 lines not on this page · raw message
include/trace/sched.h deleted +0 -339
339 lines not on this page · raw message
include/trace/skb.h deleted +0 -40
@@ -1,40 +0,0 @@ -#if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _TRACE_SKB_H - -#include <linux/skbuff.h> -#include <linux/tracepoint.h> - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM skb - -/* -* Tracepoint for free an sk_buff: -*/ -TRACE_EVENT (kfree_skb, - - TP_PROTO(struct sk_buff *skb, void *location), - -TP_ARGS (skb, location), - -TP_STRUCT__entry ( - __field( void *, skbaddr ) - __field( unsigned short, protocol ) - __field( void *, location ) - ), - -TP_fast_assign ( - __entry->skbaddr = skb; - if (skb) { - __entry->protocol = ntohs(skb->protocol); - } - __entry->location = location; - ), - -TP_printk ("skbaddr=%p protocol=%u location=%p" , - __entry->skbaddr, __entry->protocol, __entry->location) -); - -#endif /* _TRACE_SKB_H */ - -/* This part must be outside protection */ -#include <trace/define_trace.h>
kernel/exit.c +1 -1
@@ -48,7 +48,7 @@#include <linux/tracehook.h> #include <linux/fs_struct.h> #include <linux/init_task.h> -#include <trace/sched.h> +#include <trace/events/sched.h> #include <asm/uaccess.h> #include <asm/unistd.h>
kernel/fork.c +2 -1
@@ -61,7 +61,6 @@#include <linux/proc_fs.h> #include <linux/blkdev.h> #include <linux/fs_struct.h> -#include <trace/sched.h> #include <linux/magic.h> #include <asm/pgtable.h>
@@ -71,6 +70,8 @@#include <asm/cacheflush.h> #include <asm/tlbflush.h> +#include <trace/events/sched.h> +/* * Protected counters by write_lock_irq(&tasklist_lock) */
kernel/irq/handle.c +1 -1
@@ -20,7 +20,7 @@#include <linux/bootmem.h> #define CREATE_TRACE_POINTS -#include <trace/irq.h> +#include <trace/events/irq.h> #include "internals.h"
kernel/kthread.c +1 -1
@@ -13,7 +13,7 @@#include <linux/file.h> #include <linux/module.h> #include <linux/mutex.h> -#include <trace/sched.h> +#include <trace/events/sched.h> #define KTHREAD_NICE_LEVEL (-5)
kernel/lockdep.c +1 -1
@@ -48,7 +48,7 @@#include "lockdep_internals.h" #define CREATE_TRACE_POINTS -#include <trace/lockdep.h> +#include <trace/events/lockdep.h> #ifdef CONFIG_PROVE_LOCKING int prove_locking =1 ;
kernel/sched.c +1 -1
@@ -79,7 +79,7 @@#include "sched_cpupri.h" #define CREATE_TRACE_POINTS -#include <trace/sched.h> +#include <trace/events/sched.h> /* * Convert user-nice values [ -20 ... 0 ... 19 ]
kernel/signal.c +1 -1
@@ -27,7 +27,7 @@#include <linux/freezer.h> #include <linux/pid_namespace.h> #include <linux/nsproxy.h> -#include <trace/sched.h> +#include <trace/events/sched.h> #include <asm/param.h> #include <asm/uaccess.h>
kernel/softirq.c +1 -1
@@ -24,7 +24,7 @@#include <linux/ftrace.h> #include <linux/smp.h> #include <linux/tick.h> -#include <trace/irq.h> +#include <trace/events/irq.h> #include <asm/irq.h> /*
kernel/trace/ftrace.c +1 -1
@@ -29,7 +29,7 @@#include <linux/list.h> #include <linux/hash.h> -#include <trace/sched.h> +#include <trace/events/sched.h> #include <asm/ftrace.h>
kernel/trace/trace_sched_switch.c +1 -1
@@ -10,7 +10,7 @@#include <linux/kallsyms.h> #include <linux/uaccess.h> #include <linux/ftrace.h> -#include <trace/sched.h> +#include <trace/events/sched.h> #include "trace.h"
kernel/trace/trace_sched_wakeup.c +1 -1
@@ -15,7 +15,7 @@#include <linux/kallsyms.h> #include <linux/uaccess.h> #include <linux/ftrace.h> -#include <trace/sched.h> +#include <trace/events/sched.h> #include "trace.h"
mm/util.c +1 -1
@@ -7,7 +7,7 @@#include <asm/uaccess.h> #define CREATE_TRACE_POINTS -#include <trace/kmem.h> +#include <trace/events/kmem.h> /** * kstrdup - allocate space for and copy an existing string
net/core/drop_monitor.c +1 -1
@@ -23,7 +23,7 @@#include <linux/bitops.h> #include <net/genetlink.h> -#include <trace/skb.h> +#include <trace/events/skb.h> #include <asm/unaligned.h>
net/core/net-traces.c +1 -1
@@ -24,6 +24,6 @@#include <asm/bitops.h> #define CREATE_TRACE_POINTS -#include <trace/skb.h> +#include <trace/events/skb.h> EXPORT_TRACEPOINT_SYMBOL_GPL (kfree_skb);
net/core/skbuff.c +1 -1
@@ -65,7 +65,7 @@#include <asm/uaccess.h> #include <asm/system.h> -#include <trace/skb.h> +#include <trace/events/skb.h> #include "kmap_skb.h"
Signature · 3 lines
1.6.2.1 --
Steven Rostedt
maintainerPATCH 4/4 tracing/events: add trace-events-sample
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
This patch adds a sample to the samples directory on how to create and use TRACE_EVENT trace points.
--- samples/Kconfig | 7 ++ samples/Makefile | 2 +- samples/trace_events/Makefile | 8 ++ samples/trace_events/trace-events-sample.c | 56 +++++++++++++ samples/trace_events/trace-events-sample.h | 124 ++++++++++++++++++++++++++++ 5 files changed, 196 insertions(+), 1 deletions(-) create mode 100644 samples/trace_events/Makefile create mode 100644 samples/trace_events/trace-events-sample.c create mode 100644 samples/trace_events/trace-events-sample.h
samples/Kconfig +7 -0
@@ -19,6 +19,13 @@ config SAMPLE_TRACEPOINTS help This build tracepoints example modules. +config SAMPLE_TRACE_EVENTS + tristate "Build trace_events examples" + depends on EVENT_TRACING + default m + help + This build trace event example modules. + config SAMPLE_KOBJECT tristate "Build kobject examples" help
samples/Makefile +1 -1
@@ -1,3 +1,3 @@ # Makefile for Linux samples code -obj-$(CONFIG_SAMPLES) += markers/ kobject/ kprobes/ tracepoints/ +obj-$(CONFIG_SAMPLES) += markers/ kobject/ kprobes/ tracepoints/ trace_events/
samples/trace_events/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# builds the trace events example kernel modules; +# then to use one (as root): insmod <module_name.ko> + +PWD := $(shell pwd) + +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/ + +obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace-events-sample.o
samples/trace_events/trace-events-sample.c new file +56 -0
56 lines not on this page · raw message
samples/trace_events/trace-events-sample.h new file +124 -0
124 lines not on this page · raw message
Signature · 3 lines
1.6.2.1 --
Re: [PATCH 2/4] tracing/events: fix lockdep system name
In reply to Steven RostedtQuoted 7 lines · Steven Rostedt
From: Steven Rostedt <[email protected]>
Impact: fix compile error of lockdep event tracer
Ingo Molnar pointed out that the system name for the lockdep tracer was "lock" which is used to include the event trace file name. It should be "lockdep"
btw, i think it would be better to name it 'lock', all around - i.e. lock.h, lock subsystem, etc.
lockdep is the 'lock dependency tracking engine'.
The locking related tracepoints here are implemented via lockdep right now, but that might be done differently in the future - and we dont want to do a rename (or live with a misnomer) then.
Ingo
Quoted 8 lines · Steven Rostedt
Ingo,
Please pull the latest tip/tracing/core tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/core
Quoted 5 lines
Steven Rostedt (4):
tracing/events: fix compile for modules disabled tracing/events: fix lockdep system name tracing/events: move trace point headers intoinclude/trace/eventstracing/events: add trace-events-sample
Pulled, thanks - i'm doing some more tests on it now.
The include/trace/ structure now looks extremely tidy, kudos!
Ingo
Peter Zijlstra
maintainerRe: [PATCH 2/4] tracing/events: fix lockdep system name
In reply to Steven RostedtQuoted 8 lines · Steven Rostedt
plain text document attachment (0002-tracing-events-fix-lockdep-system-name.patch)
From: Steven Rostedt <[email protected]>Impact: fix compile error of lockdep event tracer
Ingo Molnar pointed out that the system name for the lockdep tracer was "lock" which is used to include the event trace file name. It should be "lockdep"
Ah, I did that on purpose. Whilst it all stems from the lockdep code, these tracepoints have nothing much to do with dependency tracking, hence I decided to drop that bit of the name.
Quoted 17 lines · Ingo Molnar
Quoted 8 lines · Steven Rostedt
Ingo,
Please pull the latest tip/tracing/core tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/coreQuoted 5 lines
Steven Rostedt (4):
tracing/events: fix compile for modules disabled tracing/events: fix lockdep system name tracing/events: move trace point headers intoinclude/trace/eventstracing/events: add trace-events-sample
Quoted 3 lines
Pulled, thanks - i'm doing some more tests on it now.
The
include/trace/structure now looks extremely tidy, kudos!
Ok, preliminary tests passed, so i pushed it out into -tip:master as well.
Btw., i have yet to trigger the lock tracing related lockup you saw
- shouldnt the self-tests have triggered any such lockup?
Ingo
Re: [PATCH 1/4] tracing/events: fix compile for modules disabled
In reply to Steven RostedtQuoted 37 lines · Steven Rostedt
From: Steven Rostedt <[email protected]>
Impact: compile fix
The addition of
TRACE_EVENTfor modules breaks the build for when modules are disabled. This code fixes that.Reported-by Ingo Molnar <[email protected]>Signed-off-by Steven Rostedt <[email protected]>--- kernel/trace/trace_events.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)kernel/trace/trace_events.c +3
-2@@ -797,6 +797,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events) (unsigned long )event < (unsigned long )end; \ event++) +#ifdef CONFIG_MODULES static void trace_module_add_events (struct module *mod) {struct ftrace_event_call *call, *start, *end;@@ -840,8 +841,8 @@ static void trace_module_remove_events(struct module *mod) } } -int trace_module_notify (struct notifier_block *self, -unsigned long val,void *data) +static int trace_module_notify (struct notifier_block *self, +unsigned long val,void *data) {struct module *mod = data;
kernel/trace/trace_events.c int trace_module_notify(struct notifier_block *self, · line 864
Quoted 6 lines
kernel/trace/trace_events.c +3
-0@@ -858,6 +859,13 @@ int trace_module_notify(struct notifier_block *self, return 0; } +#else +static int trace_module_notify (struct notifier_block *self, +unsigned long val,void *data)
I don't remember when you register the module notifier but I guess it is on init time, then you can set this func as __init if !CONFIG_MODULES.
kernel/trace/trace_events.c int trace_module_notify(struct notifier_block *self, · line 871
Quoted 7 lines
kernel/trace/trace_events.c +4
-0+{ +return 0 ; +} +#endif /* CONFIG_MODULES */ struct notifier_block trace_module_nb = { .notifier_call = trace_module_notify,
And then you can set this struct as __initdata_or_module, so that you can safely register this module notifier whatever config you have, and without consuming any space on the off case.
Quoted 4 lines
Signature · 3 lines
1.6.2.1 --
Re: [PATCH 4/4] tracing/events: add trace-events-sample
In reply to Steven RostedtQuoted 75 lines · Steven Rostedt
From: Steven Rostedt <[email protected]>
This patch adds a sample to the samples directory on how to create and use
TRACE_EVENTtrace points.Signed-off-by Steven Rostedt <[email protected]>--- samples/Kconfig | 7 ++ samples/Makefile | 2 +- samples/trace_events/Makefile | 8 ++ samples/trace_events/trace-events-sample.c | 56 +++++++++++++ samples/trace_events/trace-events-sample.h | 124 ++++++++++++++++++++++++++++ 5 files changed, 196 insertions(+), 1 deletions(-) create mode 100644 samples/trace_events/Makefile create mode 100644 samples/trace_events/trace-events-sample.c create mode 100644 samples/trace_events/trace-events-sample.hsamples/Kconfig +7
-0@@ -19,6 +19,13 @@ config SAMPLE_TRACEPOINTS help This build tracepoints example modules. +config SAMPLE_TRACE_EVENTS + tristate "Build trace_events examples" + depends on EVENT_TRACING + default m + help + This build trace event example modules. + config SAMPLE_KOBJECT tristate "Build kobject examples" helpsamples/Makefile +1
-1@@ -1,3 +1,3 @@ # Makefile for Linux samples code -obj-$(CONFIG_SAMPLES) += markers/ kobject/ kprobes/ tracepoints/ +obj-$(CONFIG_SAMPLES) += markers/ kobject/ kprobes/ tracepoints/ trace_events/samples/trace_events/Makefile new file +8
-0@@ -0,0 +1,8 @@ +# builds the trace events example kernel modules; +# then to use one (as root): insmod <module_name.ko> + +PWD := $(shell pwd) + +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/ + +obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace-events-sample.osamples/trace_events/trace-events-sample.c new file +11
-0@@ -0,0 +1,56 @@ +#include <linux/module.h> +#include <linux/kthread.h> + +/* +* Any file that uses trace points, must include the header. +* But only one file, must include the header by defining +* CREATE_TRACE_POINTS first. This will make the C code that +* creates the handles for the trace points. +*/ +#define CREATE_TRACE_POINTS +#include "trace-events-sample.h"
samples/trace_events/trace-events-sample.c line 21
Quoted 10 lines
samples/trace_events/trace-events-sample.c new file +10
-0+ + +static void simple_thread_func (int cnt) +{ +set_current_state (TASK_INTERRUPTIBLE ); +schedule_timeout (HZ ); +trace_foo_bar ("hello" , cnt); + +if (!(cnt %10 )) +/* It is really important that I say "hi!" */
Nice design choice! Indeed this is very important! ;-)
Frederic.
Quoted 169 lines
samples/trace_events/trace-events-sample.c new file +35
-0+printk (KERN_EMERG "hi!\n" ); +} + +static int simple_thread (void *arg) +{ +int cnt =0 ; + +while (!kthread_should_stop ()) +simple_thread_func (cnt++); + +return 0 ; +} + +static struct task_struct *simple_tsk; + +static int __init trace_event_init (void ) +{ + simple_tsk =kthread_run (simple_thread,NULL ,"event-sample" ); +if (IS_ERR (simple_tsk)) +return -1 ; + +return 0 ; +} + +static void __exit trace_event_exit(void) +{ +kthread_stop (simple_tsk); +} + +module_init (trace_event_init); +module_exit (trace_event_exit); + +MODULE_AUTHOR ("Steven Rostedt" ); +MODULE_DESCRIPTION ("trace-events-sample" ); +MODULE_LICENSE ("GPL" );samples/trace_events/trace-events-sample.h new file +124
-0@@ -0,0 +1,124 @@ +/* +* Notice that this file is not protected like a normal header. +* We also must allow for rereading of this file. The +* +* || defined(TRACE_HEADER_MULTI_READ) +* +* serves this purpose. +*/ +#if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_EVENT_SAMPLE_H + +/* +* All trace headers should include tracepoint.h, until we finally +* make it into a standard header. +*/ +#include <linux/tracepoint.h> + +/* +* If TRACE_SYSTEM is defined, that will be the directory created +* in the ftrace directory under /debugfs/tracing/events/<system> +* +* The define_trace.h belowe will also look for a file name of +* TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. +* +* If you want a different system than file name, you can override +* the header name by defining TRACE_INCLUDE_FILE +* +* If this file was called, goofy.h, then we would define: +* +* #define TRACE_INCLUDE_FILE goofy +* +*/ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM trace-events-sample + +/* +* The TRACE_EVENT macro is broken up into 5 parts. +* +* name: name of the trace point. This is also how to enable the tracepoint. +* A function called trace_foo_bar() will be created. +* +* proto: the prototype of the function trace_foo_bar() +* Here it is trace_foo_bar(char *foo, int bar). +* +* args: must match the arguments in the prototype. +* Here it is simply "foo, bar". +* +* struct: This defines the way the data will be stored in the ring buffer. +* There are currently two types of elements. __field and __array. +* a __field is broken up into (type, name). Where type can be any +* type but an array. +* For an array. there are three fields. (type, name, size). The +* type of elements in the array, the name of the field and the size +* of the array. +* +* __array( char, foo, 10) is the same as saying char foo[10]. +* +* fast_assign: This is a C like function that is used to store the items +* into the ring buffer. +* +* printk: This is a way to print out the data in pretty print. This is +* useful if the system crashes and you are logging via a serial line, +* the data can be printed to the console using this "printk" method. +* +* Note, that for both the assign and the printk, __entry is the handler +* to the data structure in the ring buffer, and is defined by the +* TP_STRUCT__entry. +*/ +TRACE_EVENT (foo_bar, + + TP_PROTO(char *foo, int bar), + +TP_ARGS (foo, bar), + +TP_STRUCT__entry ( + __array( char, foo, 10 ) +__field ( int, bar ) + ), + +TP_fast_assign ( + strncpy(__entry->foo, foo, 10); + __entry->bar = bar; + ), + +TP_printk ("foo %s %d" , __entry->foo, __entry->bar) +); +#endif + +/***** NOTICE! The #if protection ends here. *****/ + + +/* +* There are several ways I could have done this. If I left out the +* TRACE_INCLUDE_PATH, then it would default to the kernel source +* include/trace/events directory. +* +* I could specify a path from the define_trace.h file back to this +* file. +* +* #define TRACE_INCLUDE_PATH ../../samples/trace_events +* +* But I chose to simply make it use the current directory and then in +* the Makefile I added: +* +* CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/ +* +* This will make sure the current path is part of the include +* structure for our file so that we can find it. +* +* I could have made only the top level directory the include: +* +* CFLAGS_trace-events-sample.o := -I$(PWD) +* +* And then let the path to this directory be the TRACE_INCLUDE_PATH: +* +* #define TRACE_INCLUDE_PATH samples/trace_events +* +* But then if something defines "samples" or "trace_events" then we +* could risk that being converted too, and give us an unexpected +* result. +*/ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#include <trace/define_trace.h> Signature · 3 lines
1.6.2.1 --
Steven Rostedt
maintainerRe: [PATCH 1/4] tracing/events: fix compile for modules disabled
In reply to Frederic WeisbeckerQuoted 16 lines · Frederic Weisbecker
kernel/trace/trace_events.c int trace_module_notify(struct notifier_block *self, · line 864
Quoted 3 lines
kernel/trace/trace_events.c +3
-0+#else +static int trace_module_notify (struct notifier_block *self, +unsigned long val,void *data)I don't remember when you register the module notifier but I guess it is on init time, then you can set this func as
__initif !CONFIG_MODULES.Quoted 5 lines
kernel/trace/trace_events.c +4
-0+{ +return 0 ; +} +#endif /* CONFIG_MODULES */
Quoted 7 lines
Quoted 2 lines
struct
notifier_blocktrace_module_nb= {
.notifier_call =trace_module_notify,And then you can set this struct as
__initdata_or_module, so that you can safely register this module notifier whatever config you have, and without consuming any space on the off case.
Good point. I'll update that.
-- Steve
Re: [PATCH 4/4] tracing/events: add trace-events-sample
In reply to Steven Rostedtsamples/trace_events/Makefile line 6
Quoted 8 lines · Steven Rostedt
+++ b/samples/trace_events/Makefile
samples/trace_events/Makefile new file +6
-0@@ -0,0 +1,8 @@ +# builds the trace events example kernel modules; +# then to use one (as root): insmod <module_name.ko> + +PWD := $(shell pwd) + +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/
CFLAGS_trace-events-sample.o += -I$(src)
That should better be written as. But you'd easily get rid of that by just including the file using #include "foo.h" instead of <foo.h>, no?
samples/trace_events/trace-events-sample.h line 10
Quoted 13 lines
samples/trace_events/trace-events-sample.h new file +10
-0@@ -0,0 +1,124 @@ +/* +* Notice that this file is not protected like a normal header. +* We also must allow for rereading of this file. The +* +* || defined(TRACE_HEADER_MULTI_READ) +* +* serves this purpose. +*/ +#if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_EVENT_SAMPLE_H
Why do we need this protection at all? It only be included by the users of the tracepoints, and it seems just fair to take some more than normal precaution for more than unusual magic headers.
Steven Rostedt
maintainerRe: [PATCH 4/4] tracing/events: add trace-events-sample
Quoted 11 lines · Christoph Hellwig
samples/trace_events/Makefile line 6
Quoted 8 lines · Steven Rostedt
+++ b/samples/trace_events/Makefile
samples/trace_events/Makefile new file +6
-0@@ -0,0 +1,8 @@ +# builds the trace events example kernel modules; +# then to use one (as root): insmod <module_name.ko> + +PWD := $(shell pwd) + +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/CFLAGS_trace-events-sample.o += -I$(src)
Is $(src) defined to be where the object is compiled?
Quoted 4 lines
That should better be written as. But you'd easily get rid of that by just including the file using #include "
foo.h" instead of <foo.h>, no?
That is for the define_trace.h to find the file. The define_trace.h will look from where it is located. ie. include/trace
Quoted 10 lines
Quoted 10 lines
samples/trace_events/trace-events-sample.h new file +6
-0@@ -0,0 +1,124 @@ +/* +* Notice that this file is not protected like a normal header. +* We also must allow for rereading of this file. The +* +* || defined(TRACE_HEADER_MULTI_READ) +*
Quoted 8 lines
samples/trace_events/trace-events-sample.h line 10
Quoted 4 lines
samples/trace_events/trace-events-sample.h new file +4
-0+* serves this purpose. +*/ +#if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_EVENT_SAMPLE_HWhy do we need this protection at all? It only be included by the users of the tracepoints, and it seems just fair to take some more than normal precaution for more than unusual magic headers.
This was needed for kmem.h because it was causing header recursive hell. But instead of doing this for just a few headers, having it in all was a way to be:
1) safe
2) descriptive
#2 is because people are use to the #ifndef _MY_HEADER_H and seeing that there is also a TRACE_HEADER_MULTI_READ it makes it obvious that this header may be included more than once, purposefully.
-- Steve
Re: [PATCH 4/4] tracing/events: add trace-events-sample
Quoted 12 lines · Steven Rostedt
Quoted 11 lines · Steven Rostedt
samples/trace_events/Makefile line 6
Quoted 8 lines
+++ b/samples/trace_events/Makefile
samples/trace_events/Makefile new file +6
-0@@ -0,0 +1,8 @@ +# builds the trace events example kernel modules; +# then to use one (as root): insmod <module_name.ko> + +PWD := $(shell pwd) + +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/CFLAGS_trace-events-sample.o += -I$(src)
Quoted 1 line
Is $(src) defined to be where the object is compiled?
$(src) is the source directory, $(obj) is the directory where the compiled object ends up.
Steven Rostedt
maintainerRe: [PATCH 4/4] tracing/events: add trace-events-sample
Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Steven Rostedt
Quoted 11 lines · Steven Rostedt
samples/trace_events/Makefile line 6
Quoted 8 lines
+++ b/samples/trace_events/Makefile
samples/trace_events/Makefile new file +6
-0@@ -0,0 +1,8 @@ +# builds the trace events example kernel modules; +# then to use one (as root): insmod <module_name.ko> + +PWD := $(shell pwd) + +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/CFLAGS_trace-events-sample.o += -I$(src)
Quoted 4 lines
Quoted 1 line
Is $(src) defined to be where the object is compiled?
$(src) is the source directory, $(obj) is the directory where the compiled object ends up.
Oh, cool. I did not know that.
I'll update the sample code accordingly.
Thanks!
-- Steve
Re: [PATCH 4/4] tracing/events: add trace-events-sample
In reply to Steven RostedtQuoted 15 lines · Steven Rostedt
Quoted 11 lines · Christoph Hellwig
samples/trace_events/Makefile line 6
Quoted 8 lines · Steven Rostedt
+++ b/samples/trace_events/Makefile
samples/trace_events/Makefile new file +6
-0@@ -0,0 +1,8 @@ +# builds the trace events example kernel modules; +# then to use one (as root): insmod <module_name.ko> + +PWD := $(shell pwd) + +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/CFLAGS_trace-events-sample.o += -I$(src)
Quoted 1 line
Is $(src) defined to be where the object is compiled?
$(src) is the path to the directory where the source files are located. $(obj) is the path to the directory where the output is located.
They are both relative to the root of the kernel tree and thus they are equal. We have $(src) and $(obj) only for documentation purposes today.
In this case $(src) is correct as we want to point at where the source files are located.
Sam