Skip to content

Commit

Permalink
tracing: Documentation / sample code fixes for tracepoints
Browse files Browse the repository at this point in the history
Fix the tracepoint documentation to refer to "tracepoint-sample"
instead of "tracepoint-example" to match what actually exists;
fix the directory, and clarify how to compile.

Change every instance of "example" in the sample tracepoint code
to "sample" for consistency.

Signed-off-by: Jody McIntyre <[email protected]>
Acked-by: Mathieu Desnoyers <[email protected]>
Cc: [email protected]
LKML-Reference: <20090324200027.GH8294@clouds>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Jody McIntyre authored and Ingo Molnar committed Mar 24, 2009
1 parent a524446 commit 0a5d649
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
13 changes: 7 additions & 6 deletions Documentation/tracepoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ used to export the defined tracepoints.

* Probe / tracepoint example

See the example provided in samples/tracepoints/src
See the example provided in samples/tracepoints

Compile them with your kernel.
Compile them with your kernel. They are built during 'make' (not
'make modules') when CONFIG_SAMPLE_TRACEPOINTS=m.

Run, as root :
modprobe tracepoint-example (insmod order is not important)
modprobe tracepoint-probe-example
cat /proc/tracepoint-example (returns an expected error)
rmmod tracepoint-example tracepoint-probe-example
modprobe tracepoint-sample (insmod order is not important)
modprobe tracepoint-probe-sample
cat /proc/tracepoint-sample (returns an expected error)
rmmod tracepoint-sample tracepoint-probe-sample
dmesg
24 changes: 12 additions & 12 deletions samples/tracepoints/tracepoint-sample.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tracepoint-sample.c
*
* Executes a tracepoint when /proc/tracepoint-example is opened.
* Executes a tracepoint when /proc/tracepoint-sample is opened.
*
* (C) Copyright 2007 Mathieu Desnoyers <[email protected]>
*
Expand All @@ -16,7 +16,7 @@
DEFINE_TRACE(subsys_event);
DEFINE_TRACE(subsys_eventb);

struct proc_dir_entry *pentry_example;
struct proc_dir_entry *pentry_sample;

static int my_open(struct inode *inode, struct file *file)
{
Expand All @@ -32,25 +32,25 @@ static struct file_operations mark_ops = {
.open = my_open,
};

static int __init example_init(void)
static int __init sample_init(void)
{
printk(KERN_ALERT "example init\n");
pentry_example = proc_create("tracepoint-example", 0444, NULL,
printk(KERN_ALERT "sample init\n");
pentry_sample = proc_create("tracepoint-sample", 0444, NULL,
&mark_ops);
if (!pentry_example)
if (!pentry_sample)
return -EPERM;
return 0;
}

static void __exit example_exit(void)
static void __exit sample_exit(void)
{
printk(KERN_ALERT "example exit\n");
remove_proc_entry("tracepoint-example", NULL);
printk(KERN_ALERT "sample exit\n");
remove_proc_entry("tracepoint-sample", NULL);
}

module_init(example_init)
module_exit(example_exit)
module_init(sample_init)
module_exit(sample_exit)

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mathieu Desnoyers");
MODULE_DESCRIPTION("Tracepoint example");
MODULE_DESCRIPTION("Tracepoint sample");

0 comments on commit 0a5d649

Please sign in to comment.