tracing: fix TRACE_EVENT power tracepoint creation
Mathieu Desnoyers
reviewerPATCH 1/1 tracing: fix TRACE_EVENT power tracepoint creation
DEFINE_TRACE should also exist when CONFIG_EVENT_TRACING=n. Otherwise, setting only TRACEPOINTS=y is broken.
--- kernel/Makefile | 1 + kernel/trace/Makefile | 2 +- kernel/trace/power-traces.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-)
kernel/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_TASKSTATS) += taskstats.o t obj-$(USE_IMMEDIATE) += immediate.o obj-$(CONFIG_MARKERS) += marker.o obj-$(CONFIG_TRACEPOINTS) += tracepoint.o +obj-$(CONFIG_TRACEPOINTS) += trace/ obj-$(CONFIG_LATENCYTOP) += latencytop.o obj-$(CONFIG_BINFMT_ELF) += elfcore.o obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o
kernel/trace/Makefile +1 -1
@@ -52,7 +52,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_eve endif obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o -obj-$(CONFIG_EVENT_TRACING) += power-traces.o +obj-$(CONFIG_TRACEPOINTS) += power-traces.o ifeq ($(CONFIG_TRACING),y) obj-$(CONFIG_KGDB_KDB) += trace_kdb.o endif
kernel/trace/power-traces.c +6 -0
@@ -10,8 +10,14 @@#include <linux/sched.h> #include <linux/module.h> +#ifdef CONFIG_EVENT_TRACING #define CREATE_TRACE_POINTS #include <trace/events/power.h> +#else +DEFINE_TRACE (power_start); +DEFINE_TRACE (power_end); +DEFINE_TRACE (power_frequency); +#endif EXPORT_TRACEPOINT_SYMBOL_GPL (power_frequency);
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
Quoted 2 lines · Mathieu Desnoyers
DEFINE_TRACEshould also exist whenCONFIG_EVENT_TRACING=n. Otherwise, setting only TRACEPOINTS=y is broken.
NAK, DEFINE_TRACE is deprecated from use outside the tracing infrastructure.
Quoted 39 lines
Signed-off-by Mathieu Desnoyers <[email protected]>--- kernel/Makefile | 1 + kernel/trace/Makefile | 2 +- kernel/trace/power-traces.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-)Index: linux-2.6-lttng/kernel/Makefile
===================================================================kernel/Makefile +1
-0@@ -93,6 +93,7 @@ obj-$(CONFIG_TASKSTATS) += taskstats.o t obj-$(USE_IMMEDIATE) += immediate.o obj-$(CONFIG_MARKERS) += marker.o obj-$(CONFIG_TRACEPOINTS) += tracepoint.o +obj-$(CONFIG_TRACEPOINTS) += trace/ obj-$(CONFIG_LATENCYTOP) += latencytop.o obj-$(CONFIG_BINFMT_ELF) += elfcore.o obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.oIndex: linux-2.6-lttng/kernel/trace/Makefile
===================================================================kernel/trace/Makefile +1
-1@@ -52,7 +52,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_eve endif obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o -obj-$(CONFIG_EVENT_TRACING) += power-traces.o +obj-$(CONFIG_TRACEPOINTS) += power-traces.o ifeq ($(CONFIG_TRACING),y) obj-$(CONFIG_KGDB_KDB) += trace_kdb.o endifIndex:
linux-2.6-lttng/kernel/trace/power-traces.c
===================================================================kernel/trace/power-traces.c +0
-0@@ -10,8 +10,14 @@#include <linux/sched.h>
kernel/trace/power-traces.c line 20
Quoted 10 lines
kernel/trace/power-traces.c +6
-0#include <linux/module.h> +#ifdef CONFIG_EVENT_TRACING #define CREATE_TRACE_POINTS #include <trace/events/power.h> +#else +DEFINE_TRACE (power_start); +DEFINE_TRACE (power_end); +DEFINE_TRACE (power_frequency); +#endif
The trace/events/power.h file should handle the DEFINE_TRACE() when CONFIG_EVENT_TRACING is not set. Thus, this is the wrong fix.
-- Steve
Quoted 3 lines
kernel/trace/power-traces.c +0
-0EXPORT_TRACEPOINT_SYMBOL_GPL (power_frequency);
Mathieu Desnoyers
reviewerQuoted 7 lines · * Steven Rostedt ([email protected]) wrote:
Quoted 2 lines · Mathieu Desnoyers
DEFINE_TRACEshould also exist whenCONFIG_EVENT_TRACING=n. Otherwise, setting only TRACEPOINTS=y is broken.NAK,
DEFINE_TRACEis deprecated from use outside the tracing infrastructure.
[...]
Quoted 2 lines
The
trace/events/power.hfile should handle theDEFINE_TRACE()whenCONFIG_EVENT_TRACINGis not set. Thus, this is the wrong fix.
DEFINE_TRACE() must only be done once over the whole kernel for a particular tracepoint. Currently, it is done in power-traces.c when CONFIG_EVENT_TRACING is activated. This is the only instance where trace/power.h is included with CREATE_TRACE_POINTS set.
Given that trace/power.h is inluded in more than one .c file, generating DEFINE_TRACE() when CREATE_TRACE_POINTS is not set does not work. So what alternative do you suggest ?
Thanks,
Mathieu
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
Steven Rostedt
maintainerQuoted 3 lines · Mathieu Desnoyers
Given that
trace/power.his inluded in more than one .c file, generatingDEFINE_TRACE()whenCREATE_TRACE_POINTSis not set does not work. So what alternative do you suggest ?
Right, DEFINE_TRACE should only be set when CREATE_TRACE_POINTS is set, and that is only set in the C file that the DEFINE_TRACE is to be defined.
In fact, I don't even see what bug you are trying to fix?
The file include/trace/define_trace.h converts all the TRACE_EVENTS() into DEFINE_TRACE() when CREATE_TRACE_POINTS is set. No other C file that includes power.h should have CREATE_TRACE_POINTS set. I guess if it did, the CONFIG_EVENT_TRACING would break too.
It should just work.
-- Steve
Mathieu Desnoyers
reviewerQuoted 10 lines · * Steven Rostedt ([email protected]) wrote:
Quoted 3 lines · Mathieu Desnoyers
Given that
trace/power.his inluded in more than one .c file, generatingDEFINE_TRACE()whenCREATE_TRACE_POINTSis not set does not work. So what alternative do you suggest ?Right,
DEFINE_TRACEshould only be set whenCREATE_TRACE_POINTSis set, and that is only set in the C file that theDEFINE_TRACEis to be defined.
Quoted 8 lines
In fact, I don't even see what bug you are trying to fix?
The file
include/trace/define_trace.hconverts all theTRACE_EVENTS()intoDEFINE_TRACE()whenCREATE_TRACE_POINTSis set. No other C file that includespower.hshould haveCREATE_TRACE_POINTSset. I guess if it did, theCONFIG_EVENT_TRACINGwould break too.It should just work.
This is the culprit:
kernel/trace/ is not built when CONFIG_TRACING=n kernel/trace/power-traces.o is only built when CONFIG_EVENT_TRACING=y
So the DEFINE_TRACE is never done when CONFIG_EVENT_TRACING=n or CONFIG_TRACING=n.
What you are telling me is that changing the makefiles should be enough, and I don't need to add those DEFINE_TRACE(), correct ?
Thanks,
Mathieu
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
Steven Rostedt
maintainerQuoted 2 lines · Mathieu Desnoyers
What you are telling me is that changing the makefiles should be enough, and I don't need to add those
DEFINE_TRACE(), correct ?
Correct.
-- Steve