summaryrefslogtreecommitdiff
path: root/kernel/profile.c
diff options
context:
space:
mode:
authorJohn Levon <levon@movementarian.org>2002-10-15 04:30:38 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-10-15 04:30:38 -0700
commit120790b8fe2d901d99f459a567fefbb35c2d15e1 (patch)
treea3abac277c8b40f171364bedb3f2309ceb2062b0 /kernel/profile.c
parent7e1aee05c99cfbb7e5cf33bae11ab9fa8df6c57c (diff)
[PATCH] oprofile - timer hook
This implements a simple hook into the profiling timer for x86 so that non-perfctr machines can still use oprofile. This has proven useful for laptops and the like. It also reduces header dependencies a bit by centralising readprofile code
Diffstat (limited to 'kernel/profile.c')
-rw-r--r--kernel/profile.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/profile.c b/kernel/profile.c
index 7ebffe971ca8..756f142b1f35 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -9,6 +9,36 @@
#include <linux/notifier.h>
#include <linux/mm.h>
+extern char _stext, _etext;
+
+unsigned int * prof_buffer;
+unsigned long prof_len;
+unsigned long prof_shift;
+
+int __init profile_setup(char * str)
+{
+ int par;
+ if (get_option(&str,&par))
+ prof_shift = par;
+ return 1;
+}
+
+
+void __init profile_init(void)
+{
+ unsigned int size;
+
+ if (!prof_shift)
+ return;
+
+ /* only text is profiled */
+ prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
+ prof_len >>= prof_shift;
+
+ size = prof_len * sizeof(unsigned int) + PAGE_SIZE - 1;
+ prof_buffer = (unsigned int *) alloc_bootmem(size);
+}
+
/* Profile event notifications */
#ifdef CONFIG_PROFILING