From: Mikael Pettersson - Move perfctr_suspend_thread() call from __switch_to() to the beginning of switch_to(). Ensures that suspend actions are done when the owner task still is 'current'. Signed-off-by: Mikael Pettersson Signed-off-by: Andrew Morton --- 25-akpm/arch/x86_64/kernel/process.c | 2 -- 25-akpm/include/asm-x86_64/system.h | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff -puN arch/x86_64/kernel/process.c~perfctr-x86_64-core-updates arch/x86_64/kernel/process.c --- 25/arch/x86_64/kernel/process.c~perfctr-x86_64-core-updates 2004-11-11 01:42:53.578542544 -0800 +++ 25-akpm/arch/x86_64/kernel/process.c 2004-11-11 01:42:53.583541784 -0800 @@ -432,8 +432,6 @@ struct task_struct *__switch_to(struct t int cpu = smp_processor_id(); struct tss_struct *tss = &per_cpu(init_tss, cpu); - perfctr_suspend_thread(prev); - unlazy_fpu(prev_p); /* diff -puN include/asm-x86_64/system.h~perfctr-x86_64-core-updates include/asm-x86_64/system.h --- 25/include/asm-x86_64/system.h~perfctr-x86_64-core-updates 2004-11-11 01:42:53.579542392 -0800 +++ 25-akpm/include/asm-x86_64/system.h 2004-11-11 01:42:53.584541632 -0800 @@ -26,7 +26,8 @@ #define __EXTRA_CLOBBER \ ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15" -#define switch_to(prev,next,last) \ +#define switch_to(prev,next,last) do { \ + perfctr_suspend_thread(&(prev)->thread); \ asm volatile(SAVE_CONTEXT \ "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \ "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \ @@ -46,7 +47,8 @@ [tif_fork] "i" (TIF_FORK), \ [thread_info] "i" (offsetof(struct task_struct, thread_info)), \ [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \ - : "memory", "cc" __EXTRA_CLOBBER) + : "memory", "cc" __EXTRA_CLOBBER); \ +} while (0) extern void load_gs_index(unsigned); _