From: Ingo Molnar Add per-arch sched_cacheflush() which is a write-back cacheflush used by the migration-cost calibration code at bootup time. Signed-off-by: Ingo Molnar Cc: Nick Piggin Signed-off-by: Andrew Morton --- arch/ia64/kernel/setup.c | 10 ++++++++++ include/asm-alpha/system.h | 10 ++++++++++ include/asm-arm/system.h | 10 ++++++++++ include/asm-arm26/system.h | 10 ++++++++++ include/asm-i386/system.h | 9 +++++++++ include/asm-ia64/system.h | 1 + include/asm-m32r/system.h | 10 ++++++++++ include/asm-mips/system.h | 10 ++++++++++ include/asm-parisc/system.h | 9 +++++++++ include/asm-powerpc/system.h | 10 ++++++++++ include/asm-ppc/system.h | 10 ++++++++++ include/asm-s390/system.h | 10 ++++++++++ include/asm-sh/system.h | 10 ++++++++++ include/asm-sparc/system.h | 10 ++++++++++ include/asm-sparc64/system.h | 10 ++++++++++ include/asm-x86_64/system.h | 9 +++++++++ 16 files changed, 148 insertions(+) diff -puN arch/ia64/kernel/setup.c~sched-add-cacheflush-asm arch/ia64/kernel/setup.c --- devel/arch/ia64/kernel/setup.c~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/arch/ia64/kernel/setup.c 2005-11-14 20:43:55.000000000 -0800 @@ -59,6 +59,7 @@ #include #include #include +#include #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE) # error "struct cpuinfo_ia64 too big!" @@ -870,3 +871,12 @@ check_bugs (void) ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles, (unsigned long) __end___mckinley_e9_bundles); } + +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + */ +void sched_cacheflush(void) +{ + ia64_sal_cache_flush(3); +} diff -puN include/asm-alpha/system.h~sched-add-cacheflush-asm include/asm-alpha/system.h --- devel/include/asm-alpha/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-alpha/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -140,6 +140,16 @@ extern void halt(void) __attribute__((no struct task_struct; extern struct task_struct *alpha_switch_to(unsigned long, struct task_struct*); +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + #define imb() \ __asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory") diff -puN include/asm-arm26/system.h~sched-add-cacheflush-asm include/asm-arm26/system.h --- devel/include/asm-arm26/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-arm26/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -115,6 +115,16 @@ do { \ } while (0) /* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + +/* * Save the current interrupt enable state & disable IRQs */ #define local_irq_save(x) \ diff -puN include/asm-arm/system.h~sched-add-cacheflush-asm include/asm-arm/system.h --- devel/include/asm-arm/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-arm/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -172,6 +172,16 @@ do { \ } while (0) /* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + +/* * CPU interrupt mask handling. */ #if __LINUX_ARM_ARCH__ >= 6 diff -puN include/asm-i386/system.h~sched-add-cacheflush-asm include/asm-i386/system.h --- devel/include/asm-i386/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-i386/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -548,6 +548,15 @@ void enable_hlt(void); extern int es7000_plat; void cpu_idle_wait(void); +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible: + */ +static inline void sched_cacheflush(void) +{ + wbinvd(); +} + extern unsigned long arch_align_stack(unsigned long sp); #endif diff -puN include/asm-ia64/system.h~sched-add-cacheflush-asm include/asm-ia64/system.h --- devel/include/asm-ia64/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-ia64/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -279,6 +279,7 @@ extern void ia64_load_extra (struct task #define ia64_platform_is(x) (strcmp(x, platform_name) == 0) void cpu_idle_wait(void); +void sched_cacheflush(void); #define arch_align_stack(x) (x) diff -puN include/asm-m32r/system.h~sched-add-cacheflush-asm include/asm-m32r/system.h --- devel/include/asm-m32r/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-m32r/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -67,6 +67,16 @@ last = __last; \ } while(0) +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + /* Interrupt Control */ #if !defined(CONFIG_CHIP_M32102) #define local_irq_enable() \ diff -puN include/asm-mips/system.h~sched-add-cacheflush-asm include/asm-mips/system.h --- devel/include/asm-mips/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-mips/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -164,6 +164,16 @@ do { \ __restore_dsp(current); \ } while(0) +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + static inline unsigned long __xchg_u32(volatile int * m, unsigned int val) { __u32 retval; diff -puN include/asm-parisc/system.h~sched-add-cacheflush-asm include/asm-parisc/system.h --- devel/include/asm-parisc/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-parisc/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -49,6 +49,15 @@ extern struct task_struct *_switch_to(st (last) = _switch_to(prev, next); \ } while(0) +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} /* interrupt control */ diff -puN include/asm-powerpc/system.h~sched-add-cacheflush-asm include/asm-powerpc/system.h --- devel/include/asm-powerpc/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-powerpc/system.h 2005-11-14 20:43:56.000000000 -0800 @@ -176,6 +176,16 @@ struct thread_struct; extern struct task_struct *_switch(struct thread_struct *prev, struct thread_struct *next); +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + extern unsigned int rtas_data; extern int mem_init_done; /* set on boot once kmalloc can be called */ extern unsigned long memory_limit; diff -puN include/asm-ppc/system.h~sched-add-cacheflush-asm include/asm-ppc/system.h --- devel/include/asm-ppc/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-ppc/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -123,6 +123,16 @@ extern struct task_struct *__switch_to(s struct task_struct *); #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next))) +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + struct thread_struct; extern struct task_struct *_switch(struct thread_struct *prev, struct thread_struct *next); diff -puN include/asm-s390/system.h~sched-add-cacheflush-asm include/asm-s390/system.h --- devel/include/asm-s390/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-s390/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -104,6 +104,16 @@ static inline void restore_access_regs(u prev = __switch_to(prev,next); \ } while (0) +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + #ifdef CONFIG_VIRT_CPU_ACCOUNTING extern void account_user_vtime(struct task_struct *); extern void account_system_vtime(struct task_struct *); diff -puN include/asm-sh/system.h~sched-add-cacheflush-asm include/asm-sh/system.h --- devel/include/asm-sh/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-sh/system.h 2005-11-14 20:43:55.000000000 -0800 @@ -57,6 +57,16 @@ last = __last; \ } while (0) +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + #define nop() __asm__ __volatile__ ("nop") diff -puN include/asm-sparc64/system.h~sched-add-cacheflush-asm include/asm-sparc64/system.h --- devel/include/asm-sparc64/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-sparc64/system.h 2005-11-14 20:43:56.000000000 -0800 @@ -257,6 +257,16 @@ do { if (test_thread_flag(TIF_PERFCTR)) } \ } while(0) +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + static inline unsigned long xchg32(__volatile__ unsigned int *m, unsigned int val) { unsigned long tmp1, tmp2; diff -puN include/asm-sparc/system.h~sched-add-cacheflush-asm include/asm-sparc/system.h --- devel/include/asm-sparc/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-sparc/system.h 2005-11-14 20:43:56.000000000 -0800 @@ -166,6 +166,16 @@ extern void fpsave(unsigned long *fpregs } while(0) /* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + * + * TODO: fill this in! + */ +static inline void sched_cacheflush(void) +{ +} + +/* * Changing the IRQ level on the Sparc. */ extern void local_irq_restore(unsigned long); diff -puN include/asm-x86_64/system.h~sched-add-cacheflush-asm include/asm-x86_64/system.h --- devel/include/asm-x86_64/system.h~sched-add-cacheflush-asm 2005-11-14 20:43:55.000000000 -0800 +++ devel-akpm/include/asm-x86_64/system.h 2005-11-14 20:43:56.000000000 -0800 @@ -178,6 +178,15 @@ static inline void write_cr4(unsigned lo #define wbinvd() \ __asm__ __volatile__ ("wbinvd": : :"memory"); +/* + * On SMP systems, when the scheduler does migration-cost autodetection, + * it needs a way to flush as much of the CPU's caches as possible. + */ +static inline void sched_cacheflush(void) +{ + wbinvd(); +} + #endif /* __KERNEL__ */ #define nop() __asm__ __volatile__ ("nop") _