backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: backports@vger.kernel.org
Cc: johannes@sipsolutions.net, Hauke Mehrtens <hauke@hauke-m.de>
Subject: [PATCH 05/12] header: Add trace_##name##_enabled()
Date: Mon,  5 Aug 2019 14:06:57 +0200	[thread overview]
Message-ID: <20190805120704.13128-6-hauke@hauke-m.de> (raw)
In-Reply-To: <20190805120704.13128-1-hauke@hauke-m.de>

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>
---
 backport/backport-include/linux/tracepoint.h | 132 +++++++++++++++++++
 1 file changed, 132 insertions(+)

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 */
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

  parent reply	other threads:[~2019-08-05 12:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 12:06 [PATCH 00/12] backports: Update to kernel 5.3-rc3 Hauke Mehrtens
2019-08-05 12:06 ` [PATCH 01/12] patches: Refresh patches against " Hauke Mehrtens
2019-08-05 12:06 ` [PATCH 02/12] header: Add BITS_PER_TYPE() Hauke Mehrtens
2019-08-05 12:06 ` [PATCH 03/12] header: Add ktime_get_boottime_ns() Hauke Mehrtens
2019-08-05 12:06 ` [PATCH 04/12] header: Add nl80211_validate_nested() Hauke Mehrtens
2019-08-05 12:06 ` Hauke Mehrtens [this message]
2019-08-05 12:06 ` [PATCH 06/12] header: Remove skb_xmit_more() Hauke Mehrtens
2019-08-05 12:06 ` [PATCH 07/12] backport: Add genl_callback_extack() function Hauke Mehrtens
2019-08-05 12:07 ` [PATCH 08/12] backport: Add arc4 library Hauke Mehrtens
2019-08-05 12:07 ` [PATCH 09/12] patches: Add include in cfg80211.h Hauke Mehrtens
2019-08-05 12:07 ` [PATCH 10/12] patches: Do not use GRO_CONSUMED on kernel < 4.11 Hauke Mehrtens
2019-08-05 12:07 ` [PATCH 11/12] dependencies: Make AIRO depend on kernel 4.20 Hauke Mehrtens
2019-08-05 12:07 ` [PATCH 12/12] kconfig: Update to KConfig to version from kernel 4.17 Hauke Mehrtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190805120704.13128-6-hauke@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=backports@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).