Contexts for RT debugging
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · ----- On Nov 12, 2015, at 3:49 PM, Julien Desfossez [email protected]…
Add the interruptible, preemptible,
need_reschedand migratable contexts.TODO: find a way to check if IRQs are disabled prior to the instrumentation (ex: kprobe).
I implemented the TODO, and merged into master, thanks!
Mathieu
Quoted 553 lines
Signed-off-by Julien Desfossez <[email protected]>---
Makefile | 12 ++++- lttng-abi.c | 12 +++++ lttng-abi.h | 4 ++ lttng-context-interruptible.c | 94 ++++++++++++++++++++++++++++++++++++++ lttng-context-migratable.c | 94 ++++++++++++++++++++++++++++++++++++++ lttng-context-need-reschedule.c | 94 ++++++++++++++++++++++++++++++++++++++ lttng-context-preemptible.c | 99 +++++++++++++++++++++++++++++++++++++++++ lttng-context.c | 20 +++++++++ lttng-events.h | 8 ++++ 9 files changed, 436 insertions(+), 1 deletion(-)create mode 100644
lttng-context-interruptible.ccreate mode 100644lttng-context-migratable.ccreate mode 100644lttng-context-need-reschedule.ccreate mode 100644lttng-context-preemptible.cMakefile +2
-1@@ -41,7 +41,8 @@ lttng-tracer-objs := lttng-events.o lttng-abi.o \ lttng-context-vpid.o lttng-context-tid.o \ lttng-context-vtid.o lttng-context-ppid.o \ lttng-context-vppid.o lttng-context-cpu-id.o \ - lttng-calibrate.o \ + lttng-context-interruptible.o \ + lttng-context-need-reschedule.o lttng-calibrate.o \ lttng-context-hostname.o wrapper/random.o \ probes/lttng.o wrapper/trace-clock.o \ wrapper/page_alloc.o \@@ -66,6 +67,15 @@ lttng-tracer-objs += $(shell \ echo "lttng-context-perf-counters.o" ; fi;)endif #
CONFIG_PERF_EVENTSMakefile +9
-0+ifneq ($(CONFIG_PREEMPT_RT_FULL),) +lttng-tracer-objs += lttng-context-migratable.o +lttng-tracer-objs += lttng-context-preemptible.o +endif # CONFIG_PREEMPT_RT_FULLJ + +ifneq ($(CONFIG_PREEMPT),) +lttng-tracer-objs += lttng-context-preemptible.o +endif +lttng-tracer-objs += $(shell \ if [ $(VERSION) -ge 4 \ -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 15 -a $(SUBLEVEL) -ge 0 \) ] ; then \lttng-abi.c +12
-0@@ -236,6 +236,18 @@ long lttng_abi_add_context(struct file *file,return lttng_add_hostname_to_ctx (ctx);case LTTNG_KERNEL_CONTEXT_CPU_ID :return lttng_add_cpu_id_to_ctx (ctx); +case LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE : +return lttng_add_interruptible_to_ctx (ctx); +case LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE : +return lttng_add_need_reschedule_to_ctx (ctx); +#if defined(CONFIG_PREEMPT_RT_FULL ) || defined(CONFIG_PREEMPT ) +case LTTNG_KERNEL_CONTEXT_PREEMPTIBLE : +return lttng_add_preemptible_to_ctx (ctx); +#endif +#ifdef CONFIG_PREEMPT_RT_FULL +case LTTNG_KERNEL_CONTEXT_MIGRATABLE : +return lttng_add_migratable_to_ctx (ctx); +#endif default :return -EINVAL ; }lttng-abi.h +4
-0@@ -142,6 +142,10 @@ enum lttng_kernel_context_type {LTTNG_KERNEL_CONTEXT_VPPID =9 ,LTTNG_KERNEL_CONTEXT_HOSTNAME =10 ,LTTNG_KERNEL_CONTEXT_CPU_ID =11 , +LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE =12 , +LTTNG_KERNEL_CONTEXT_PREEMPTIBLE =13 , +LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE =14 , + LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, }; struct lttng_kernel_perf_counter_ctx {lttng-context-interruptible.c new file +74
-0@@ -0,0 +1,94 @@ +/* +* lttng-context-interruptible.c +* +* LTTng interruptible context. +* +* Copyright (C) 2009-2012 Mathieu Desnoyers <[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/slab.h> +#include <linux/sched.h> +#include <linux/irqflags.h> +#include "lttng-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "lttng-tracer.h" + +static +size_t interruptible_get_size (size_t offset) +{ +size_t size =0 ; + + size +=lib_ring_buffer_align (offset,lttng_alignof (uint8_t)); + size +=sizeof (uint8_t ); +return size; +} + +static +void interruptible_record (struct lttng_ctx_field *field, +struct lib_ring_buffer_ctx *ctx, +struct lttng_channel *chan) +{ +uint8_t interruptible = !irqs_disabled (); + +lib_ring_buffer_align_ctx (ctx,lttng_alignof (interruptible)); + chan->ops->event_write (ctx, &interruptible,sizeof (interruptible)); +} + +static +void interruptible_get_value (struct lttng_ctx_field *field, +union lttng_ctx_value *value) +{ + value->s64 = !irqs_disabled (); +} + +int lttng_add_interruptible_to_ctx (struct lttng_ctx **ctx) +{ +struct lttng_ctx_field *field; + + field =lttng_append_context (ctx); +if (!field) +return -ENOMEM ; +if (lttng_find_context (*ctx,"interruptible" )) { +lttng_remove_context_field (ctx, field); +return -EEXIST ; + } + field->event_field.name ="interruptible" ; + field->event_field.type.atype = atype_integer; + field->event_field.type.u.basic.integer.size =sizeof (uint8_t ) *CHAR_BIT ; + field->event_field.type.u.basic.integer.alignment = lttng_alignof(uint8_t) *
CHAR_BIT;lttng-context-interruptible.c new file +1
-0+ field->event_field.type.u.basic.integer.signedness =
lttng_is_signed_type(uint8_t);lttng-context-interruptible.c new file +19
-0+ field->event_field.type.u.basic.integer.reverse_byte_order =0 ; + field->event_field.type.u.basic.integer.base =10 ; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = interruptible_get_size; + field->record = interruptible_record; + field->get_value = interruptible_get_value; +lttng_context_update (*ctx); +wrapper_vmalloc_sync_all (); +return 0 ; +} +EXPORT_SYMBOL_GPL (lttng_add_interruptible_to_ctx); + +MODULE_LICENSE ("GPL and additional rights" ); +MODULE_AUTHOR ("Mathieu Desnoyers" ); +MODULE_DESCRIPTION ("Linux Trace Toolkit interruptible Context" ); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION ) + LTTNG_MODULES_EXTRAVERSION);lttng-context-migratable.c new file +74
-0@@ -0,0 +1,94 @@ +/* +* lttng-context-migratable.c +* +* LTTng migratable context. +* +* Copyright (C) 2009-2012 Mathieu Desnoyers <[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/slab.h> +#include <linux/sched.h> +#include <linux/irqflags.h> +#include "lttng-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "lttng-tracer.h" + +static +size_t migratable_get_size (size_t offset) +{ +size_t size =0 ; + + size +=lib_ring_buffer_align (offset,lttng_alignof (uint8_t)); + size +=sizeof (uint8_t ); +return size; +} + +static +void migratable_record (struct lttng_ctx_field *field, +struct lib_ring_buffer_ctx *ctx, +struct lttng_channel *chan) +{ +uint8_t migratable = !__migrate_disabled (current); + +lib_ring_buffer_align_ctx (ctx,lttng_alignof (migratable)); + chan->ops->event_write (ctx, &migratable,sizeof (migratable)); +} + +static +void migratable_get_value (struct lttng_ctx_field *field, +union lttng_ctx_value *value) +{ + value->s64 = !__migrate_disabled (current); +} + +int lttng_add_migratable_to_ctx (struct lttng_ctx **ctx) +{ +struct lttng_ctx_field *field; + + field =lttng_append_context (ctx); +if (!field) +return -ENOMEM ; +if (lttng_find_context (*ctx,"migratable" )) { +lttng_remove_context_field (ctx, field); +return -EEXIST ; + } + field->event_field.name ="migratable" ; + field->event_field.type.atype = atype_integer; + field->event_field.type.u.basic.integer.size =sizeof (uint8_t ) *CHAR_BIT ; + field->event_field.type.u.basic.integer.alignment = lttng_alignof(uint8_t) *
CHAR_BIT;lttng-context-migratable.c new file +1
-0+ field->event_field.type.u.basic.integer.signedness =
lttng_is_signed_type(uint8_t);lttng-context-migratable.c new file +19
-0+ field->event_field.type.u.basic.integer.reverse_byte_order =0 ; + field->event_field.type.u.basic.integer.base =10 ; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = migratable_get_size; + field->record = migratable_record; + field->get_value = migratable_get_value; +lttng_context_update (*ctx); +wrapper_vmalloc_sync_all (); +return 0 ; +} +EXPORT_SYMBOL_GPL (lttng_add_migratable_to_ctx); + +MODULE_LICENSE ("GPL and additional rights" ); +MODULE_AUTHOR ("Mathieu Desnoyers" ); +MODULE_DESCRIPTION ("Linux Trace Toolkit migratable Context" ); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION ) + LTTNG_MODULES_EXTRAVERSION);lttng-context-need-reschedule.c new file +74
-0@@ -0,0 +1,94 @@ +/* +* lttng-context-need_reschedule.c +* +* LTTng need_reschedule context. +* +* Copyright (C) 2009-2012 Mathieu Desnoyers <[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/slab.h> +#include <linux/sched.h> +#include <linux/irqflags.h> +#include "lttng-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "lttng-tracer.h" + +static +size_t need_reschedule_get_size (size_t offset) +{ +size_t size =0 ; + + size +=lib_ring_buffer_align (offset,lttng_alignof (uint8_t)); + size +=sizeof (uint8_t ); +return size; +} + +static +void need_reschedule_record (struct lttng_ctx_field *field, +struct lib_ring_buffer_ctx *ctx, +struct lttng_channel *chan) +{ +uint8_t need_reschedule =test_tsk_need_resched (current); + +lib_ring_buffer_align_ctx (ctx,lttng_alignof (need_reschedule)); + chan->ops->event_write (ctx, &need_reschedule,sizeof (need_reschedule)); +} + +static +void need_reschedule_get_value (struct lttng_ctx_field *field, +union lttng_ctx_value *value) +{ + value->s64 =test_tsk_need_resched (current);; +} + +int lttng_add_need_reschedule_to_ctx (struct lttng_ctx **ctx) +{ +struct lttng_ctx_field *field; + + field =lttng_append_context (ctx); +if (!field) +return -ENOMEM ; +if (lttng_find_context (*ctx,"need_reschedule" )) { +lttng_remove_context_field (ctx, field); +return -EEXIST ; + } + field->event_field.name ="need_reschedule" ; + field->event_field.type.atype = atype_integer; + field->event_field.type.u.basic.integer.size =sizeof (uint8_t ) *CHAR_BIT ; + field->event_field.type.u.basic.integer.alignment = lttng_alignof(uint8_t) *
CHAR_BIT;lttng-context-need-reschedule.c new file +1
-0+ field->event_field.type.u.basic.integer.signedness =
lttng_is_signed_type(uint8_t);lttng-context-need-reschedule.c new file +19
-0+ field->event_field.type.u.basic.integer.reverse_byte_order =0 ; + field->event_field.type.u.basic.integer.base =10 ; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = need_reschedule_get_size; + field->record = need_reschedule_record; + field->get_value = need_reschedule_get_value; +lttng_context_update (*ctx); +wrapper_vmalloc_sync_all (); +return 0 ; +} +EXPORT_SYMBOL_GPL (lttng_add_need_reschedule_to_ctx); + +MODULE_LICENSE ("GPL and additional rights" ); +MODULE_AUTHOR ("Mathieu Desnoyers" ); +MODULE_DESCRIPTION ("Linux Trace Toolkit need_reschedule Context" ); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION ) + LTTNG_MODULES_EXTRAVERSION);lttng-context-preemptible.c new file +79
-0@@ -0,0 +1,99 @@ +/* +* lttng-context-preemptible.c +* +* LTTng preemptible context. +* +* Copyright (C) 2009-2012 Mathieu Desnoyers <[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/slab.h> +#include <linux/sched.h> +#include <linux/irqflags.h> +#include "lttng-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "lttng-tracer.h" + +static +size_t preemptible_get_size (size_t offset) +{ +size_t size =0 ; + + size +=lib_ring_buffer_align (offset,lttng_alignof (uint8_t)); + size +=sizeof (uint8_t ); +return size; +} + +static +void preemptible_record (struct lttng_ctx_field *field, +struct lib_ring_buffer_ctx *ctx, +struct lttng_channel *chan) +{ +uint8_t preemptible; + +/* +* The tracing adds 2 levels of preempt_disable. +*/ +WARN_ON_ONCE (preempt_count () <2 ); + preemptible = ((preempt_count () -2 ) ==0 ); +lib_ring_buffer_align_ctx (ctx,lttng_alignof (preemptible)); + chan->ops->event_write (ctx, &preemptible,sizeof (preemptible)); +} + +static +void preemptible_get_value (struct lttng_ctx_field *field, +union lttng_ctx_value *value) +{ + value->s64 = ((preempt_count () -2 ) ==0 ); +} + +int lttng_add_preemptible_to_ctx (struct lttng_ctx **ctx) +{ +struct lttng_ctx_field *field; + + field =lttng_append_context (ctx); +if (!field) +return -ENOMEM ; +if (lttng_find_context (*ctx,"preemptible" )) { +lttng_remove_context_field (ctx, field); +return -EEXIST ; + } + field->event_field.name ="preemptible" ; + field->event_field.type.atype = atype_integer; + field->event_field.type.u.basic.integer.size =sizeof (uint8_t ) *CHAR_BIT ; + field->event_field.type.u.basic.integer.alignment = lttng_alignof(uint8_t) *
CHAR_BIT;lttng-context-preemptible.c new file +1
-0+ field->event_field.type.u.basic.integer.signedness =
lttng_is_signed_type(uint8_t);lttng-context-preemptible.c new file +19
-0+ field->event_field.type.u.basic.integer.reverse_byte_order =0 ; + field->event_field.type.u.basic.integer.base =10 ; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = preemptible_get_size; + field->record = preemptible_record; + field->get_value = preemptible_get_value; +lttng_context_update (*ctx); +wrapper_vmalloc_sync_all (); +return 0 ; +} +EXPORT_SYMBOL_GPL (lttng_add_preemptible_to_ctx); + +MODULE_LICENSE ("GPL and additional rights" ); +MODULE_AUTHOR ("Mathieu Desnoyers" ); +MODULE_DESCRIPTION ("Linux Trace Toolkit preemptible Context" ); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION ) + LTTNG_MODULES_EXTRAVERSION);lttng-context.c +20
-0@@ -268,6 +268,26 @@ int lttng_context_init(void)if (ret) {printk (KERN_WARNING "Cannot add context lttng_add_cpu_id_to_ctx" ); } + ret =lttng_add_interruptible_to_ctx (<tng_static_ctx); +if (ret) { +printk (KERN_WARNING "Cannot add context lttng_add_interruptible_to_ctx" ); + } + ret =lttng_add_need_reschedule_to_ctx (<tng_static_ctx); +if (ret) { +printk (KERN_WARNING "Cannot add context lttng_add_need_reschedule_to_ctx" ); + } +#if defined(CONFIG_PREEMPT_RT_FULL ) || defined(CONFIG_PREEMPT ) + ret =lttng_add_preemptible_to_ctx (<tng_static_ctx); +if (ret) { +printk (KERN_WARNING "Cannot add context lttng_add_preemptible_to_ctx" ); + } +#endif +#ifdef CONFIG_PREEMPT_RT_FULL + ret =lttng_add_migratable_to_ctx (<tng_static_ctx); +if (ret) { +printk (KERN_WARNING "Cannot add context lttng_add_migratable_to_ctx" ); + } +#endif /* TODO: perf counters for filtering */ return 0 ; }lttng-events.h +8
-0@@ -630,6 +630,14 @@ int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);int lttng_add_ppid_to_ctx (struct lttng_ctx **ctx);int lttng_add_vppid_to_ctx (struct lttng_ctx **ctx);int lttng_add_hostname_to_ctx (struct lttng_ctx **ctx); +int lttng_add_interruptible_to_ctx (struct lttng_ctx **ctx); +int lttng_add_need_reschedule_to_ctx (struct lttng_ctx **ctx); +#if defined(CONFIG_PREEMPT_RT_FULL ) || defined(CONFIG_PREEMPT ) +int lttng_add_preemptible_to_ctx (struct lttng_ctx **ctx); +#endif +#ifdef CONFIG_PREEMPT_RT_FULL +int lttng_add_migratable_to_ctx (struct lttng_ctx **ctx); +#endif #if defined(CONFIG_PERF_EVENTS ) && (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,33 )) int lttng_add_perf_counter_to_ctx(uint32_t type,
uint64_tconfig,
--
1.9.1
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com