|
Lines 331-336
Link Here
|
| 331 |
struct cpu_group *cg, int indent); |
331 |
struct cpu_group *cg, int indent); |
| 332 |
#endif |
332 |
#endif |
| 333 |
|
333 |
|
|
|
334 |
static int sched_random(); |
| 335 |
|
| 334 |
static void sched_setup(void *dummy); |
336 |
static void sched_setup(void *dummy); |
| 335 |
SYSINIT(sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL); |
337 |
SYSINIT(sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL); |
| 336 |
|
338 |
|
|
Lines 359-364
Link Here
|
| 359 |
/* |
361 |
/* |
| 360 |
* Print the threads waiting on a run-queue. |
362 |
* Print the threads waiting on a run-queue. |
| 361 |
*/ |
363 |
*/ |
|
|
364 |
|
| 365 |
static int sched_random() |
| 366 |
{ |
| 367 |
int rnd, *rndptr; |
| 368 |
rndptr = DPCPU_PTR(randomval); |
| 369 |
rnd = (*rndptr = *rndptr * 69069 + 5) >> 26; |
| 370 |
return(rnd); |
| 371 |
} |
| 372 |
|
| 373 |
|
| 362 |
static void |
374 |
static void |
| 363 |
runq_print(struct runq *rq) |
375 |
runq_print(struct runq *rq) |
| 364 |
{ |
376 |
{ |
|
Lines 651-657
Link Here
|
| 651 |
cpuset_t cpumask; |
663 |
cpuset_t cpumask; |
| 652 |
struct cpu_group *child; |
664 |
struct cpu_group *child; |
| 653 |
struct tdq *tdq; |
665 |
struct tdq *tdq; |
| 654 |
int cpu, i, hload, lload, load, total, rnd, *rndptr; |
666 |
int cpu, i, hload, lload, load, total, rnd; |
| 655 |
|
667 |
|
| 656 |
total = 0; |
668 |
total = 0; |
| 657 |
cpumask = cg->cg_mask; |
669 |
cpumask = cg->cg_mask; |
|
Lines 700-708
Link Here
|
| 700 |
CPU_CLR(cpu, &cpumask); |
712 |
CPU_CLR(cpu, &cpumask); |
| 701 |
tdq = TDQ_CPU(cpu); |
713 |
tdq = TDQ_CPU(cpu); |
| 702 |
load = tdq->tdq_load * 256; |
714 |
load = tdq->tdq_load * 256; |
| 703 |
rndptr = DPCPU_PTR(randomval); |
715 |
rnd = sched_random(); |
| 704 |
rnd = (*rndptr = *rndptr * 69069 + 5) >> 26; |
716 |
if (match & CPU_SEARCH_LOWEST) { |
| 705 |
if (match & CPU_SEARCH_LOWEST) { |
|
|
| 706 |
if (cpu == low->cs_prefer) |
717 |
if (cpu == low->cs_prefer) |
| 707 |
load -= 64; |
718 |
load -= 64; |
| 708 |
/* If that CPU is allowed and get data. */ |
719 |
/* If that CPU is allowed and get data. */ |
|
Lines 861-874
Link Here
|
| 861 |
{ |
872 |
{ |
| 862 |
struct tdq *tdq; |
873 |
struct tdq *tdq; |
| 863 |
|
874 |
|
| 864 |
/* |
|
|
| 865 |
* Select a random time between .5 * balance_interval and |
| 866 |
* 1.5 * balance_interval. |
| 867 |
*/ |
| 868 |
balance_ticks = max(balance_interval / 2, 1); |
| 869 |
balance_ticks += random() % balance_interval; |
| 870 |
if (smp_started == 0 || rebalance == 0) |
875 |
if (smp_started == 0 || rebalance == 0) |
| 871 |
return; |
876 |
return; |
|
|
877 |
|
| 878 |
balance_ticks = max(balance_interval / 2, 1) + |
| 879 |
(sched_random() % balance_interval); |
| 872 |
tdq = TDQ_SELF(); |
880 |
tdq = TDQ_SELF(); |
| 873 |
TDQ_UNLOCK(tdq); |
881 |
TDQ_UNLOCK(tdq); |
| 874 |
sched_balance_group(cpu_top); |
882 |
sched_balance_group(cpu_top); |