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

John Levon (levon@movementarian.org)
Tue, 17 Jun 2003 15:53:55 +0100


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 {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/