Re: [PATCH 4/4] compat: add some tracing backport work

From: Luis R. Rodriguez
Date: Mon Mar 26 2012 - 08:58:26 EST


On Mon, Mar 26, 2012 at 10:49:28AM +0200, Johannes Berg wrote:
> On Wed, 2012-03-21 at 21:29 -0700, Luis R. Rodriguez wrote:
>
> > But no dice. I then figured it may be my kernel with
> > CONFIG_TRACEPOINTS=y and indeed that is the case -- so we have to
> > consider the case where the target kernel may have tracing enabled and
> > we have to disable it somehow. Undef'ing CONFIG_TRACEPOINTS and
> > DECLARE_TRACE doesn't really do it.
>
> Oh, ok, yuck. So I guess we can't easily disable tracing if it's enabled
> in the base kernel ...

Its a bit tough.

> > We may need to redefine each macro to some COMPAT_TRACE_ macro, not sure yet.
>
> That would require patches again though, no fun either.

Agreed.

I've gotten a bit farther:

This is not yet complete. At least for mac80211 we fail with:

CC [M] /home/mcgrof/devel/compat-wireless/net/mac80211/driver-trace.o
In file included from include/trace/ftrace.h:554:0,
from include/trace/define_trace.h:96,
from /home/mcgrof/devel/compat-wireless/include/trace/define_trace.h:4,
from /home/mcgrof/devel/compat-wireless/net/mac80211/driver-trace.h:1559,
from /home/mcgrof/devel/compat-wireless/net/mac80211/driver-trace.c:8:
/home/mcgrof/devel/compat-wireless/net/mac80211/./driver-trace.h: In function âftrace_test_probe_drv_return_voidâ:
/home/mcgrof/devel/compat-wireless/net/mac80211/./driver-trace.h:111:2: error: implicit declaration of function âcheck_trace_callback_type_drv_return_voidâ

This is against v2.6.33

And ckmake log:

mcgrof@tux ~/compat (git::master)$ ckmake
Trying kernel 3.3.0-030300rc2-generic [OK]
Trying kernel 3.2.2-030202-generic [OK]
Trying kernel 3.1.10-030110-generic [OK]
Trying kernel 3.0.18-030018-generic [OK]
Trying kernel 2.6.39-02063904-generic [OK]
Trying kernel 2.6.38-13-generic [OK]
Trying kernel 2.6.38-02063808-generic [OK]
Trying kernel 2.6.37-02063706-generic [FAILED]
Trying kernel 2.6.36-02063604-generic [FAILED]
Trying kernel 2.6.35-02063512-generic [FAILED]
Trying kernel 2.6.34-02063410-generic [OK]
Trying kernel 2.6.33-02063305-generic [OK]
Trying kernel 2.6.32-02063255-generic [OK]
Trying kernel 2.6.31-22-generic [OK]
Trying kernel 2.6.31-02063113-generic [OK]
Trying kernel 2.6.30-02063010-generic [OK]
Trying kernel 2.6.29-02062906-generic [OK]
Trying kernel 2.6.28-02062810-generic [OK]
Trying kernel 2.6.27-020627-generic [OK]
Trying kernel 2.6.26-020626-generic [OK]
Trying kernel 2.6.25-020625-generic [OK]
Trying kernel 2.6.24-020624-generic [OK]


---
include/linux/tracepoint.h | 57 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a5bd743..4930600 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -10,13 +10,16 @@
/* Backports f42c85e7 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
#undef TP_STRUCT__entry
+/* XXX: Is this right when CONFIG_TRACEPOINTS is enabled ? */
#define TP_STRUCT__entry(args...) args
#endif

-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
/* Backports 091ad365, a rename */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE
+#endif

+/* Backpports 2939b0469 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
#define TP_PROTO TPPROTO
#define TP_ARGS TPARGS
@@ -24,7 +27,53 @@
#define TP_RAW_FMT TPRAWFMT
#endif

-#endif
+/* Force disabling tracing */
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, ...) \
+static inline void trace_ ## name(proto) {}
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(...)
+#undef DEFINE_EVENT
+#define DEFINE_EVENT(evt_class, name, proto, ...) \
+static inline void trace_ ## name(proto) {}
+
+#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)) \
+ { \
+ }
+
+#undef DEFINE_TRACE_FN
+#define DEFINE_TRACE_FN(name, reg, unreg)
+
+#undef DEFINE_TRACE
+#define DEFINE_TRACE(name)
+
+#undef EXPORT_TRACEPOINT_SYMBOL_GPL
+#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
+
+#undef EXPORT_TRACEPOINT_SYMBOL
+#define EXPORT_TRACEPOINT_SYMBOL(name)
+
+#ifdef CONFIG_TRACEPOINTS
+#else /* CONFIG_TRACEPOINTS */
+#endif /* CONFIG_TRACEPOINTS */

#else /* just disable tracing */

@@ -42,8 +91,8 @@ static inline void trace_ ## name(proto) {}
#define TP_ARGS(args...) args
#define TP_CONDITION(args...) args

-struct tracepoint_iter {
-};
+//struct tracepoint_iter {
+//};

#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */

--
1.7.10.rc1.22.gf5241

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/