Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199133
b: refs/heads/master
c: 38516ab
h: refs/heads/master
i:
  199131: 174845f
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed May 14, 2010
1 parent 67d0d22 commit 9178b2d
Show file tree
Hide file tree
Showing 15 changed files with 299 additions and 211 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53da59aa6dd881fd0bbdd058a8a299d90ce9dd1d
refs/heads/master: 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e
95 changes: 72 additions & 23 deletions trunk/include/linux/tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
struct module;
struct tracepoint;

struct tracepoint_func {
void *func;
void *data;
};

struct tracepoint {
const char *name; /* Tracepoint name */
int state; /* State. */
void (*regfunc)(void);
void (*unregfunc)(void);
void **funcs;
struct tracepoint_func *funcs;
} __attribute__((aligned(32))); /*
* Aligned on 32 bytes because it is
* globally visible and gcc happily
Expand All @@ -37,16 +42,19 @@ struct tracepoint {
* Connect a probe to a tracepoint.
* Internal API, should not be used directly.
*/
extern int tracepoint_probe_register(const char *name, void *probe);
extern int tracepoint_probe_register(const char *name, void *probe, void *data);

/*
* Disconnect a probe from a tracepoint.
* Internal API, should not be used directly.
*/
extern int tracepoint_probe_unregister(const char *name, void *probe);
extern int
tracepoint_probe_unregister(const char *name, void *probe, void *data);

extern int tracepoint_probe_register_noupdate(const char *name, void *probe);
extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe);
extern int tracepoint_probe_register_noupdate(const char *name, void *probe,
void *data);
extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe,
void *data);
extern void tracepoint_probe_update_all(void);

struct tracepoint_iter {
Expand Down Expand Up @@ -102,17 +110,27 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
/*
* it_func[0] is never NULL because there is at least one element in the array
* when the array itself is non NULL.
*
* Note, the proto and args passed in includes "__data" as the first parameter.
* The reason for this is to handle the "void" prototype. If a tracepoint
* has a "void" prototype, then it is invalid to declare a function
* as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
* "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
*/
#define __DO_TRACE(tp, proto, args) \
do { \
void **it_func; \
struct tracepoint_func *it_func_ptr; \
void *it_func; \
void *__data; \
\
rcu_read_lock_sched_notrace(); \
it_func = rcu_dereference_sched((tp)->funcs); \
if (it_func) { \
it_func_ptr = rcu_dereference_sched((tp)->funcs); \
if (it_func_ptr) { \
do { \
((void(*)(proto))(*it_func))(args); \
} while (*(++it_func)); \
it_func = (it_func_ptr)->func; \
__data = (it_func_ptr)->data; \
((void(*)(proto))(it_func))(args); \
} while ((++it_func_ptr)->func); \
} \
rcu_read_unlock_sched_notrace(); \
} while (0)
Expand All @@ -122,23 +140,29 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
* not add unwanted padding between the beginning of the section and the
* structure. Force alignment to the same alignment as the section start.
*/
#define DECLARE_TRACE(name, proto, args) \
#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
extern struct tracepoint __tracepoint_##name; \
static inline void trace_##name(proto) \
{ \
if (unlikely(__tracepoint_##name.state)) \
__DO_TRACE(&__tracepoint_##name, \
TP_PROTO(proto), TP_ARGS(args)); \
TP_PROTO(data_proto), \
TP_ARGS(data_args)); \
} \
static inline int register_trace_##name(void (*probe)(proto)) \
static inline int \
register_trace_##name(void (*probe)(data_proto), void *data) \
{ \
return tracepoint_probe_register(#name, (void *)probe); \
return tracepoint_probe_register(#name, (void *)probe, \
data); \
} \
static inline int unregister_trace_##name(void (*probe)(proto)) \
static inline int \
unregister_trace_##name(void (*probe)(data_proto), void *data) \
{ \
return tracepoint_probe_unregister(#name, (void *)probe);\
return tracepoint_probe_unregister(#name, (void *)probe, \
data); \
} \
static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
static inline void \
check_trace_callback_type_##name(void (*cb)(data_proto)) \
{ \
}

Expand All @@ -158,20 +182,22 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
EXPORT_SYMBOL(__tracepoint_##name)

#else /* !CONFIG_TRACEPOINTS */
#define DECLARE_TRACE(name, proto, args) \
static inline void _do_trace_##name(struct tracepoint *tp, proto) \
{ } \
#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
static inline void trace_##name(proto) \
{ } \
static inline int register_trace_##name(void (*probe)(proto)) \
static inline int \
register_trace_##name(void (*probe)(data_proto), \
void *data) \
{ \
return -ENOSYS; \
} \
static inline int unregister_trace_##name(void (*probe)(proto)) \
static inline int \
unregister_trace_##name(void (*probe)(data_proto), \
void *data) \
{ \
return -ENOSYS; \
} \
static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
{ \
}

Expand All @@ -181,6 +207,29 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
#define EXPORT_TRACEPOINT_SYMBOL(name)

#endif /* CONFIG_TRACEPOINTS */

/*
* The need for the DECLARE_TRACE_NOARGS() is to handle the prototype
* (void). "void" is a special value in a function prototype and can
* not be combined with other arguments. Since the DECLARE_TRACE()
* macro adds a data element at the beginning of the prototype,
* we need a way to differentiate "(void *data, proto)" from
* "(void *data, void)". The second prototype is invalid.
*
* DECLARE_TRACE_NOARGS() passes "void" as the tracepoint prototype
* and "void *__data" as the callback prototype.
*
* DECLARE_TRACE() passes "proto" as the tracepoint protoype and
* "void *__data, proto" as the callback prototype.
*/
#define DECLARE_TRACE_NOARGS(name) \
__DECLARE_TRACE(name, void, , void *__data, __data)

#define DECLARE_TRACE(name, proto, args) \
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
PARAMS(void *__data, proto), \
PARAMS(__data, args))

#endif /* DECLARE_TRACE */

#ifndef TRACE_EVENT
Expand Down
14 changes: 7 additions & 7 deletions trunk/include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,18 @@ static inline notrace int ftrace_get_offsets_##call( \
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args) \
\
static void perf_trace_##name(proto); \
static void perf_trace_##name(void *, proto); \
\
static notrace int \
perf_trace_enable_##name(struct ftrace_event_call *unused) \
{ \
return register_trace_##name(perf_trace_##name); \
return register_trace_##name(perf_trace_##name, NULL); \
} \
\
static notrace void \
perf_trace_disable_##name(struct ftrace_event_call *unused) \
{ \
unregister_trace_##name(perf_trace_##name); \
unregister_trace_##name(perf_trace_##name, NULL); \
}

#undef DEFINE_EVENT_PRINT
Expand Down Expand Up @@ -578,21 +578,21 @@ ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, call, proto, args) \
\
static notrace void ftrace_raw_event_##call(proto) \
static notrace void ftrace_raw_event_##call(void *__ignore, proto) \
{ \
ftrace_raw_event_id_##template(&event_##call, args); \
} \
\
static notrace int \
ftrace_raw_reg_event_##call(struct ftrace_event_call *unused) \
{ \
return register_trace_##call(ftrace_raw_event_##call); \
return register_trace_##call(ftrace_raw_event_##call, NULL); \
} \
\
static notrace void \
ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused) \
{ \
unregister_trace_##call(ftrace_raw_event_##call); \
unregister_trace_##call(ftrace_raw_event_##call, NULL); \
} \
\
static struct trace_event ftrace_event_type_##call = { \
Expand Down Expand Up @@ -793,7 +793,7 @@ perf_trace_templ_##call(struct ftrace_event_call *event_call, \

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, call, proto, args) \
static notrace void perf_trace_##call(proto) \
static notrace void perf_trace_##call(void *__ignore, proto) \
{ \
struct ftrace_event_call *event_call = &event_##call; \
\
Expand Down
Loading

0 comments on commit 9178b2d

Please sign in to comment.