diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2019-08-02 22:06:21 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2019-08-14 20:15:48 +0200 |
commit | f6f975f74e57492d952ce03c4f410d16935a3161 (patch) | |
tree | 7c62a3e293c0438d70192ce6e0c5dcaf95ffe02f /backport | |
parent | 70c90463ff26b759fddf6e5decc6bf6ae6136776 (diff) |
header: Add trace_##name##_enabled()
This adds the function trace_##name##_enabled to __DECLARE_TRACE() which
was added in commit 7c65bbc7dc ("tracing: Add
trace_<tracepoint>_enabled() function"). This is now used by ath10k.
__DECLARE_TRACE() got other changes wit kernel 3.16, so add two
different versions.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'backport')
-rw-r--r-- | backport/backport-include/linux/tracepoint.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/backport/backport-include/linux/tracepoint.h b/backport/backport-include/linux/tracepoint.h index a695c6fc..6bb91ad3 100644 --- a/backport/backport-include/linux/tracepoint.h +++ b/backport/backport-include/linux/tracepoint.h @@ -7,4 +7,136 @@ #define TRACE_DEFINE_ENUM(a) #endif +#if LINUX_VERSION_IS_LESS(3,15,0) +#ifdef TRACEPOINTS_ENABLED +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + extern struct tracepoint __tracepoint_##name; \ + static inline void trace_##name(proto) \ + { \ + if (static_key_false(&__tracepoint_##name.key)) \ + __DO_TRACE(&__tracepoint_##name, \ + TP_PROTO(data_proto), \ + TP_ARGS(data_args), \ + TP_CONDITION(cond),,); \ + } \ + __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \ + PARAMS(cond), PARAMS(data_proto), PARAMS(data_args)) \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_register(#name, (void *)probe, \ + data); \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_unregister(#name, (void *)probe, \ + data); \ + } \ + static inline void \ + check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return static_key_false(&__tracepoint_##name.key); \ + } + +#else +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void trace_##name##_rcuidle(proto) \ + { } \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return false; \ + } +#endif /* TRACEPOINTS_ENABLED */ +#elif LINUX_VERSION_IS_LESS(3,16,0) +#ifdef TRACEPOINTS_ENABLED +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + extern struct tracepoint __tracepoint_##name; \ + static inline void trace_##name(proto) \ + { \ + if (static_key_false(&__tracepoint_##name.key)) \ + __DO_TRACE(&__tracepoint_##name, \ + TP_PROTO(data_proto), \ + TP_ARGS(data_args), \ + TP_CONDITION(cond),,); \ + } \ + __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \ + PARAMS(cond), PARAMS(data_proto), PARAMS(data_args)) \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_register(&__tracepoint_##name, \ + (void *)probe, data); \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_unregister(&__tracepoint_##name,\ + (void *)probe, data); \ + } \ + static inline void \ + check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return static_key_false(&__tracepoint_##name.key); \ + } + +#else +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void trace_##name##_rcuidle(proto) \ + { } \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return false; \ + } +#endif /* TRACEPOINTS_ENABLED */ +#endif /* < 3.16 */ + #endif /* __BACKPORT_LINUX_TRACEPOINT_H */ |