Skip to contentSkip to conversation

irqsoff and preemptoff contexts

PATCH Mathieu Desnoyers 2 participants 3 messages Nov 11, 2015 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

irqsoff and preemptoff as names seems to imply a double negation.

Could we make it so that "1" means "enabled" instead of "off" ?

We should also add "need resched" thread flag.

Thanks,

Mathieu

Quoted 292 lines · ----- On Nov 10, 2015, at 9:20 PM, Julien Desfossez [email protected]…

---

Makefile                   |  1 +
lttng-abi.c                |  4 ++
lttng-abi.h                |  2 +
lttng-context-irqsoff.c    | 94 ++++++++++++++++++++++++++++++++++++++++++++++
lttng-context-preemptoff.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
lttng-context.c            |  8 ++++
lttng-events.h             |  2 +
7 files changed, 205 insertions(+)

create mode 100644 lttng-context-irqsoff.c
create mode 100644 lttng-context-preemptoff.c

Makefile +1 -0
index f7aa23f..efc534e 100644
@@ -41,6 +41,7 @@ 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-context-irqsoff.o lttng-context-preemptoff.o \
 			lttng-calibrate.o \
 			lttng-context-hostname.o wrapper/random.o \
 			probes/lttng.o wrapper/trace-clock.o \
lttng-abi.c +4 -0
index f6f3043..8be9b1e 100644
@@ -236,6 +236,10 @@ 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_IRQSOFF:
+		return lttng_add_irqsoff_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_PREEMPTOFF:
+		return lttng_add_preemptoff_to_ctx(ctx);
 	default:
 		return -EINVAL;
 	}
lttng-abi.h +2 -0
index a40b58f..e8b0647 100644
@@ -142,6 +142,8 @@ enum lttng_kernel_context_type {
 	LTTNG_KERNEL_CONTEXT_VPPID		= 9,
 	LTTNG_KERNEL_CONTEXT_HOSTNAME		= 10,
 	LTTNG_KERNEL_CONTEXT_CPU_ID		= 11,
+	LTTNG_KERNEL_CONTEXT_IRQSOFF		= 12,
+	LTTNG_KERNEL_CONTEXT_PREEMPTOFF		= 13,
 };
 
 struct lttng_kernel_perf_counter_ctx {
lttng-context-irqsoff.c new file +74 -0
new file mode 100644
index 0000000..2980265
@@ -0,0 +1,94 @@
+/*
+ * lttng-context-irqsoff.c
+ *
+ * LTTng irqsoff 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 irqsoff_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 irqsoff_record(struct lttng_ctx_field *field,
+		struct lib_ring_buffer_ctx *ctx,
+		struct lttng_channel *chan)
+{
+	uint8_t irqsoff = irqs_disabled();
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(irqsoff));
+	chan->ops->event_write(ctx, &irqsoff, sizeof(irqsoff));
+}
+
+static
+void irqsoff_get_value(struct lttng_ctx_field *field,
+		union lttng_ctx_value *value)
+{
+	value->s64 = irqs_disabled();
+}
+
+int lttng_add_irqsoff_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, "irqsoff")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "irqsoff";
+	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-irqsoff.c new file +1 -0
+	field->event_field.type.u.basic.integer.signedness =

lttng_is_signed_type(uint8_t);

lttng-context-irqsoff.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 = irqsoff_get_size;
+	field->record = irqsoff_record;
+	field->get_value = irqsoff_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_irqsoff_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit irqsoff Context");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+	__stringify(LTTNG_MODULES_MINOR_VERSION) "."
+	__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+	LTTNG_MODULES_EXTRAVERSION);
lttng-context-preemptoff.c new file +74 -0
new file mode 100644
index 0000000..72d60f8
@@ -0,0 +1,94 @@
+/*
+ * lttng-context-preemptoff.c
+ *
+ * LTTng preemptoff 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 preemptoff_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 preemptoff_record(struct lttng_ctx_field *field,
+		struct lib_ring_buffer_ctx *ctx,
+		struct lttng_channel *chan)
+{
+	uint8_t preemptoff = !!preempt_count();
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(preemptoff));
+	chan->ops->event_write(ctx, &preemptoff, sizeof(preemptoff));
+}
+
+static
+void preemptoff_get_value(struct lttng_ctx_field *field,
+		union lttng_ctx_value *value)
+{
+	value->s64 = !!preempt_count();
+}
+
+int lttng_add_preemptoff_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, "preemptoff")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "preemptoff";
+	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-preemptoff.c new file +1 -0
+	field->event_field.type.u.basic.integer.signedness =

lttng_is_signed_type(uint8_t);

lttng-context-preemptoff.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 = preemptoff_get_size;
+	field->record = preemptoff_record;
+	field->get_value = preemptoff_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_preemptoff_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit preemptoff Context");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+	__stringify(LTTNG_MODULES_MINOR_VERSION) "."
+	__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+	LTTNG_MODULES_EXTRAVERSION);
lttng-context.c +8 -0
index eca58ce..66e828b 100644
@@ -268,6 +268,14 @@ int lttng_context_init(void)
 	if (ret) {
 		printk(KERN_WARNING "Cannot add context lttng_add_cpu_id_to_ctx");
 	}
+	ret = lttng_add_irqsoff_to_ctx(&lttng_static_ctx);
+	if (ret) {
+		printk(KERN_WARNING "Cannot add context lttng_add_irqsoff_to_ctx");
+	}
+	ret = lttng_add_preemptoff_to_ctx(&lttng_static_ctx);
+	if (ret) {
+		printk(KERN_WARNING "Cannot add context lttng_add_preemptoff_to_ctx");
+	}
 	/* TODO: perf counters for filtering */
 	return 0;
 }
lttng-events.h +2 -0
index 234d4bc..dda22e7 100644
@@ -630,6 +630,8 @@ 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_irqsoff_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_preemptoff_to_ctx(struct lttng_ctx **ctx);
 #if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >=
 KERNEL_VERSION(2,6,33))
 int lttng_add_perf_counter_to_ctx(uint32_t type,

uint64_t config,
--
1.9.1

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 3 lines

irqsoff and preemptoff as names seems to imply a double negation.

Could we make it so that "1" means "enabled" instead of "off" ?

I was thinking of those as flags, so they would be raised when the IRQs or preemption is disabled. From my quick test with -k -a, they are at 0 most of the time.

I agree it is a double negation, I'm just not sure which option is the clearest for the users.

Julien

Quoted 311 lines

We should also add "need resched" thread flag.

Thanks,

Mathieu

Quoted 292 lines · ----- On Nov 10, 2015, at 9:20 PM, Julien Desfossez [email protected]…

---

Makefile                   |  1 +
lttng-abi.c                |  4 ++
lttng-abi.h                |  2 +
lttng-context-irqsoff.c    | 94 ++++++++++++++++++++++++++++++++++++++++++++++
lttng-context-preemptoff.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
lttng-context.c            |  8 ++++
lttng-events.h             |  2 +
7 files changed, 205 insertions(+)

create mode 100644 lttng-context-irqsoff.c
create mode 100644 lttng-context-preemptoff.c

Makefile +1 -0
index f7aa23f..efc534e 100644
@@ -41,6 +41,7 @@ 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-context-irqsoff.o lttng-context-preemptoff.o \
 			lttng-calibrate.o \
 			lttng-context-hostname.o wrapper/random.o \
 			probes/lttng.o wrapper/trace-clock.o \
lttng-abi.c +4 -0
index f6f3043..8be9b1e 100644
@@ -236,6 +236,10 @@ 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_IRQSOFF:
+		return lttng_add_irqsoff_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_PREEMPTOFF:
+		return lttng_add_preemptoff_to_ctx(ctx);
 	default:
 		return -EINVAL;
 	}
lttng-abi.h +2 -0
index a40b58f..e8b0647 100644
@@ -142,6 +142,8 @@ enum lttng_kernel_context_type {
 	LTTNG_KERNEL_CONTEXT_VPPID		= 9,
 	LTTNG_KERNEL_CONTEXT_HOSTNAME		= 10,
 	LTTNG_KERNEL_CONTEXT_CPU_ID		= 11,
+	LTTNG_KERNEL_CONTEXT_IRQSOFF		= 12,
+	LTTNG_KERNEL_CONTEXT_PREEMPTOFF		= 13,
 };
 
 struct lttng_kernel_perf_counter_ctx {
lttng-context-irqsoff.c new file +74 -0
new file mode 100644
index 0000000..2980265
@@ -0,0 +1,94 @@
+/*
+ * lttng-context-irqsoff.c
+ *
+ * LTTng irqsoff 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 irqsoff_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 irqsoff_record(struct lttng_ctx_field *field,
+		struct lib_ring_buffer_ctx *ctx,
+		struct lttng_channel *chan)
+{
+	uint8_t irqsoff = irqs_disabled();
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(irqsoff));
+	chan->ops->event_write(ctx, &irqsoff, sizeof(irqsoff));
+}
+
+static
+void irqsoff_get_value(struct lttng_ctx_field *field,
+		union lttng_ctx_value *value)
+{
+	value->s64 = irqs_disabled();
+}
+
+int lttng_add_irqsoff_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, "irqsoff")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "irqsoff";
+	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-irqsoff.c new file +1 -0
+	field->event_field.type.u.basic.integer.signedness =

lttng_is_signed_type(uint8_t);

lttng-context-irqsoff.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 = irqsoff_get_size;
+	field->record = irqsoff_record;
+	field->get_value = irqsoff_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_irqsoff_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit irqsoff Context");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+	__stringify(LTTNG_MODULES_MINOR_VERSION) "."
+	__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+	LTTNG_MODULES_EXTRAVERSION);
lttng-context-preemptoff.c new file +74 -0
new file mode 100644
index 0000000..72d60f8
@@ -0,0 +1,94 @@
+/*
+ * lttng-context-preemptoff.c
+ *
+ * LTTng preemptoff 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 preemptoff_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 preemptoff_record(struct lttng_ctx_field *field,
+		struct lib_ring_buffer_ctx *ctx,
+		struct lttng_channel *chan)
+{
+	uint8_t preemptoff = !!preempt_count();
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(preemptoff));
+	chan->ops->event_write(ctx, &preemptoff, sizeof(preemptoff));
+}
+
+static
+void preemptoff_get_value(struct lttng_ctx_field *field,
+		union lttng_ctx_value *value)
+{
+	value->s64 = !!preempt_count();
+}
+
+int lttng_add_preemptoff_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, "preemptoff")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "preemptoff";
+	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-preemptoff.c new file +1 -0
+	field->event_field.type.u.basic.integer.signedness =

lttng_is_signed_type(uint8_t);

lttng-context-preemptoff.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 = preemptoff_get_size;
+	field->record = preemptoff_record;
+	field->get_value = preemptoff_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_preemptoff_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit preemptoff Context");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+	__stringify(LTTNG_MODULES_MINOR_VERSION) "."
+	__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+	LTTNG_MODULES_EXTRAVERSION);
lttng-context.c +8 -0
index eca58ce..66e828b 100644
@@ -268,6 +268,14 @@ int lttng_context_init(void)
 	if (ret) {
 		printk(KERN_WARNING "Cannot add context lttng_add_cpu_id_to_ctx");
 	}
+	ret = lttng_add_irqsoff_to_ctx(&lttng_static_ctx);
+	if (ret) {
+		printk(KERN_WARNING "Cannot add context lttng_add_irqsoff_to_ctx");
+	}
+	ret = lttng_add_preemptoff_to_ctx(&lttng_static_ctx);
+	if (ret) {
+		printk(KERN_WARNING "Cannot add context lttng_add_preemptoff_to_ctx");
+	}
 	/* TODO: perf counters for filtering */
 	return 0;
 }
lttng-events.h +2 -0
index 234d4bc..dda22e7 100644
@@ -630,6 +630,8 @@ 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_irqsoff_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_preemptoff_to_ctx(struct lttng_ctx **ctx);
 #if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >=
 KERNEL_VERSION(2,6,33))
 int lttng_add_perf_counter_to_ctx(uint32_t type,

uint64_t config,
--
1.9.1

Signature · 8 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): 20151111160049.GE3548@sinkpad

#5 lore raw
Quoted 9 lines · ----- On Nov 11, 2015, at 11:00 AM, Julien Desfossez [email protected]…
Quoted 3 lines

irqsoff and preemptoff as names seems to imply a double negation.

Could we make it so that "1" means "enabled" instead of "off" ?

I was thinking of those as flags, so they would be raised when the IRQs or preemption is disabled. From my quick test with -k -a, they are at 0 most of the time.

I agree it is a double negation, I'm just not sure which option is the clearest for the users.

I'd go for:

interruptible
preemptible
migratable (RT kernel specific, request from tglx) need_reschedule

Thanks,

Mathieu

Quoted 315 lines

Julien

Quoted 312 lines

We should also add "need resched" thread flag.

Thanks,

Mathieu

----- On Nov 10, 2015, at 9:20 PM, Julien Desfossez [email protected]

Quoted 289 lines · wrote:

---

Makefile                   |  1 +
lttng-abi.c                |  4 ++
lttng-abi.h                |  2 +
lttng-context-irqsoff.c    | 94 ++++++++++++++++++++++++++++++++++++++++++++++
lttng-context-preemptoff.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
lttng-context.c            |  8 ++++
lttng-events.h             |  2 +
7 files changed, 205 insertions(+)

create mode 100644 lttng-context-irqsoff.c
create mode 100644 lttng-context-preemptoff.c

Makefile +1 -0
index f7aa23f..efc534e 100644
@@ -41,6 +41,7 @@ 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-context-irqsoff.o lttng-context-preemptoff.o \
 			lttng-calibrate.o \
 			lttng-context-hostname.o wrapper/random.o \
 			probes/lttng.o wrapper/trace-clock.o \
lttng-abi.c +4 -0
index f6f3043..8be9b1e 100644
@@ -236,6 +236,10 @@ 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_IRQSOFF:
+		return lttng_add_irqsoff_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_PREEMPTOFF:
+		return lttng_add_preemptoff_to_ctx(ctx);
 	default:
 		return -EINVAL;
 	}
lttng-abi.h +2 -0
index a40b58f..e8b0647 100644
@@ -142,6 +142,8 @@ enum lttng_kernel_context_type {
 	LTTNG_KERNEL_CONTEXT_VPPID		= 9,
 	LTTNG_KERNEL_CONTEXT_HOSTNAME		= 10,
 	LTTNG_KERNEL_CONTEXT_CPU_ID		= 11,
+	LTTNG_KERNEL_CONTEXT_IRQSOFF		= 12,
+	LTTNG_KERNEL_CONTEXT_PREEMPTOFF		= 13,
 };
 
 struct lttng_kernel_perf_counter_ctx {
lttng-context-irqsoff.c new file +74 -0
new file mode 100644
index 0000000..2980265
@@ -0,0 +1,94 @@
+/*
+ * lttng-context-irqsoff.c
+ *
+ * LTTng irqsoff 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 irqsoff_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 irqsoff_record(struct lttng_ctx_field *field,
+		struct lib_ring_buffer_ctx *ctx,
+		struct lttng_channel *chan)
+{
+	uint8_t irqsoff = irqs_disabled();
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(irqsoff));
+	chan->ops->event_write(ctx, &irqsoff, sizeof(irqsoff));
+}
+
+static
+void irqsoff_get_value(struct lttng_ctx_field *field,
+		union lttng_ctx_value *value)
+{
+	value->s64 = irqs_disabled();
+}
+
+int lttng_add_irqsoff_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, "irqsoff")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "irqsoff";
+	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-irqsoff.c new file +1 -0
+	field->event_field.type.u.basic.integer.signedness =

lttng_is_signed_type(uint8_t);

lttng-context-irqsoff.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 = irqsoff_get_size;
+	field->record = irqsoff_record;
+	field->get_value = irqsoff_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_irqsoff_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit irqsoff Context");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+	__stringify(LTTNG_MODULES_MINOR_VERSION) "."
+	__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+	LTTNG_MODULES_EXTRAVERSION);
lttng-context-preemptoff.c new file +74 -0
new file mode 100644
index 0000000..72d60f8
@@ -0,0 +1,94 @@
+/*
+ * lttng-context-preemptoff.c
+ *
+ * LTTng preemptoff 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 preemptoff_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 preemptoff_record(struct lttng_ctx_field *field,
+		struct lib_ring_buffer_ctx *ctx,
+		struct lttng_channel *chan)
+{
+	uint8_t preemptoff = !!preempt_count();
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(preemptoff));
+	chan->ops->event_write(ctx, &preemptoff, sizeof(preemptoff));
+}
+
+static
+void preemptoff_get_value(struct lttng_ctx_field *field,
+		union lttng_ctx_value *value)
+{
+	value->s64 = !!preempt_count();
+}
+
+int lttng_add_preemptoff_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, "preemptoff")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "preemptoff";
+	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-preemptoff.c new file +1 -0
+	field->event_field.type.u.basic.integer.signedness =

lttng_is_signed_type(uint8_t);

lttng-context-preemptoff.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 = preemptoff_get_size;
+	field->record = preemptoff_record;
+	field->get_value = preemptoff_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_preemptoff_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit preemptoff Context");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+	__stringify(LTTNG_MODULES_MINOR_VERSION) "."
+	__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+	LTTNG_MODULES_EXTRAVERSION);
lttng-context.c +8 -0
index eca58ce..66e828b 100644
@@ -268,6 +268,14 @@ int lttng_context_init(void)
 	if (ret) {
 		printk(KERN_WARNING "Cannot add context lttng_add_cpu_id_to_ctx");
 	}
+	ret = lttng_add_irqsoff_to_ctx(&lttng_static_ctx);
+	if (ret) {
+		printk(KERN_WARNING "Cannot add context lttng_add_irqsoff_to_ctx");
+	}
+	ret = lttng_add_preemptoff_to_ctx(&lttng_static_ctx);
+	if (ret) {
+		printk(KERN_WARNING "Cannot add context lttng_add_preemptoff_to_ctx");
+	}
 	/* TODO: perf counters for filtering */
 	return 0;
 }
lttng-events.h +2 -0
index 234d4bc..dda22e7 100644
@@ -630,6 +630,8 @@ 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_irqsoff_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_preemptoff_to_ctx(struct lttng_ctx **ctx);
 #if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >=
 KERNEL_VERSION(2,6,33))
 int lttng_add_perf_counter_to_ctx(uint32_t type,
Quoted 3 lines

uint64_t config,
--
1.9.1

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com