Add preemptirq instrumentation
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 173 lines · Michael Jeanson
The tracepoints were introduced in kernl 4.15 alongside the config option
PREEMPTIRQ_EVENTS.This enables tracing of disable and enable events for preemption and irqs. For tracing preempt disable/enable events,
DEBUG_PREEMPTmust be enabled. For tracing irq disable/enable events,PROVE_LOCKINGmust be disabled.See upstream commit:
commit
d59158162e032917a428704160a2063a02405ec6
Author: Joel Fernandes <[email protected]>
Date: Tue Oct 10 15:51:37 2017 -0700tracing: Add support for preempt and irq enable/disable events
Preempt and irq trace events can be used for tracing the start and end of an atomic section which can be used by a trace viewer like systrace to graphically view the start and end of an atomic section and correlate them with latencies and scheduling issues.
This also serves as a prelude to using synthetic events or probes to rewrite the preempt and irqsoff tracers, along with numerous benefits of using trace events features for these events.
Signed-off-by Michael Jeanson <[email protected]>--- instrumentation/events/lttng-module/preemptirq.h | 72 ++++++++++++++++++++++++ probes/Kbuild | 4 ++ probes/lttng-probe-preemptirq.c | 49 ++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 instrumentation/events/lttng-module/preemptirq.h create mode 100644 probes/lttng-probe-preemptirq.cinstrumentation/events/lttng-module/preemptirq.h new file +72
-0@@ -0,0 +1,72 @@ +#ifdef CONFIG_PREEMPTIRQ_EVENTS + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM preemptirq + +#if !defined(LTTNG_TRACE_PREEMPTIRQ_H ) || defined(TRACE_HEADER_MULTI_READ ) +#define LTTNG_TRACE_PREEMPTIRQ_H + +#include <linux/ktime.h> +#include <linux/string.h> +#include <asm/sections.h> +#include <probes/lttng-tracepoint-event.h> + + +LTTNG_TRACEPOINT_EVENT_CLASS (preemptirq_template, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip), + +TP_FIELDS ( + ctf_integer(unsigned long, caller, ip) + ctf_integer(unsigned long, parent, parent_ip) + ) +) + +#ifndef CONFIG_PROVE_LOCKING +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, irq_disable, + + preemptirq_irq_disable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, irq_enable, + + preemptirq_irq_enable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) +#endif /* !CONFIG_PROVE_LOCKING */ + +#ifdef CONFIG_DEBUG_PREEMPT +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, preempt_disable, + + preemptirq_preempt_disable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, preempt_enable, + + preemptirq_preempt_enable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) +#endif /* CONFIG_DEBUG_PREEMPT */ + +#endif /* LTTNG_TRACE_PREEMPTIRQ_H */ + +/* This part must be outside protection */ +#include <probes/define_trace.h> + +#endif /* CONFIG_PREEMPTIRQ_EVENTS */ probes/Kbuild +4
-0@@ -266,4 +266,8 @@ ifneq ($(CONFIG_DYNAMIC_FTRACE),) endif endif # CONFIG_DYNAMIC_FTRACE +ifneq ($(CONFIG_PREEMPTIRQ_EVENTS),) + obj-$(CONFIG_LTTNG) += lttng-probe-preemptirq.o +endif # CONFIG_PREEMPTIRQ_EVENTS + # vim:syntax=makeprobes/lttng-probe-preemptirq.c new file +39
-0@@ -0,0 +1,49 @@ +/* +* probes/lttng-probe-preemptirq.c +* +* LTTng preemptirq probes. +* +* Copyright (C) 2010-2012 Mathieu Desnoyers <[email protected]> +* 2017 Michael Jeanson <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; only +* version 2.1 of the License. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <linux/module.h> +#include <linux/uaccess.h> +#include <lttng-tracer.h> + +/* +* Create the tracepoint static inlines from the kernel to validate that our +* trace event macros match the kernel we run on. +*/ +#include <trace/events/preemptirq.h> + +/* +* Create LTTng tracepoint probes. +*/ +#define LTTNG_PACKAGE_BUILD +#define CREATE_TRACE_POINTS +#define TRACE_INCLUDE_PATH instrumentation/events/lttng-module
probes/lttng-probe-preemptirq.c line 49
Quoted 10 lines
probes/lttng-probe-preemptirq.c new file +10
-0+ +#include <instrumentation/events/lttng-module/preemptirq.h> + +MODULE_LICENSE ("GPL and additional rights" ); +MODULE_AUTHOR ("Michael Jeanson <[email protected]>" ); +MODULE_DESCRIPTION ("LTTng preemptirq probes" ); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION ) + LTTNG_MODULES_EXTRAVERSION);
This patch should of been submitted as an RFC.
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Quoted 56 lines · ----- On Dec 19, 2017, at 4:10 PM, Michael Jeanson [email protected] wrote:
The tracepoints were introduced in kernl 4.15 alongside the config option
PREEMPTIRQ_EVENTS.This enables tracing of disable and enable events for preemption and irqs. For tracing preempt disable/enable events,
DEBUG_PREEMPTmust be enabled. For tracing irq disable/enable events,PROVE_LOCKINGmust be disabled.See upstream commit:
commit
d59158162e032917a428704160a2063a02405ec6
Author: Joel Fernandes <[email protected]>
Date: Tue Oct 10 15:51:37 2017 -0700tracing: Add support for preempt and irq enable/disable events
Preempt and irq trace events can be used for tracing the start and end of an atomic section which can be used by a trace viewer like systrace to graphically view the start and end of an atomic section and correlate them with latencies and scheduling issues.
This also serves as a prelude to using synthetic events or probes to rewrite the preempt and irqsoff tracers, along with numerous benefits of using trace events features for these events.
Signed-off-by Michael Jeanson <[email protected]>---
instrumentation/events/lttng-module/preemptirq.h | 72 ++++++++++++++++++++++++ probes/Kbuild | 4 ++ probes/lttng-probe-preemptirq.c | 49 ++++++++++++++++ 3 files changed, 125 insertions(+)create mode 100644
instrumentation/events/lttng-module/preemptirq.hcreate mode 100644probes/lttng-probe-preemptirq.cinstrumentation/events/lttng-module/preemptirq.h new file +13
-0@@ -0,0 +1,72 @@ +#ifdef CONFIG_PREEMPTIRQ_EVENTS + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM preemptirq + +#if !defined(LTTNG_TRACE_PREEMPTIRQ_H ) || defined(TRACE_HEADER_MULTI_READ ) +#define LTTNG_TRACE_PREEMPTIRQ_H + +#include <linux/ktime.h> +#include <linux/string.h> +#include <asm/sections.h> +#include <probes/lttng-tracepoint-event.h> +
instrumentation/events/lttng-module/preemptirq.h line 23
Quoted 10 lines
instrumentation/events/lttng-module/preemptirq.h new file +10
-0+ +LTTNG_TRACEPOINT_EVENT_CLASS(preemptirq_template, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + + TP_ARGS(ip, parent_ip), + + TP_FIELDS( + ctf_integer(unsigned long, caller, ip) + ctf_integer(unsigned long, parent, parent_ip)
We may want ctf_integer_hex() for both fields here. I'll edit the patch and merge it into lttng-modules master branch.
Should we also send a patch to lttng-tools so it loads this probe module optionally ?
Thanks,
Mathieu
Quoted 119 lines
instrumentation/events/lttng-module/preemptirq.h new file +49
-0+ ) +) + +#ifndef CONFIG_PROVE_LOCKING +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, irq_disable, + + preemptirq_irq_disable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, irq_enable, + + preemptirq_irq_enable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) +#endif /* !CONFIG_PROVE_LOCKING */ + +#ifdef CONFIG_DEBUG_PREEMPT +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, preempt_disable, + + preemptirq_preempt_disable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP (preemptirq_template, preempt_enable, + + preemptirq_preempt_enable, + + TP_PROTO(unsigned long ip, unsigned long parent_ip), + +TP_ARGS (ip, parent_ip) +) +#endif /* CONFIG_DEBUG_PREEMPT */ + +#endif /* LTTNG_TRACE_PREEMPTIRQ_H */ + +/* This part must be outside protection */ +#include <probes/define_trace.h> + +#endif /* CONFIG_PREEMPTIRQ_EVENTS */ probes/Kbuild +0
-0@@ -266,4 +266,8 @@ ifneq ($(CONFIG_DYNAMIC_FTRACE),) endifendif #
CONFIG_DYNAMIC_FTRACEprobes/Kbuild +4
-0+ifneq ($(CONFIG_PREEMPTIRQ_EVENTS),) + obj-$(CONFIG_LTTNG) += lttng-probe-preemptirq.o +endif # CONFIG_PREEMPTIRQ_EVENTS +# vim:syntax=make
probes/lttng-probe-preemptirq.c new file +49
-1@@ -0,0 +1,49 @@ +/* +* probes/lttng-probe-preemptirq.c +* +* LTTng preemptirq probes. +* +* Copyright (C) 2010-2012 Mathieu Desnoyers <[email protected]> +* 2017 Michael Jeanson <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; only +* version 2.1 of the License. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <linux/module.h> +#include <linux/uaccess.h> +#include <lttng-tracer.h> + +/* +* Create the tracepoint static inlines from the kernel to validate that our +* trace event macros match the kernel we run on. +*/ +#include <trace/events/preemptirq.h> + +/* +* Create LTTng tracepoint probes. +*/ +#define LTTNG_PACKAGE_BUILD +#define CREATE_TRACE_POINTS +#define TRACE_INCLUDE_PATH instrumentation/events/lttng-module + +#include <instrumentation/events/lttng-module/preemptirq.h> + +MODULE_LICENSE ("GPL and additional rights" ); +MODULE_AUTHOR ("Michael Jeanson <[email protected]>" ); +MODULE_DESCRIPTION ("LTTng preemptirq probes" ); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION ) + LTTNG_MODULES_EXTRAVERSION); --2.7.4
Signature · 7 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev