Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched

* git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched:
[PATCH] sched: implement cpu_clock(cpu) high-speed time source
[PATCH] sched: fix the all pinned logic in load_balance_newidle()
[PATCH] sched: fix newly idle load balance in case of SMT
[PATCH] sched: sched_cacheflush is now unused

+33 -154
-9
arch/ia64/kernel/setup.c
··· 980 980 pm_idle = default_idle; 981 981 } 982 982 983 - /* 984 - * On SMP systems, when the scheduler does migration-cost autodetection, 985 - * it needs a way to flush as much of the CPU's caches as possible. 986 - */ 987 - void sched_cacheflush(void) 988 - { 989 - ia64_sal_cache_flush(3); 990 - } 991 - 992 983 void __init 993 984 check_bugs (void) 994 985 {
-10
include/asm-alpha/system.h
··· 139 139 struct task_struct; 140 140 extern struct task_struct *alpha_switch_to(unsigned long, struct task_struct*); 141 141 142 - /* 143 - * On SMP systems, when the scheduler does migration-cost autodetection, 144 - * it needs a way to flush as much of the CPU's caches as possible. 145 - * 146 - * TODO: fill this in! 147 - */ 148 - static inline void sched_cacheflush(void) 149 - { 150 - } 151 - 152 142 #define imb() \ 153 143 __asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory") 154 144
-10
include/asm-arm/system.h
··· 254 254 last = __switch_to(prev,task_thread_info(prev), task_thread_info(next)); \ 255 255 } while (0) 256 256 257 - /* 258 - * On SMP systems, when the scheduler does migration-cost autodetection, 259 - * it needs a way to flush as much of the CPU's caches as possible. 260 - * 261 - * TODO: fill this in! 262 - */ 263 - static inline void sched_cacheflush(void) 264 - { 265 - } 266 - 267 257 #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110) 268 258 /* 269 259 * On the StrongARM, "swp" is terminally broken since it bypasses the
-10
include/asm-arm26/system.h
··· 110 110 } while (0) 111 111 112 112 /* 113 - * On SMP systems, when the scheduler does migration-cost autodetection, 114 - * it needs a way to flush as much of the CPU's caches as possible. 115 - * 116 - * TODO: fill this in! 117 - */ 118 - static inline void sched_cacheflush(void) 119 - { 120 - } 121 - 122 - /* 123 113 * Save the current interrupt enable state & disable IRQs 124 114 */ 125 115 #define local_irq_save(x) \
-9
include/asm-i386/system.h
··· 310 310 extern int es7000_plat; 311 311 void cpu_idle_wait(void); 312 312 313 - /* 314 - * On SMP systems, when the scheduler does migration-cost autodetection, 315 - * it needs a way to flush as much of the CPU's caches as possible: 316 - */ 317 - static inline void sched_cacheflush(void) 318 - { 319 - wbinvd(); 320 - } 321 - 322 313 extern unsigned long arch_align_stack(unsigned long sp); 323 314 extern void free_init_pages(char *what, unsigned long begin, unsigned long end); 324 315
-1
include/asm-ia64/system.h
··· 259 259 #define ia64_platform_is(x) (strcmp(x, platform_name) == 0) 260 260 261 261 void cpu_idle_wait(void); 262 - void sched_cacheflush(void); 263 262 264 263 #define arch_align_stack(x) (x) 265 264
-10
include/asm-m32r/system.h
··· 54 54 ); \ 55 55 } while(0) 56 56 57 - /* 58 - * On SMP systems, when the scheduler does migration-cost autodetection, 59 - * it needs a way to flush as much of the CPU's caches as possible. 60 - * 61 - * TODO: fill this in! 62 - */ 63 - static inline void sched_cacheflush(void) 64 - { 65 - } 66 - 67 57 /* Interrupt Control */ 68 58 #if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104) 69 59 #define local_irq_enable() \
-10
include/asm-mips/system.h
··· 71 71 write_c0_userlocal(task_thread_info(current)->tp_value);\ 72 72 } while(0) 73 73 74 - /* 75 - * On SMP systems, when the scheduler does migration-cost autodetection, 76 - * it needs a way to flush as much of the CPU's caches as possible. 77 - * 78 - * TODO: fill this in! 79 - */ 80 - static inline void sched_cacheflush(void) 81 - { 82 - } 83 - 84 74 static inline unsigned long __xchg_u32(volatile int * m, unsigned int val) 85 75 { 86 76 __u32 retval;
-11
include/asm-parisc/system.h
··· 48 48 (last) = _switch_to(prev, next); \ 49 49 } while(0) 50 50 51 - /* 52 - * On SMP systems, when the scheduler does migration-cost autodetection, 53 - * it needs a way to flush as much of the CPU's caches as possible. 54 - * 55 - * TODO: fill this in! 56 - */ 57 - static inline void sched_cacheflush(void) 58 - { 59 - } 60 - 61 - 62 51 /* interrupt control */ 63 52 #define local_save_flags(x) __asm__ __volatile__("ssm 0, %0" : "=r" (x) : : "memory") 64 53 #define local_irq_disable() __asm__ __volatile__("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
-10
include/asm-powerpc/system.h
··· 184 184 extern struct task_struct *_switch(struct thread_struct *prev, 185 185 struct thread_struct *next); 186 186 187 - /* 188 - * On SMP systems, when the scheduler does migration-cost autodetection, 189 - * it needs a way to flush as much of the CPU's caches as possible. 190 - * 191 - * TODO: fill this in! 192 - */ 193 - static inline void sched_cacheflush(void) 194 - { 195 - } 196 - 197 187 extern unsigned int rtas_data; 198 188 extern int mem_init_done; /* set on boot once kmalloc can be called */ 199 189 extern unsigned long memory_limit;
-10
include/asm-ppc/system.h
··· 129 129 struct task_struct *); 130 130 #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next))) 131 131 132 - /* 133 - * On SMP systems, when the scheduler does migration-cost autodetection, 134 - * it needs a way to flush as much of the CPU's caches as possible. 135 - * 136 - * TODO: fill this in! 137 - */ 138 - static inline void sched_cacheflush(void) 139 - { 140 - } 141 - 142 132 struct thread_struct; 143 133 extern struct task_struct *_switch(struct thread_struct *prev, 144 134 struct thread_struct *next);
-10
include/asm-s390/system.h
··· 97 97 prev = __switch_to(prev,next); \ 98 98 } while (0) 99 99 100 - /* 101 - * On SMP systems, when the scheduler does migration-cost autodetection, 102 - * it needs a way to flush as much of the CPU's caches as possible. 103 - * 104 - * TODO: fill this in! 105 - */ 106 - static inline void sched_cacheflush(void) 107 - { 108 - } 109 - 110 100 #ifdef CONFIG_VIRT_CPU_ACCOUNTING 111 101 extern void account_vtime(struct task_struct *); 112 102 extern void account_tick_vtime(struct task_struct *);
-10
include/asm-sh/system.h
··· 64 64 last = __last; \ 65 65 } while (0) 66 66 67 - /* 68 - * On SMP systems, when the scheduler does migration-cost autodetection, 69 - * it needs a way to flush as much of the CPU's caches as possible. 70 - * 71 - * TODO: fill this in! 72 - */ 73 - static inline void sched_cacheflush(void) 74 - { 75 - } 76 - 77 67 #ifdef CONFIG_CPU_SH4A 78 68 #define __icbi() \ 79 69 { \
-10
include/asm-sparc/system.h
··· 165 165 } while(0) 166 166 167 167 /* 168 - * On SMP systems, when the scheduler does migration-cost autodetection, 169 - * it needs a way to flush as much of the CPU's caches as possible. 170 - * 171 - * TODO: fill this in! 172 - */ 173 - static inline void sched_cacheflush(void) 174 - { 175 - } 176 - 177 - /* 178 168 * Changing the IRQ level on the Sparc. 179 169 */ 180 170 extern void local_irq_restore(unsigned long);
-10
include/asm-sparc64/system.h
··· 204 204 } \ 205 205 } while(0) 206 206 207 - /* 208 - * On SMP systems, when the scheduler does migration-cost autodetection, 209 - * it needs a way to flush as much of the CPU's caches as possible. 210 - * 211 - * TODO: fill this in! 212 - */ 213 - static inline void sched_cacheflush(void) 214 - { 215 - } 216 - 217 207 static inline unsigned long xchg32(__volatile__ unsigned int *m, unsigned int val) 218 208 { 219 209 unsigned long tmp1, tmp2;
-9
include/asm-x86_64/system.h
··· 111 111 #define wbinvd() \ 112 112 __asm__ __volatile__ ("wbinvd": : :"memory"); 113 113 114 - /* 115 - * On SMP systems, when the scheduler does migration-cost autodetection, 116 - * it needs a way to flush as much of the CPU's caches as possible. 117 - */ 118 - static inline void sched_cacheflush(void) 119 - { 120 - wbinvd(); 121 - } 122 - 123 114 #endif /* __KERNEL__ */ 124 115 125 116 #define nop() __asm__ __volatile__ ("nop")
+7
include/linux/sched.h
··· 1348 1348 #endif 1349 1349 1350 1350 extern unsigned long long sched_clock(void); 1351 + 1352 + /* 1353 + * For kernel-internal use: high-speed (but slightly incorrect) per-cpu 1354 + * clock constructed from sched_clock(): 1355 + */ 1356 + extern unsigned long long cpu_clock(int cpu); 1357 + 1351 1358 extern unsigned long long 1352 1359 task_sched_runtime(struct task_struct *task); 1353 1360
+26 -5
kernel/sched.c
··· 379 379 #define task_rq(p) cpu_rq(task_cpu(p)) 380 380 #define cpu_curr(cpu) (cpu_rq(cpu)->curr) 381 381 382 + /* 383 + * For kernel-internal use: high-speed (but slightly incorrect) per-cpu 384 + * clock constructed from sched_clock(): 385 + */ 386 + unsigned long long cpu_clock(int cpu) 387 + { 388 + struct rq *rq = cpu_rq(cpu); 389 + unsigned long long now; 390 + unsigned long flags; 391 + 392 + spin_lock_irqsave(&rq->lock, flags); 393 + now = rq_clock(rq); 394 + spin_unlock_irqrestore(&rq->lock, flags); 395 + 396 + return now; 397 + } 398 + 382 399 #ifdef CONFIG_FAIR_GROUP_SCHED 383 400 /* Change a task's ->cfs_rq if it moves across CPUs */ 384 401 static inline void set_task_cfs_rq(struct task_struct *p) ··· 2252 2235 2253 2236 rq = cpu_rq(i); 2254 2237 2255 - if (*sd_idle && !idle_cpu(i)) 2238 + if (*sd_idle && rq->nr_running) 2256 2239 *sd_idle = 0; 2257 2240 2258 2241 /* Bias balancing toward cpus of our domain */ ··· 2274 2257 /* 2275 2258 * First idle cpu or the first cpu(busiest) in this sched group 2276 2259 * is eligible for doing load balancing at this and above 2277 - * domains. 2260 + * domains. In the newly idle case, we will allow all the cpu's 2261 + * to do the newly idle load balance. 2278 2262 */ 2279 - if (local_group && balance_cpu != this_cpu && balance) { 2263 + if (idle != CPU_NEWLY_IDLE && local_group && 2264 + balance_cpu != this_cpu && balance) { 2280 2265 *balance = 0; 2281 2266 goto ret; 2282 2267 } ··· 2696 2677 unsigned long imbalance; 2697 2678 int nr_moved = 0; 2698 2679 int sd_idle = 0; 2680 + int all_pinned = 0; 2699 2681 cpumask_t cpus = CPU_MASK_ALL; 2700 2682 2701 2683 /* ··· 2735 2715 double_lock_balance(this_rq, busiest); 2736 2716 nr_moved = move_tasks(this_rq, this_cpu, busiest, 2737 2717 minus_1_or_zero(busiest->nr_running), 2738 - imbalance, sd, CPU_NEWLY_IDLE, NULL); 2718 + imbalance, sd, CPU_NEWLY_IDLE, 2719 + &all_pinned); 2739 2720 spin_unlock(&busiest->lock); 2740 2721 2741 - if (!nr_moved) { 2722 + if (unlikely(all_pinned)) { 2742 2723 cpu_clear(cpu_of(busiest), cpus); 2743 2724 if (!cpus_empty(cpus)) 2744 2725 goto redo;