Skip to contentSkip to conversation

tracing: Some last minute updates for 3.20

PATCH New Steven Rostedt 1 participant 6 messages Feb 10, 2015

Subsystems (2)
lore
Share & tools
lore
author maintainer
#5 lore raw

PATCH 5/5 tracing: Fix unmapping loop in tracing_mark_write

In reply to Steven Rostedt

From: Vikram Mulukutla <[email protected]>

Commit 6edb2a8a385f0cdef51dae37ff23e74d76d8a6ce introduced an array map_pages that contains the addresses returned by kmap_atomic. However, when unmapping those pages, map_pages[0] is unmapped before map_pages[1], breaking the nesting requirement as specified in the documentation for kmap_atomic/kunmap_atomic.

This was caught by the highmem debug code present in kunmap_atomic. Fix the loop to do the unmapping properly.

---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
index 5afce60e1b68..2078b86750e0 100644
@@ -4928,7 +4928,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
 	*fpos += written;
 
  out_unlock:
-	for (i = 0; i < nr_pages; i++){
+	for (i = nr_pages - 1; i >= 0; i--) {
 		kunmap_atomic(map_page[i]);
 		put_page(pages[i]);
 	}
Signature · 1 line
2.1.4
author maintainer
#2 lore raw

PATCH 2/5 tracing: Add TRACE_EVENT_CONDITION sample

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

The sample code lacks an example of TRACE_EVENT_CONDITION, and it has been expressed to me that this feature for TRACE_EVENT is not well known and not used when it could be.

---
 samples/trace_events/trace-events-sample.c |  3 ++
 samples/trace_events/trace-events-sample.h | 58 ++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
samples/trace_events/trace-events-sample.c +3 -0
index 16c15c08ed38..c396a49b5d78 100644
@@ -31,8 +31,11 @@ static void simple_thread_func(int cnt)
 		array[i] = i + 1;
 	array[i] = 0;
 
+	/* Silly tracepoints */
 	trace_foo_bar("hello", cnt, array, random_strings[len],
 		      tsk_cpus_allowed(current));
+
+	trace_foo_bar_with_cond("Some times print", cnt);
 }
 
 static int simple_thread(void *arg)
samples/trace_events/trace-events-sample.h +58 -0

64 lines not on this page · raw message

Signature · 1 line
2.1.4
author maintainer
#1 lore raw

PATCH 1/5 tracing: Update the TRACE_EVENT fields available in the sample code

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

The sample code in samples/trace_events/ is extremely out of date and does not show all the new fields that have been added since the sample code was written. As most people are unaware of these new fields, adding sample code and explanations of those fields should help out.

---
 samples/trace_events/trace-events-sample.c |  19 +++-
 samples/trace_events/trace-events-sample.h | 145 ++++++++++++++++++++++++++---
 2 files changed, 150 insertions(+), 14 deletions(-)
samples/trace_events/trace-events-sample.c +18 -1
index aabc4e970911..16c15c08ed38 100644
@@ -10,12 +10,29 @@
 #define CREATE_TRACE_POINTS
 #include "trace-events-sample.h"
 
+static const char *random_strings[] = {
+	"Mother Goose",
+	"Snoopy",
+	"Gandalf",
+	"Frodo",
+	"One ring to rule them all"
+};
 
 static void simple_thread_func(int cnt)
 {
+	int array[6];
+	int len = cnt % 5;
+	int i;
+
 	set_current_state(TASK_INTERRUPTIBLE);
 	schedule_timeout(HZ);
-	trace_foo_bar("hello", cnt);
+
+	for (i = 0; i < len; i++)
+		array[i] = i + 1;
+	array[i] = 0;
+
+	trace_foo_bar("hello", cnt, array, random_strings[len],
+		      tsk_cpus_allowed(current));
 }
 
 static int simple_thread(void *arg)
samples/trace_events/trace-events-sample.h +132 -13

182 lines not on this page · raw message

Signature · 1 line
2.1.4

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Some last minute updates for 3.20

Some last minute updates for this merge window. Mostly documentantion and sample code changes. Nothing risky. But they went through my entire test suite anyway.

There is also an urgent patch that got lost in my inbox that I added.

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: 7215853e985a4bef1a6c14e00e89dfec84f1e457

Steven Rostedt (Red Hat) (4):
tracing: Update the TRACE_EVENT fields available in the sample code
tracing: Add TRACE_EVENT_CONDITION sample
tracing: Add TRACE_EVENT_FN example
tracing: Add samples of DECLARE_EVENT_CLASS() and DEFINE_EVENT()

Vikram Mulukutla (1):
tracing: Fix unmapping loop in tracing_mark_write

----

 kernel/trace/trace.c                       |   2 +-
 samples/trace_events/trace-events-sample.c |  80 ++++++-
 samples/trace_events/trace-events-sample.h | 328 +++++++++++++++++++++++++++--
 3 files changed, 395 insertions(+), 15 deletions(-)
author maintainer
#3 lore raw

PATCH 3/5 tracing: Add TRACE_EVENT_FN example

From: "Steven Rostedt (Red Hat)" <[email protected]>

If a function should be called before a tracepoint is enabled and/or after it is disabled, the TRACE_EVENT_FN() serves this purpose. But it is not well documented. Having it as a sample would help developers to know how to use it.

---
 samples/trace_events/trace-events-sample.c | 51 ++++++++++++++++++++++++++++++
 samples/trace_events/trace-events-sample.h | 44 ++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)
samples/trace_events/trace-events-sample.c +51 -0
index c396a49b5d78..39d4484aef53 100644
@@ -49,6 +49,52 @@ static int simple_thread(void *arg)
 }
 
 static struct task_struct *simple_tsk;
+static struct task_struct *simple_tsk_fn;
+
+static void simple_thread_func_fn(int cnt)
+{
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(HZ);
+
+	/* More silly tracepoints */
+	trace_foo_bar_with_fn("Look at me", cnt);
+}
+
+static int simple_thread_fn(void *arg)
+{
+	int cnt = 0;
+
+	while (!kthread_should_stop())
+		simple_thread_func_fn(cnt++);
+
+	return 0;
+}
+
+static DEFINE_MUTEX(thread_mutex);
+
+void foo_bar_reg(void)
+{
+	pr_info("Starting thread for foo_bar_fn\n");
+	/*
+	 * We shouldn't be able to start a trace when the module is
+	 * unloading (there's other locks to prevent that). But
+	 * for consistency sake, we still take the thread_mutex.
+	 */
+	mutex_lock(&thread_mutex);
+	simple_tsk_fn = kthread_run(simple_thread_fn, NULL, "event-sample-fn");
+	mutex_unlock(&thread_mutex);
+}
+
+void foo_bar_unreg(void)
+{
+	pr_info("Killing thread for foo_bar_fn\n");
+	/* protect against module unloading */
+	mutex_lock(&thread_mutex);
+	if (simple_tsk_fn)
+		kthread_stop(simple_tsk_fn);
+	simple_tsk_fn = NULL;
+	mutex_unlock(&thread_mutex);
+}
 
 static int __init trace_event_init(void)
 {
@@ -62,6 +108,11 @@ static int __init trace_event_init(void)
 static void __exit trace_event_exit(void)
 {
 	kthread_stop(simple_tsk);
+	mutex_lock(&thread_mutex);
+	if (simple_tsk_fn)
+		kthread_stop(simple_tsk_fn);
+	simple_tsk_fn = NULL;
+	mutex_unlock(&thread_mutex);
 }
 
 module_init(trace_event_init);
samples/trace_events/trace-events-sample.h +44 -0

50 lines not on this page · raw message

Signature · 1 line
2.1.4
author maintainer
#4 lore raw

PATCH 4/5 tracing: Add samples of DECLARE_EVENT_CLASS() and DEFINE_EVENT()

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

Add to samples/trace_events/ the macros DECLARE_EVENT_CLASS() and DEFINE_EVENT() and recommend using them over multiple TRACE_EVENT() macros if the multiple events have the same format.

---
 samples/trace_events/trace-events-sample.c |  7 +++
 samples/trace_events/trace-events-sample.h | 81 ++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)
samples/trace_events/trace-events-sample.c +7 -0
index 39d4484aef53..880a7d1d27d2 100644
@@ -35,7 +35,13 @@ static void simple_thread_func(int cnt)
 	trace_foo_bar("hello", cnt, array, random_strings[len],
 		      tsk_cpus_allowed(current));
 
+	trace_foo_with_template_simple("HELLO", cnt);
+
 	trace_foo_bar_with_cond("Some times print", cnt);
+
+	trace_foo_with_template_cond("prints other times", cnt);
+
+	trace_foo_with_template_print("I have to be different", cnt);
 }
 
 static int simple_thread(void *arg)
@@ -58,6 +64,7 @@ static void simple_thread_func_fn(int cnt)
 
 	/* More silly tracepoints */
 	trace_foo_bar_with_fn("Look at me", cnt);
+	trace_foo_with_template_fn("Look at me too", cnt);
 }
 
 static int simple_thread_fn(void *arg)
samples/trace_events/trace-events-sample.h +81 -0

87 lines not on this page · raw message

Signature · 1 line
2.1.4