All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [PATCH] use vmalloc'ed trace buffer
@ 2006-06-15 11:20 Jan Kiszka
  2006-06-15 14:57 ` [Xenomai-core] " Philippe Gerum
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2006-06-15 11:20 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: adeos-main, xenomai-core


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

Hi Philippe,

here is the cleaned up and configurable version of my vmalloc hack for
the I-pipe tracer.

As it has a slight performance impact to use virtual memory for the
trace buffer (running "hackbench 10" in parallel to "latency -p 100" on
a 266 MHz P-MMX: 227 vs. 244 s hackbench runtime), I left this option
off by default. If there is any kind of CONFIG combination that cries
for default on, we can easily add it.

Jan

[-- Attachment #1.2: tracer-dyn-buffer-v2.patch --]
[-- Type: text/plain, Size: 4234 bytes --]

Index: linux-2.6.16.1/kernel/ipipe/Kconfig
===================================================================
--- linux-2.6.16.1.orig/kernel/ipipe/Kconfig
+++ linux-2.6.16.1/kernel/ipipe/Kconfig
@@ -34,3 +34,12 @@ config IPIPE_TRACE_SHIFT
 	---help---
 	  The number of trace points to hold tracing data for each
 	  trace path, as a power of 2.
+
+config IPIPE_TRACE_VMALLOC
+	bool "Use vmalloc'ed trace buffer"
+	depends on IPIPE_TRACE
+	---help---
+	  Instead of reserving static kernel data, the required buffer
+	  is allocated via vmalloc during boot-up when this option is
+	  enabled. This can help to start systems that are low on memory,
+	  but it slightly degrades overall performance.
Index: linux-2.6.16.1/kernel/ipipe/tracer.c
===================================================================
--- linux-2.6.16.1.orig/kernel/ipipe/tracer.c
+++ linux-2.6.16.1/kernel/ipipe/tracer.c
@@ -2,7 +2,7 @@
  * kernel/ipipe/tracer.c
  *
  * Copyright (C) 2005 Luotao Fu.
- *               2005 Jan Kiszka.
+ *               2005, 2006 Jan Kiszka.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 #include <linux/seq_file.h>
 #include <linux/proc_fs.h>
 #include <linux/ctype.h>
+#include <linux/vmalloc.h>
 #include <linux/ipipe_trace.h>
 #include <asm/uaccess.h>
 
@@ -86,7 +87,13 @@ enum ipipe_trace_type
 };
 
 
-int ipipe_trace_enable = 1;
+#ifdef CONFIG_IPIPE_TRACE_VMALLOC
+#define IPIPE_DEFAULT_TRACE_STATE   0
+
+static struct ipipe_trace_path *trace_paths[NR_CPUS];
+
+#else /* !CONFIG_IPIPE_TRACE_VMALLOC */
+#define IPIPE_DEFAULT_TRACE_STATE   1
 
 static struct ipipe_trace_path trace_paths[NR_CPUS][IPIPE_TRACE_PATHS] =
 	{ [0 ... NR_CPUS-1] =
@@ -94,6 +101,10 @@ static struct ipipe_trace_path trace_pat
 			{ .begin = -1, .end = -1 }
 		}
 	};
+#endif /* CONFIG_IPIPE_TRACE_VMALLOC */
+
+int ipipe_trace_enable = IPIPE_DEFAULT_TRACE_STATE;
+
 static int active_path[NR_CPUS] =
 	{ [0 ... NR_CPUS-1] = IPIPE_DEFAULT_ACTIVE };
 static int max_path[NR_CPUS] =
@@ -1097,10 +1108,30 @@ __ipipe_create_trace_proc_val(struct pro
 	}
 }
 
-void __init __ipipe_init_trace_proc(void)
+void __init __ipipe_init_tracer(void)
 {
 	struct proc_dir_entry *trace_dir;
 	struct proc_dir_entry *entry;
+#ifdef CONFIG_IPIPE_TRACE_VMALLOC
+	int cpu, path;
+
+	for (cpu = 0; cpu < NR_CPUS; cpu++) {
+		trace_paths[cpu] = vmalloc(
+			sizeof(struct ipipe_trace_path) * IPIPE_TRACE_PATHS);
+		if (!trace_paths) {
+			printk(KERN_ERR "I-pipe: "
+			       "insufficient memory for trace buffer.\n");
+			return;
+		}
+		memset(trace_paths[cpu], 0,
+			sizeof(struct ipipe_trace_path) * IPIPE_TRACE_PATHS);
+		for (path = 0; path < IPIPE_TRACE_PATHS; path++) {
+			trace_paths[cpu][path].begin = -1;
+			trace_paths[cpu][path].end   = -1;
+		}
+	}
+	ipipe_trace_enable = 1;
+#endif /* CONFIG_IPIPE_TRACE_VMALLOC */
 
 	trace_dir = create_proc_entry("trace", S_IFDIR, ipipe_proc_root);
 
Index: linux-2.6.16.1/include/linux/ipipe.h
===================================================================
--- linux-2.6.16.1.orig/include/linux/ipipe.h
+++ linux-2.6.16.1/include/linux/ipipe.h
@@ -329,9 +329,9 @@ void ipipe_init(void);
 void ipipe_init_proc(void);
 
 #ifdef CONFIG_IPIPE_TRACE
-void __ipipe_init_trace_proc(void);
+void __ipipe_init_tracer(void);
 #else /* !CONFIG_IPIPE_TRACE */
-#define __ipipe_init_trace_proc()   do { } while(0)
+#define __ipipe_init_tracer()       do { } while(0)
 #endif /* CONFIG_IPIPE_TRACE */
 
 #else	/* !CONFIG_PROC_FS */
Index: linux-2.6.16.1/kernel/ipipe/core.c
===================================================================
--- linux-2.6.16.1.orig/kernel/ipipe/core.c
+++ linux-2.6.16.1/kernel/ipipe/core.c
@@ -1012,8 +1012,9 @@ void ipipe_init_proc(void)
 {
 	ipipe_proc_root = create_proc_entry("ipipe",S_IFDIR, 0);
 	create_proc_read_entry("version",0444,ipipe_proc_root,&__ipipe_version_info_proc,NULL);
-	__ipipe_init_trace_proc();
 	__ipipe_add_domain_proc(ipipe_root_domain);
+
+	__ipipe_init_tracer();
 }
 
 #endif	/* CONFIG_PROC_FS */

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-06-15 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-15 11:20 [Xenomai-core] [PATCH] use vmalloc'ed trace buffer Jan Kiszka
2006-06-15 14:57 ` [Xenomai-core] " Philippe Gerum

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.