2008-12-30 04:42:23 +07:00
|
|
|
/*
|
|
|
|
* Memory allocator tracing
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Eduard - Gabriel Munteanu
|
|
|
|
* Copyright (C) 2008 Pekka Enberg <penberg@cs.helsinki.fi>
|
|
|
|
* Copyright (C) 2008 Frederic Weisbecker <fweisbec@gmail.com>
|
|
|
|
*/
|
|
|
|
|
2009-03-23 22:14:13 +07:00
|
|
|
#include <linux/tracepoint.h>
|
|
|
|
#include <linux/seq_file.h>
|
2008-12-30 04:42:23 +07:00
|
|
|
#include <linux/debugfs.h>
|
2009-03-23 22:14:13 +07:00
|
|
|
#include <linux/dcache.h>
|
2008-12-30 04:42:23 +07:00
|
|
|
#include <linux/fs.h>
|
2009-03-23 22:14:13 +07:00
|
|
|
|
2009-04-10 13:26:18 +07:00
|
|
|
#include <linux/kmemtrace.h>
|
2008-12-30 04:42:23 +07:00
|
|
|
|
|
|
|
#include "trace_output.h"
|
2009-03-23 22:14:13 +07:00
|
|
|
#include "trace.h"
|
2008-12-30 04:42:23 +07:00
|
|
|
|
|
|
|
/* Select an alternative, minimalistic output than the original one */
|
|
|
|
#define TRACE_KMEM_OPT_MINIMAL 0x1
|
|
|
|
|
|
|
|
static struct tracer_opt kmem_opts[] = {
|
|
|
|
/* Default disable the minimalistic output */
|
|
|
|
{ TRACER_OPT(kmem_minimalistic, TRACE_KMEM_OPT_MINIMAL) },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct tracer_flags kmem_tracer_flags = {
|
2009-03-23 22:14:13 +07:00
|
|
|
.val = 0,
|
|
|
|
.opts = kmem_opts
|
2008-12-30 04:42:23 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct trace_array *kmemtrace_array;
|
|
|
|
|
2009-03-23 20:12:24 +07:00
|
|
|
/* Trace allocations */
|
|
|
|
static inline void kmemtrace_alloc(enum kmemtrace_type_id type_id,
|
|
|
|
unsigned long call_site,
|
|
|
|
const void *ptr,
|
|
|
|
size_t bytes_req,
|
|
|
|
size_t bytes_alloc,
|
|
|
|
gfp_t gfp_flags,
|
|
|
|
int node)
|
|
|
|
{
|
2009-03-31 12:48:49 +07:00
|
|
|
struct ftrace_event_call *call = &event_kmem_alloc;
|
2009-03-23 20:12:24 +07:00
|
|
|
struct trace_array *tr = kmemtrace_array;
|
2009-03-23 22:14:13 +07:00
|
|
|
struct kmemtrace_alloc_entry *entry;
|
|
|
|
struct ring_buffer_event *event;
|
2009-03-23 20:12:24 +07:00
|
|
|
|
|
|
|
event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry));
|
|
|
|
if (!event)
|
|
|
|
return;
|
2009-03-23 22:14:13 +07:00
|
|
|
|
|
|
|
entry = ring_buffer_event_data(event);
|
2009-03-23 20:12:24 +07:00
|
|
|
tracing_generic_entry_update(&entry->ent, 0, 0);
|
|
|
|
|
2009-03-23 22:14:13 +07:00
|
|
|
entry->ent.type = TRACE_KMEM_ALLOC;
|
|
|
|
entry->type_id = type_id;
|
|
|
|
entry->call_site = call_site;
|
|
|
|
entry->ptr = ptr;
|
|
|
|
entry->bytes_req = bytes_req;
|
|
|
|
entry->bytes_alloc = bytes_alloc;
|
|
|
|
entry->gfp_flags = gfp_flags;
|
|
|
|
entry->node = node;
|
2009-03-23 20:12:24 +07:00
|
|
|
|
2009-04-08 15:15:54 +07:00
|
|
|
if (!filter_check_discard(call, entry, tr->buffer, event))
|
|
|
|
ring_buffer_unlock_commit(tr->buffer, event);
|
2009-03-23 20:12:24 +07:00
|
|
|
|
|
|
|
trace_wake_up();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kmemtrace_free(enum kmemtrace_type_id type_id,
|
|
|
|
unsigned long call_site,
|
|
|
|
const void *ptr)
|
|
|
|
{
|
2009-03-31 12:48:49 +07:00
|
|
|
struct ftrace_event_call *call = &event_kmem_free;
|
2009-03-23 20:12:24 +07:00
|
|
|
struct trace_array *tr = kmemtrace_array;
|
2009-03-23 22:14:13 +07:00
|
|
|
struct kmemtrace_free_entry *entry;
|
|
|
|
struct ring_buffer_event *event;
|
2009-03-23 20:12:24 +07:00
|
|
|
|
|
|
|
event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry));
|
|
|
|
if (!event)
|
|
|
|
return;
|
|
|
|
entry = ring_buffer_event_data(event);
|
|
|
|
tracing_generic_entry_update(&entry->ent, 0, 0);
|
|
|
|
|
2009-03-23 22:14:13 +07:00
|
|
|
entry->ent.type = TRACE_KMEM_FREE;
|
|
|
|
entry->type_id = type_id;
|
|
|
|
entry->call_site = call_site;
|
|
|
|
entry->ptr = ptr;
|
2009-03-23 20:12:24 +07:00
|
|
|
|
2009-04-08 15:15:54 +07:00
|
|
|
if (!filter_check_discard(call, entry, tr->buffer, event))
|
|
|
|
ring_buffer_unlock_commit(tr->buffer, event);
|
2009-03-23 20:12:24 +07:00
|
|
|
|
|
|
|
trace_wake_up();
|
|
|
|
}
|
|
|
|
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
static void kmemtrace_kmalloc(void *ignore,
|
|
|
|
unsigned long call_site,
|
2009-03-23 20:12:24 +07:00
|
|
|
const void *ptr,
|
|
|
|
size_t bytes_req,
|
|
|
|
size_t bytes_alloc,
|
|
|
|
gfp_t gfp_flags)
|
|
|
|
{
|
|
|
|
kmemtrace_alloc(KMEMTRACE_TYPE_KMALLOC, call_site, ptr,
|
|
|
|
bytes_req, bytes_alloc, gfp_flags, -1);
|
|
|
|
}
|
|
|
|
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
static void kmemtrace_kmem_cache_alloc(void *ignore,
|
|
|
|
unsigned long call_site,
|
2009-03-23 20:12:24 +07:00
|
|
|
const void *ptr,
|
|
|
|
size_t bytes_req,
|
|
|
|
size_t bytes_alloc,
|
|
|
|
gfp_t gfp_flags)
|
|
|
|
{
|
|
|
|
kmemtrace_alloc(KMEMTRACE_TYPE_CACHE, call_site, ptr,
|
|
|
|
bytes_req, bytes_alloc, gfp_flags, -1);
|
|
|
|
}
|
|
|
|
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
static void kmemtrace_kmalloc_node(void *ignore,
|
|
|
|
unsigned long call_site,
|
2009-03-23 20:12:24 +07:00
|
|
|
const void *ptr,
|
|
|
|
size_t bytes_req,
|
|
|
|
size_t bytes_alloc,
|
|
|
|
gfp_t gfp_flags,
|
|
|
|
int node)
|
|
|
|
{
|
|
|
|
kmemtrace_alloc(KMEMTRACE_TYPE_KMALLOC, call_site, ptr,
|
|
|
|
bytes_req, bytes_alloc, gfp_flags, node);
|
|
|
|
}
|
|
|
|
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
static void kmemtrace_kmem_cache_alloc_node(void *ignore,
|
|
|
|
unsigned long call_site,
|
2009-03-23 20:12:24 +07:00
|
|
|
const void *ptr,
|
|
|
|
size_t bytes_req,
|
|
|
|
size_t bytes_alloc,
|
|
|
|
gfp_t gfp_flags,
|
|
|
|
int node)
|
|
|
|
{
|
|
|
|
kmemtrace_alloc(KMEMTRACE_TYPE_CACHE, call_site, ptr,
|
|
|
|
bytes_req, bytes_alloc, gfp_flags, node);
|
|
|
|
}
|
|
|
|
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
static void
|
|
|
|
kmemtrace_kfree(void *ignore, unsigned long call_site, const void *ptr)
|
2009-03-23 20:12:24 +07:00
|
|
|
{
|
|
|
|
kmemtrace_free(KMEMTRACE_TYPE_KMALLOC, call_site, ptr);
|
|
|
|
}
|
|
|
|
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
static void kmemtrace_kmem_cache_free(void *ignore,
|
|
|
|
unsigned long call_site, const void *ptr)
|
2009-03-23 20:12:24 +07:00
|
|
|
{
|
|
|
|
kmemtrace_free(KMEMTRACE_TYPE_CACHE, call_site, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int kmemtrace_start_probes(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
err = register_trace_kmalloc(kmemtrace_kmalloc, NULL);
|
2009-03-23 20:12:24 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
err = register_trace_kmem_cache_alloc(kmemtrace_kmem_cache_alloc, NULL);
|
2009-03-23 20:12:24 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
err = register_trace_kmalloc_node(kmemtrace_kmalloc_node, NULL);
|
2009-03-23 20:12:24 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
err = register_trace_kmem_cache_alloc_node(kmemtrace_kmem_cache_alloc_node, NULL);
|
2009-03-23 20:12:24 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
err = register_trace_kfree(kmemtrace_kfree, NULL);
|
2009-03-23 20:12:24 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
err = register_trace_kmem_cache_free(kmemtrace_kmem_cache_free, NULL);
|
2009-03-23 20:12:24 +07:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void kmemtrace_stop_probes(void)
|
|
|
|
{
|
tracing: Let tracepoints have data passed to tracepoint callbacks
This patch adds data to be passed to tracepoint callbacks.
The created functions from DECLARE_TRACE() now need a mandatory data
parameter. For example:
DECLARE_TRACE(mytracepoint, int value, value)
Will create the register function:
int register_trace_mytracepoint((void(*)(void *data, int value))probe,
void *data);
As the first argument, all callbacks (probes) must take a (void *data)
parameter. So a callback for the above tracepoint will look like:
void myprobe(void *data, int value)
{
}
The callback may choose to ignore the data parameter.
This change allows callbacks to register a private data pointer along
with the function probe.
void mycallback(void *data, int value);
register_trace_mytracepoint(mycallback, mydata);
Then the mycallback() will receive the "mydata" as the first parameter
before the args.
A more detailed example:
DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
/* In the C file */
DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));
[...]
trace_mytracepoint(status);
/* In a file registering this tracepoint */
int my_callback(void *data, int status)
{
struct my_struct my_data = data;
[...]
}
[...]
my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
init_my_data(my_data);
register_trace_mytracepoint(my_callback, my_data);
The same callback can also be registered to the same tracepoint as long
as the data registered is different. Note, the data must also be used
to unregister the callback:
unregister_trace_mytracepoint(my_callback, my_data);
Because of the data parameter, tracepoints declared this way can not have
no args. That is:
DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());
will cause an error.
If no arguments are needed, a new macro can be used instead:
DECLARE_TRACE_NOARGS(mytracepoint);
Since there are no arguments, the proto and args fields are left out.
This is part of a series to make the tracepoint footprint smaller:
text data bss dec hex filename
4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
4914025 1088868 861512 6864405 68be15 vmlinux.class
4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
Again, this patch also increases the size of the kernel, but
lays the ground work for decreasing it.
v5: Fixed net/core/drop_monitor.c to handle these updates.
v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
#ifdef CONFIG_TRACE_POINTS, since the two are the same in both
cases. The __DECLARE_TRACE() is what changes.
Thanks to Frederic Weisbecker for pointing this out.
v3: Made all register_* functions require data to be passed and
all callbacks to take a void * parameter as its first argument.
This makes the calling functions comply with C standards.
Also added more comments to the modifications of DECLARE_TRACE().
v2: Made the DECLARE_TRACE() have the ability to pass arguments
and added a new DECLARE_TRACE_NOARGS() for tracepoints that
do not need any arguments.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-04-21 04:04:50 +07:00
|
|
|
unregister_trace_kmalloc(kmemtrace_kmalloc, NULL);
|
|
|
|
unregister_trace_kmem_cache_alloc(kmemtrace_kmem_cache_alloc, NULL);
|
|
|
|
unregister_trace_kmalloc_node(kmemtrace_kmalloc_node, NULL);
|
|
|
|
unregister_trace_kmem_cache_alloc_node(kmemtrace_kmem_cache_alloc_node, NULL);
|
|
|
|
unregister_trace_kfree(kmemtrace_kfree, NULL);
|
|
|
|
unregister_trace_kmem_cache_free(kmemtrace_kmem_cache_free, NULL);
|
2009-03-23 20:12:24 +07:00
|
|
|
}
|
|
|
|
|
2008-12-30 04:42:23 +07:00
|
|
|
static int kmem_trace_init(struct trace_array *tr)
|
|
|
|
{
|
|
|
|
kmemtrace_array = tr;
|
|
|
|
|
2009-09-04 23:12:39 +07:00
|
|
|
tracing_reset_online_cpus(tr);
|
2008-12-30 04:42:23 +07:00
|
|
|
|
2009-03-23 20:12:24 +07:00
|
|
|
kmemtrace_start_probes();
|
2008-12-30 04:42:23 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void kmem_trace_reset(struct trace_array *tr)
|
|
|
|
{
|
2009-03-23 20:12:24 +07:00
|
|
|
kmemtrace_stop_probes();
|
2008-12-30 04:42:23 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void kmemtrace_headers(struct seq_file *s)
|
|
|
|
{
|
|
|
|
/* Don't need headers for the original kmemtrace output */
|
|
|
|
if (!(kmem_tracer_flags.val & TRACE_KMEM_OPT_MINIMAL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
seq_printf(s, "#\n");
|
|
|
|
seq_printf(s, "# ALLOC TYPE REQ GIVEN FLAGS "
|
|
|
|
" POINTER NODE CALLER\n");
|
|
|
|
seq_printf(s, "# FREE | | | | "
|
|
|
|
" | | | |\n");
|
|
|
|
seq_printf(s, "# |\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-03-23 20:12:26 +07:00
|
|
|
* The following functions give the original output from kmemtrace,
|
|
|
|
* plus the origin CPU, since reordering occurs in-kernel now.
|
2008-12-30 04:42:23 +07:00
|
|
|
*/
|
2009-03-23 20:12:26 +07:00
|
|
|
|
|
|
|
#define KMEMTRACE_USER_ALLOC 0
|
|
|
|
#define KMEMTRACE_USER_FREE 1
|
|
|
|
|
|
|
|
struct kmemtrace_user_event {
|
2009-03-23 22:14:13 +07:00
|
|
|
u8 event_id;
|
|
|
|
u8 type_id;
|
|
|
|
u16 event_size;
|
|
|
|
u32 cpu;
|
|
|
|
u64 timestamp;
|
|
|
|
unsigned long call_site;
|
|
|
|
unsigned long ptr;
|
2009-03-23 20:12:26 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct kmemtrace_user_event_alloc {
|
2009-03-23 22:14:13 +07:00
|
|
|
size_t bytes_req;
|
|
|
|
size_t bytes_alloc;
|
|
|
|
unsigned gfp_flags;
|
|
|
|
int node;
|
2009-03-23 20:12:26 +07:00
|
|
|
};
|
|
|
|
|
2008-12-30 04:42:23 +07:00
|
|
|
static enum print_line_t
|
2010-04-23 05:46:14 +07:00
|
|
|
kmemtrace_print_alloc(struct trace_iterator *iter, int flags,
|
|
|
|
struct trace_event *event)
|
2009-07-03 16:34:24 +07:00
|
|
|
{
|
|
|
|
struct trace_seq *s = &iter->seq;
|
|
|
|
struct kmemtrace_alloc_entry *entry;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
trace_assign_type(entry, iter->ent);
|
|
|
|
|
|
|
|
ret = trace_seq_printf(s, "type_id %d call_site %pF ptr %lu "
|
|
|
|
"bytes_req %lu bytes_alloc %lu gfp_flags %lu node %d\n",
|
|
|
|
entry->type_id, (void *)entry->call_site, (unsigned long)entry->ptr,
|
|
|
|
(unsigned long)entry->bytes_req, (unsigned long)entry->bytes_alloc,
|
|
|
|
(unsigned long)entry->gfp_flags, entry->node);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
return TRACE_TYPE_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum print_line_t
|
2010-04-23 05:46:14 +07:00
|
|
|
kmemtrace_print_free(struct trace_iterator *iter, int flags,
|
|
|
|
struct trace_event *event)
|
2008-12-30 04:42:23 +07:00
|
|
|
{
|
|
|
|
struct trace_seq *s = &iter->seq;
|
2009-07-03 16:34:24 +07:00
|
|
|
struct kmemtrace_free_entry *entry;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
trace_assign_type(entry, iter->ent);
|
|
|
|
|
|
|
|
ret = trace_seq_printf(s, "type_id %d call_site %pF ptr %lu\n",
|
|
|
|
entry->type_id, (void *)entry->call_site,
|
|
|
|
(unsigned long)entry->ptr);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
return TRACE_TYPE_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum print_line_t
|
2010-04-23 05:46:14 +07:00
|
|
|
kmemtrace_print_alloc_user(struct trace_iterator *iter, int flags,
|
|
|
|
struct trace_event *event)
|
2009-07-03 16:34:24 +07:00
|
|
|
{
|
|
|
|
struct trace_seq *s = &iter->seq;
|
|
|
|
struct kmemtrace_alloc_entry *entry;
|
2009-03-23 20:12:26 +07:00
|
|
|
struct kmemtrace_user_event *ev;
|
2009-07-03 16:34:24 +07:00
|
|
|
struct kmemtrace_user_event_alloc *ev_alloc;
|
|
|
|
|
|
|
|
trace_assign_type(entry, iter->ent);
|
2008-12-30 04:42:23 +07:00
|
|
|
|
2009-03-23 20:12:26 +07:00
|
|
|
ev = trace_seq_reserve(s, sizeof(*ev));
|
|
|
|
if (!ev)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
2009-03-23 22:14:13 +07:00
|
|
|
|
|
|
|
ev->event_id = KMEMTRACE_USER_ALLOC;
|
|
|
|
ev->type_id = entry->type_id;
|
|
|
|
ev->event_size = sizeof(*ev) + sizeof(*ev_alloc);
|
|
|
|
ev->cpu = iter->cpu;
|
|
|
|
ev->timestamp = iter->ts;
|
|
|
|
ev->call_site = entry->call_site;
|
|
|
|
ev->ptr = (unsigned long)entry->ptr;
|
2009-03-23 20:12:26 +07:00
|
|
|
|
|
|
|
ev_alloc = trace_seq_reserve(s, sizeof(*ev_alloc));
|
|
|
|
if (!ev_alloc)
|
2008-12-30 04:42:23 +07:00
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
2009-03-23 22:14:13 +07:00
|
|
|
|
|
|
|
ev_alloc->bytes_req = entry->bytes_req;
|
|
|
|
ev_alloc->bytes_alloc = entry->bytes_alloc;
|
|
|
|
ev_alloc->gfp_flags = entry->gfp_flags;
|
|
|
|
ev_alloc->node = entry->node;
|
2008-12-30 04:42:23 +07:00
|
|
|
|
|
|
|
return TRACE_TYPE_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum print_line_t
|
2010-04-23 05:46:14 +07:00
|
|
|
kmemtrace_print_free_user(struct trace_iterator *iter, int flags,
|
|
|
|
struct trace_event *event)
|
2008-12-30 04:42:23 +07:00
|
|
|
{
|
|
|
|
struct trace_seq *s = &iter->seq;
|
2009-07-03 16:34:24 +07:00
|
|
|
struct kmemtrace_free_entry *entry;
|
2009-03-23 20:12:26 +07:00
|
|
|
struct kmemtrace_user_event *ev;
|
2008-12-30 04:42:23 +07:00
|
|
|
|
2009-07-03 16:34:24 +07:00
|
|
|
trace_assign_type(entry, iter->ent);
|
|
|
|
|
2009-03-23 20:12:26 +07:00
|
|
|
ev = trace_seq_reserve(s, sizeof(*ev));
|
|
|
|
if (!ev)
|
2008-12-30 04:42:23 +07:00
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
2009-03-23 22:14:13 +07:00
|
|
|
|
|
|
|
ev->event_id = KMEMTRACE_USER_FREE;
|
|
|
|
ev->type_id = entry->type_id;
|
|
|
|
ev->event_size = sizeof(*ev);
|
|
|
|
ev->cpu = iter->cpu;
|
|
|
|
ev->timestamp = iter->ts;
|
|
|
|
ev->call_site = entry->call_site;
|
|
|
|
ev->ptr = (unsigned long)entry->ptr;
|
2008-12-30 04:42:23 +07:00
|
|
|
|
|
|
|
return TRACE_TYPE_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The two other following provide a more minimalistic output */
|
|
|
|
static enum print_line_t
|
2009-07-03 16:34:24 +07:00
|
|
|
kmemtrace_print_alloc_compress(struct trace_iterator *iter)
|
2008-12-30 04:42:23 +07:00
|
|
|
{
|
2009-07-03 16:34:24 +07:00
|
|
|
struct kmemtrace_alloc_entry *entry;
|
2008-12-30 04:42:23 +07:00
|
|
|
struct trace_seq *s = &iter->seq;
|
|
|
|
int ret;
|
|
|
|
|
2009-07-03 16:34:24 +07:00
|
|
|
trace_assign_type(entry, iter->ent);
|
|
|
|
|
2008-12-30 04:42:23 +07:00
|
|
|
/* Alloc entry */
|
|
|
|
ret = trace_seq_printf(s, " + ");
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Type */
|
|
|
|
switch (entry->type_id) {
|
|
|
|
case KMEMTRACE_TYPE_KMALLOC:
|
|
|
|
ret = trace_seq_printf(s, "K ");
|
|
|
|
break;
|
|
|
|
case KMEMTRACE_TYPE_CACHE:
|
|
|
|
ret = trace_seq_printf(s, "C ");
|
|
|
|
break;
|
|
|
|
case KMEMTRACE_TYPE_PAGES:
|
|
|
|
ret = trace_seq_printf(s, "P ");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = trace_seq_printf(s, "? ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Requested */
|
2009-01-30 04:49:45 +07:00
|
|
|
ret = trace_seq_printf(s, "%4zu ", entry->bytes_req);
|
2008-12-30 04:42:23 +07:00
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Allocated */
|
2009-01-30 04:49:45 +07:00
|
|
|
ret = trace_seq_printf(s, "%4zu ", entry->bytes_alloc);
|
2008-12-30 04:42:23 +07:00
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Flags
|
|
|
|
* TODO: would be better to see the name of the GFP flag names
|
|
|
|
*/
|
|
|
|
ret = trace_seq_printf(s, "%08x ", entry->gfp_flags);
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Pointer to allocated */
|
|
|
|
ret = trace_seq_printf(s, "0x%tx ", (ptrdiff_t)entry->ptr);
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
2009-07-09 09:46:30 +07:00
|
|
|
/* Node and call site*/
|
|
|
|
ret = trace_seq_printf(s, "%4d %pf\n", entry->node,
|
|
|
|
(void *)entry->call_site);
|
2008-12-30 04:42:23 +07:00
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
return TRACE_TYPE_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum print_line_t
|
2009-07-03 16:34:24 +07:00
|
|
|
kmemtrace_print_free_compress(struct trace_iterator *iter)
|
2008-12-30 04:42:23 +07:00
|
|
|
{
|
2009-07-03 16:34:24 +07:00
|
|
|
struct kmemtrace_free_entry *entry;
|
2008-12-30 04:42:23 +07:00
|
|
|
struct trace_seq *s = &iter->seq;
|
|
|
|
int ret;
|
|
|
|
|
2009-07-03 16:34:24 +07:00
|
|
|
trace_assign_type(entry, iter->ent);
|
|
|
|
|
2008-12-30 04:42:23 +07:00
|
|
|
/* Free entry */
|
|
|
|
ret = trace_seq_printf(s, " - ");
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Type */
|
|
|
|
switch (entry->type_id) {
|
|
|
|
case KMEMTRACE_TYPE_KMALLOC:
|
|
|
|
ret = trace_seq_printf(s, "K ");
|
|
|
|
break;
|
|
|
|
case KMEMTRACE_TYPE_CACHE:
|
|
|
|
ret = trace_seq_printf(s, "C ");
|
|
|
|
break;
|
|
|
|
case KMEMTRACE_TYPE_PAGES:
|
|
|
|
ret = trace_seq_printf(s, "P ");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = trace_seq_printf(s, "? ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Skip requested/allocated/flags */
|
|
|
|
ret = trace_seq_printf(s, " ");
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
/* Pointer to allocated */
|
|
|
|
ret = trace_seq_printf(s, "0x%tx ", (ptrdiff_t)entry->ptr);
|
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
2009-07-09 09:46:30 +07:00
|
|
|
/* Skip node and print call site*/
|
|
|
|
ret = trace_seq_printf(s, " %pf\n", (void *)entry->call_site);
|
2008-12-30 04:42:23 +07:00
|
|
|
if (!ret)
|
|
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
|
|
|
|
return TRACE_TYPE_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum print_line_t kmemtrace_print_line(struct trace_iterator *iter)
|
|
|
|
{
|
|
|
|
struct trace_entry *entry = iter->ent;
|
|
|
|
|
2009-07-03 16:34:24 +07:00
|
|
|
if (!(kmem_tracer_flags.val & TRACE_KMEM_OPT_MINIMAL))
|
|
|
|
return TRACE_TYPE_UNHANDLED;
|
2008-12-30 04:42:23 +07:00
|
|
|
|
2009-07-03 16:34:24 +07:00
|
|
|
switch (entry->type) {
|
|
|
|
case TRACE_KMEM_ALLOC:
|
|
|
|
return kmemtrace_print_alloc_compress(iter);
|
|
|
|
case TRACE_KMEM_FREE:
|
|
|
|
return kmemtrace_print_free_compress(iter);
|
2008-12-30 04:42:23 +07:00
|
|
|
default:
|
|
|
|
return TRACE_TYPE_UNHANDLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-23 05:46:14 +07:00
|
|
|
static struct trace_event_functions kmem_trace_alloc_funcs = {
|
2009-07-06 15:15:04 +07:00
|
|
|
.trace = kmemtrace_print_alloc,
|
|
|
|
.binary = kmemtrace_print_alloc_user,
|
2009-07-03 16:34:24 +07:00
|
|
|
};
|
|
|
|
|
2010-04-23 05:46:14 +07:00
|
|
|
static struct trace_event kmem_trace_alloc = {
|
|
|
|
.type = TRACE_KMEM_ALLOC,
|
|
|
|
.funcs = &kmem_trace_alloc_funcs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct trace_event_functions kmem_trace_free_funcs = {
|
2009-07-06 15:15:04 +07:00
|
|
|
.trace = kmemtrace_print_free,
|
|
|
|
.binary = kmemtrace_print_free_user,
|
2009-07-03 16:34:24 +07:00
|
|
|
};
|
|
|
|
|
2010-04-23 05:46:14 +07:00
|
|
|
static struct trace_event kmem_trace_free = {
|
|
|
|
.type = TRACE_KMEM_FREE,
|
|
|
|
.funcs = &kmem_trace_free_funcs,
|
|
|
|
};
|
|
|
|
|
2008-12-30 04:42:23 +07:00
|
|
|
static struct tracer kmem_tracer __read_mostly = {
|
2009-03-23 22:14:13 +07:00
|
|
|
.name = "kmemtrace",
|
|
|
|
.init = kmem_trace_init,
|
|
|
|
.reset = kmem_trace_reset,
|
|
|
|
.print_line = kmemtrace_print_line,
|
|
|
|
.print_header = kmemtrace_headers,
|
|
|
|
.flags = &kmem_tracer_flags
|
2008-12-30 04:42:23 +07:00
|
|
|
};
|
|
|
|
|
2009-01-06 16:16:35 +07:00
|
|
|
void kmemtrace_init(void)
|
|
|
|
{
|
|
|
|
/* earliest opportunity to start kmem tracing */
|
|
|
|
}
|
|
|
|
|
2008-12-30 04:42:23 +07:00
|
|
|
static int __init init_kmem_tracer(void)
|
|
|
|
{
|
2009-07-03 16:34:24 +07:00
|
|
|
if (!register_ftrace_event(&kmem_trace_alloc)) {
|
|
|
|
pr_warning("Warning: could not register kmem events\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!register_ftrace_event(&kmem_trace_free)) {
|
|
|
|
pr_warning("Warning: could not register kmem events\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-09-28 14:55:40 +07:00
|
|
|
if (register_tracer(&kmem_tracer) != 0) {
|
2009-07-03 16:34:24 +07:00
|
|
|
pr_warning("Warning: could not register the kmem tracer\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2008-12-30 04:42:23 +07:00
|
|
|
}
|
|
|
|
device_initcall(init_kmem_tracer);
|