Skip to contentSkip to conversation

oprofile - hooks

PATCH In review John Levon 1 participant 1 message Oct 15, 2002

Subsystems (2)
lore
Share & tools
lore

John Levon

author
#0 lore raw

PATCH 1/7 oprofile - hooks

The following seven patches, against the latest bk2patch, implement the oprofile functionality in 2.5. Each patch produces a compilable kernel, but most of the patches are dependent upon the previous ones. The design and implementation is similar to that we discussed previously.

The patch has been in -mm series for a while now, and has been tested by numerous people on UP and SMP. The patch has been looked at by Andi Kleen, Christophe Hellwig, Ingo Molnar, and Alan Cox, amongst others.

Please consider applying (especially as oprofile can no longer build externally)

thanks
john

[1/7]

This patch implements the simple hooks we need to catch unmappings, and to make sure no stale task_struct*'s are ever used by the main oprofile core mechanism. If disabled, it compiles to nothing.

arch/i386/Config.help +5 -0
diff -Naur -X dontdiff linux-linus/arch/i386/Config.help linux-linus2/arch/i386/Config.help
@@ -1048,6 +1048,11 @@
   Say Y here if you want to reduce the chances of the tree compiling,
   and are prepared to dig into driver internals to fix compile errors.
 
+Profiling support
+CONFIG_PROFILING
+  Say Y here to enable the extended profiling support mechanisms used
+  by profilers such as OProfile.
+ 
 Software Suspend
 CONFIG_SOFTWARE_SUSPEND
   Enable the possibilty of suspendig machine. It doesn't need APM.
arch/i386/config.in +7 -0
diff -Naur -X dontdiff linux-linus/arch/i386/config.in linux-linus2/arch/i386/config.in
@@ -442,6 +442,13 @@
 
 source net/bluetooth/Config.in
 
+if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+   mainmenu_option next_comment
+   comment 'Profiling support'
+   bool 'Profiling support (EXPERIMENTAL)' CONFIG_PROFILING
+   endmenu
+fi
+ 
 mainmenu_option next_comment
 comment 'Kernel hacking'
 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
include/linux/profile.h +56 -0

56 lines not on this page · raw message

kernel/Makefile +3 -2
diff -Naur -X dontdiff linux-linus/kernel/Makefile linux-linus2/kernel/Makefile
@@ -3,9 +3,10 @@
 #
 
 export-objs = signal.o sys.o kmod.o workqueue.o ksyms.o pm.o exec_domain.o \
-	      printk.o platform.o suspend.o dma.o module.o cpufreq.o
+		printk.o platform.o suspend.o dma.o module.o cpufreq.o \
+		profile.o
 
-obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
+obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
 	    module.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o futex.o platform.o pid.o
kernel/exit.c +7 -3
diff -Naur -X dontdiff linux-linus/kernel/exit.c linux-linus2/kernel/exit.c
@@ -19,6 +19,7 @@
 #include <linux/file.h>
 #include <linux/binfmts.h>
 #include <linux/ptrace.h>
+#include <linux/profile.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -59,11 +60,12 @@
 {
 	struct dentry *proc_dentry;
 	task_t *leader;
-
-	if (p->state < TASK_ZOMBIE)
-		BUG();
+ 
+	BUG_ON(p->state < TASK_ZOMBIE);
+ 
 	if (p != current)
 		wait_task_inactive(p);
+
 	atomic_dec(&p->user->processes);
 	security_ops->task_free_security(p);
 	free_uid(p->user);
@@ -635,6 +637,8 @@
 				current->comm, current->pid,
 				preempt_count());
 
+	profile_exit_task(tsk);
+ 
 fake_volatile:
 	acct_process(code);
 	__exit_mm(tsk);
kernel/profile.c +91 -0

91 lines not on this page · raw message

mm/mmap.c +8 -0
diff -Naur -X dontdiff linux-linus/mm/mmap.c linux-linus2/mm/mmap.c
@@ -16,6 +16,7 @@
 #include <linux/fs.h>
 #include <linux/personality.h>
 #include <linux/security.h>
+#include <linux/profile.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgalloc.h>
@@ -1104,6 +1105,10 @@
 	if (mpnt->vm_start >= end)
 		return 0;
 
+	/* Something will probably happen, so notify. */
+	if (mpnt->vm_file && (mpnt->vm_flags & VM_EXEC))
+		profile_exec_unmap(mm);
+ 
 	/*
 	 * If we need to split any vma, do it now to save pain later.
 	 */
@@ -1253,7 +1258,10 @@
 	mmu_gather_t *tlb;
 	struct vm_area_struct * mpnt;
 
+	profile_exit_mmap(mm);
+ 
 	release_segments(mm);
+ 
 	spin_lock(&mm->page_table_lock);
 
 	tlb = tlb_gather_mmu(mm, 1);