All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Philippe Gerum <rpm@xenomai.org>
Cc: adeos-main <adeos-main@gna.org>
Subject: [Adeos-main] [PATCH 2/2] output minimum function trace overhead
Date: Mon, 08 Jan 2007 23:21:18 +0100	[thread overview]
Message-ID: <45A2C3DE.309@domain.hid> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 250 bytes --]

This patch calibrates the best-case overhead a function trace point
introduces and dumps the result at the beginning of each tracer output.
Should give the reader of some trace an idea what the instrumentation
/at least/ costed per entry.

Jan

[-- Attachment #1.2: calc-trace-overhead.patch --]
[-- Type: text/plain, Size: 2770 bytes --]

---
 kernel/ipipe/tracer.c |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

Index: linux-2.6.19-ipipe/kernel/ipipe/tracer.c
===================================================================
--- linux-2.6.19-ipipe.orig/kernel/ipipe/tracer.c
+++ linux-2.6.19-ipipe/kernel/ipipe/tracer.c
@@ -129,6 +129,7 @@ static int pre_trace = IPIPE_DEFAULT_PRE
 static int post_trace = IPIPE_DEFAULT_POST_TRACE;
 static int back_trace = IPIPE_DEFAULT_BACK_TRACE;
 static int verbose_trace;
+static unsigned long trace_overhead;
 
 static DEFINE_MUTEX(out_mutex);
 static struct ipipe_trace_path *print_path;
@@ -824,6 +825,9 @@ static void __ipipe_print_dbgwarning(str
 
 static void __ipipe_print_headline(struct seq_file *m)
 {
+	seq_printf(m, "Calibrated minimum trace-point overhead: %lu.%03lu "
+		   "us\n\n", trace_overhead/1000, trace_overhead%1000);
+
 	if (verbose_trace) {
 		const char *name[4] = { [0 ... 3] = "<unused>" };
 		struct list_head *pos;
@@ -917,7 +921,7 @@ static void *__ipipe_max_prtrace_start(s
 			UTS_RELEASE, IPIPE_ARCH_STRING);
 		__ipipe_print_dbgwarning(m);
 		seq_printf(m, "Begin: %lld cycles, Trace Points: %d (-%d/+%d), "
-			"Length: %lu us\n\n",
+			"Length: %lu us\n",
 			print_path->point[print_path->begin].timestamp,
 			points, print_pre_trace, print_post_trace, length_usecs);
 		__ipipe_print_headline(m);
@@ -1073,7 +1077,7 @@ static void *__ipipe_frozen_prtrace_star
 			"------\n",
 			UTS_RELEASE, IPIPE_ARCH_STRING);
 		__ipipe_print_dbgwarning(m);
-		seq_printf(m, "Freeze: %lld cycles, Trace Points: %d (+%d)\n\n",
+		seq_printf(m, "Freeze: %lld cycles, Trace Points: %d (+%d)\n",
 			print_path->point[print_path->begin].timestamp,
 			print_pre_trace+1, print_post_trace);
 		__ipipe_print_headline(m);
@@ -1200,6 +1204,8 @@ void __init __ipipe_init_tracer(void)
 {
 	struct proc_dir_entry *trace_dir;
 	struct proc_dir_entry *entry;
+	unsigned long long start, end, min = ULLONG_MAX;
+	int i;
 #ifdef CONFIG_IPIPE_TRACE_VMALLOC
 	int cpu, path;
 
@@ -1221,6 +1227,21 @@ void __init __ipipe_init_tracer(void)
 	ipipe_trace_enable = CONFIG_IPIPE_TRACE_ENABLE_VALUE;
 #endif /* CONFIG_IPIPE_TRACE_VMALLOC */
 
+	/* Calculate minimum overhead of __ipipe_trace() */
+	local_irq_disable_hw();
+	for (i = 0; i < 100; i++) {
+		ipipe_read_tsc(start);
+		__ipipe_trace(IPIPE_TRACE_FUNC, __BUILTIN_RETURN_ADDRESS0,
+			      __BUILTIN_RETURN_ADDRESS1, 0);
+		ipipe_read_tsc(end);
+
+		end -= start;
+		if (end < min)
+			min = end;
+	}
+	local_irq_enable_hw();
+	trace_overhead = ipipe_tsc2ns(min);
+
 	trace_dir = create_proc_entry("trace", S_IFDIR, ipipe_proc_root);
 
 	entry = create_proc_entry("max", 0644, trace_dir);

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

                 reply	other threads:[~2007-01-08 22:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45A2C3DE.309@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=adeos-main@gna.org \
    --cc=rpm@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.