Deleted Added
full compact
sched_ule.c (212153) sched_ule.c (212416)
1/*-
2 * Copyright (c) 2002-2007, Jeffrey Roberson <jeff@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 *
32 * etymology:
33 * ULE is the last three letters in schedule. It owes its name to a
34 * generic user created for a scheduling system by Paul Mikesell at
35 * Isilon Systems and a general lack of creativity on the part of the author.
36 */
37
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2007, Jeffrey Roberson <jeff@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 *
32 * etymology:
33 * ULE is the last three letters in schedule. It owes its name to a
34 * generic user created for a scheduling system by Paul Mikesell at
35 * Isilon Systems and a general lack of creativity on the part of the author.
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/kern/sched_ule.c 212153 2010-09-02 16:23:05Z mdf $");
39__FBSDID("$FreeBSD: head/sys/kern/sched_ule.c 212416 2010-09-10 13:24:47Z mav $");
40
41#include "opt_hwpmc_hooks.h"
42#include "opt_kdtrace.h"
43#include "opt_sched.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/kdb.h>

--- 143 unchanged lines hidden (view full) ---

191#else
192static int preempt_thresh = PRI_MIN_KERN;
193#endif
194#else
195static int preempt_thresh = 0;
196#endif
197static int static_boost = PRI_MIN_TIMESHARE;
198static int sched_idlespins = 10000;
40
41#include "opt_hwpmc_hooks.h"
42#include "opt_kdtrace.h"
43#include "opt_sched.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/kdb.h>

--- 143 unchanged lines hidden (view full) ---

191#else
192static int preempt_thresh = PRI_MIN_KERN;
193#endif
194#else
195static int preempt_thresh = 0;
196#endif
197static int static_boost = PRI_MIN_TIMESHARE;
198static int sched_idlespins = 10000;
199static int sched_idlespinthresh = 4;
199static int sched_idlespinthresh = 64;
200
201/*
202 * tdq - per processor runqs and statistics. All fields are protected by the
203 * tdq_lock. The load and lowpri may be accessed without to avoid excess
204 * locking in sched_pickcpu();
205 */
206struct tdq {
207 /* Ordered to improve efficiency of cpu_search() and switch(). */
208 struct mtx tdq_lock; /* run queue lock. */
209 struct cpu_group *tdq_cg; /* Pointer to cpu topology. */
210 volatile int tdq_load; /* Aggregate load. */
200
201/*
202 * tdq - per processor runqs and statistics. All fields are protected by the
203 * tdq_lock. The load and lowpri may be accessed without to avoid excess
204 * locking in sched_pickcpu();
205 */
206struct tdq {
207 /* Ordered to improve efficiency of cpu_search() and switch(). */
208 struct mtx tdq_lock; /* run queue lock. */
209 struct cpu_group *tdq_cg; /* Pointer to cpu topology. */
210 volatile int tdq_load; /* Aggregate load. */
211 volatile int tdq_cpu_idle; /* cpu_idle() is active. */
211 int tdq_sysload; /* For loadavg, !ITHD load. */
212 int tdq_transferable; /* Transferable thread count. */
213 short tdq_switchcnt; /* Switches this tick. */
214 short tdq_oldswitchcnt; /* Switches last tick. */
215 u_char tdq_lowpri; /* Lowest priority thread. */
216 u_char tdq_ipipending; /* IPI pending. */
217 u_char tdq_idx; /* Current insert index. */
218 u_char tdq_ridx; /* Current removal index. */

--- 742 unchanged lines hidden (view full) ---

961 ctd = pcpu_find(cpu)->pc_curthread;
962 if (!sched_shouldpreempt(pri, ctd->td_priority, 1))
963 return;
964 if (TD_IS_IDLETHREAD(ctd)) {
965 /*
966 * If the MD code has an idle wakeup routine try that before
967 * falling back to IPI.
968 */
212 int tdq_sysload; /* For loadavg, !ITHD load. */
213 int tdq_transferable; /* Transferable thread count. */
214 short tdq_switchcnt; /* Switches this tick. */
215 short tdq_oldswitchcnt; /* Switches last tick. */
216 u_char tdq_lowpri; /* Lowest priority thread. */
217 u_char tdq_ipipending; /* IPI pending. */
218 u_char tdq_idx; /* Current insert index. */
219 u_char tdq_ridx; /* Current removal index. */

--- 742 unchanged lines hidden (view full) ---

962 ctd = pcpu_find(cpu)->pc_curthread;
963 if (!sched_shouldpreempt(pri, ctd->td_priority, 1))
964 return;
965 if (TD_IS_IDLETHREAD(ctd)) {
966 /*
967 * If the MD code has an idle wakeup routine try that before
968 * falling back to IPI.
969 */
969 if (cpu_idle_wakeup(cpu))
970 if (!tdq->tdq_cpu_idle || cpu_idle_wakeup(cpu))
970 return;
971 }
972 tdq->tdq_ipipending = 1;
973 ipi_cpu(cpu, IPI_PREEMPT);
974}
975
976/*
977 * Steals load from a timeshare queue. Honors the rotating queue head

--- 1562 unchanged lines hidden (view full) ---

2540 if (TDQ_IDLESPIN(tdq) && switchcnt > sched_idlespinthresh) {
2541 for (i = 0; i < sched_idlespins; i++) {
2542 if (tdq->tdq_load)
2543 break;
2544 cpu_spinwait();
2545 }
2546 }
2547 switchcnt = tdq->tdq_switchcnt + tdq->tdq_oldswitchcnt;
971 return;
972 }
973 tdq->tdq_ipipending = 1;
974 ipi_cpu(cpu, IPI_PREEMPT);
975}
976
977/*
978 * Steals load from a timeshare queue. Honors the rotating queue head

--- 1562 unchanged lines hidden (view full) ---

2541 if (TDQ_IDLESPIN(tdq) && switchcnt > sched_idlespinthresh) {
2542 for (i = 0; i < sched_idlespins; i++) {
2543 if (tdq->tdq_load)
2544 break;
2545 cpu_spinwait();
2546 }
2547 }
2548 switchcnt = tdq->tdq_switchcnt + tdq->tdq_oldswitchcnt;
2548 if (tdq->tdq_load == 0)
2549 cpu_idle(switchcnt > 1);
2549 if (tdq->tdq_load == 0) {
2550 tdq->tdq_cpu_idle = 1;
2551 if (tdq->tdq_load == 0) {
2552 cpu_idle(switchcnt > sched_idlespinthresh);
2553 tdq->tdq_switchcnt++;
2554 }
2555 tdq->tdq_cpu_idle = 0;
2556 }
2550 if (tdq->tdq_load) {
2551 thread_lock(td);
2552 mi_switch(SW_VOL | SWT_IDLE, NULL);
2553 thread_unlock(td);
2554 }
2555 }
2556}
2557

--- 191 unchanged lines hidden ---
2557 if (tdq->tdq_load) {
2558 thread_lock(td);
2559 mi_switch(SW_VOL | SWT_IDLE, NULL);
2560 thread_unlock(td);
2561 }
2562 }
2563}
2564

--- 191 unchanged lines hidden ---