--- drivers/oprofile/cpu_buffer.c.orig 2007-10-03 21:36:08.000000000 +0200 +++ drivers/oprofile/cpu_buffer.c 2007-10-11 12:41:57.000000000 +0200 @@ -241,7 +241,7 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) { int is_kernel = !user_mode(regs); - unsigned long pc = profile_pc(regs); + unsigned long pc = instruction_pointer(regs); oprofile_add_ext_sample(pc, regs, event, is_kernel); } --- drivers/oprofile/buffer_sync.c.orig 2007-10-04 10:15:27.000000000 +0200 +++ drivers/oprofile/buffer_sync.c 2007-10-11 12:49:22.000000000 +0200 @@ -530,11 +530,30 @@ /* userspace context switch */ new = (struct task_struct *)s->event; - release_mm(oldmm); - mm = take_tasks_mm(new); - if (mm != oldmm) - cookie = get_exec_dcookie(mm); - add_user_ctx_switch(new, cookie); + /* Ugly, let says task pointer can't be + in the last page nor in the first page */ + if (s->event + 0x1000 > 0x2000) { + release_mm(oldmm); + mm = take_tasks_mm(new); + if (mm != oldmm) + cookie = get_exec_dcookie(mm); + add_user_ctx_switch(new, cookie); + } else { + static int show_it = 0; + if (show_it++ < 5) { + printk(KERN_INFO + "oprofile: Invalid " + "event %lu, head %lu, " + "tail %lu, eip %lu, " + "available %lu, i %u " + "state %d %d\n", + s->event, + cpu_buf->head_pos, + cpu_buf->tail_pos, + s->eip, available, i, + state, in_kernel); + } + } } } else { if (state >= sb_bt_start &&