[PATCH 3/3] OProfile: thread switching performance fix

John Levon
2003-06-17T14:41:42Z

Avoid the linear list walk of get_exec_dcookie() when we've switched to a task
using the same mm.

diff -Naur -X dontdiff linux-cvs/drivers/oprofile/buffer_sync.c linux-fixes/drivers/oprofile/buffer_sync.c
--- linux-cvs/drivers/oprofile/buffer_sync.c 2003-06-15 02:06:38.000000000 +0100
+++ linux-fixes/drivers/oprofile/buffer_sync.c 2003-06-15 15:34:47.000000000 +0100
@@ -425,7 +425,7 @@
{
struct mm_struct * mm = 0;
struct task_struct * new;
- unsigned long cookie;
+ unsigned long cookie = 0;
int in_kernel = 1;
unsigned int i;

@@ -442,13 +442,15 @@
in_kernel = s->event;
add_kernel_ctx_switch(s->event);
} else {
+ struct mm_struct * oldmm = mm;
+
/* userspace context switch */
new = (struct task_struct *)s->event;

- release_mm(mm);
+ release_mm(oldmm);
mm = take_tasks_mm(new);
-
- cookie = get_exec_dcookie(mm);
+ if (mm != oldmm)
+ cookie = get_exec_dcookie(mm);
add_user_ctx_switch(new, cookie);
}
} else {