rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LAST
Also directly call swapper() at the end of mi_startup instead of relying on swapper being the last thing in sysinits order. Rationale: - "RUN_SCHEDULER" was misleading, scheduling already takes place at that stage - "scheduler" was misleading, the function swaps in the swapped out processes - another SYSINIT(SI_SUB_RUN_SCHEDULER, SI_ORDER_ANY) could never be invoked depending on its relative order with scheduler; this was not obvious and the bug actually used to exist Reviewed by: kib (ealier version) MFC after: 14 days
This commit is contained in:
parent
886dbd270f
commit
785797c341
@ -136,7 +136,7 @@ oktousecallout(void *data __unused)
|
|||||||
{
|
{
|
||||||
calloutok = 1;
|
calloutok = 1;
|
||||||
}
|
}
|
||||||
SYSINIT(gdbhack, SI_SUB_RUN_SCHEDULER, SI_ORDER_MIDDLE, oktousecallout, NULL);
|
SYSINIT(gdbhack, SI_SUB_LAST, SI_ORDER_MIDDLE, oktousecallout, NULL);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdb_cnputc(struct consdev *cp, int c)
|
gdb_cnputc(struct consdev *cp, int c)
|
||||||
|
@ -243,9 +243,6 @@ restart:
|
|||||||
/*
|
/*
|
||||||
* Traverse the (now) ordered list of system initialization tasks.
|
* Traverse the (now) ordered list of system initialization tasks.
|
||||||
* Perform each task, and continue on to the next task.
|
* Perform each task, and continue on to the next task.
|
||||||
*
|
|
||||||
* The last item on the list is expected to be the scheduler,
|
|
||||||
* which will not return.
|
|
||||||
*/
|
*/
|
||||||
for (sipp = sysinit; sipp < sysinit_end; sipp++) {
|
for (sipp = sysinit; sipp < sysinit_end; sipp++) {
|
||||||
|
|
||||||
@ -303,7 +300,13 @@ restart:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("Shouldn't get here!");
|
mtx_assert(&Giant, MA_OWNED | MA_NOTRECURSED);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now hand over this thread to swapper.
|
||||||
|
*/
|
||||||
|
swapper();
|
||||||
/* NOTREACHED*/
|
/* NOTREACHED*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +349,7 @@ static char wit_warn[] =
|
|||||||
"WARNING: WITNESS option enabled, expect reduced performance.\n";
|
"WARNING: WITNESS option enabled, expect reduced performance.\n";
|
||||||
SYSINIT(witwarn, SI_SUB_COPYRIGHT, SI_ORDER_THIRD + 1,
|
SYSINIT(witwarn, SI_SUB_COPYRIGHT, SI_ORDER_THIRD + 1,
|
||||||
print_caddr_t, wit_warn);
|
print_caddr_t, wit_warn);
|
||||||
SYSINIT(witwarn2, SI_SUB_RUN_SCHEDULER, SI_ORDER_THIRD + 1,
|
SYSINIT(witwarn2, SI_SUB_LAST, SI_ORDER_THIRD + 1,
|
||||||
print_caddr_t, wit_warn);
|
print_caddr_t, wit_warn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -355,7 +358,7 @@ static char diag_warn[] =
|
|||||||
"WARNING: DIAGNOSTIC option enabled, expect reduced performance.\n";
|
"WARNING: DIAGNOSTIC option enabled, expect reduced performance.\n";
|
||||||
SYSINIT(diagwarn, SI_SUB_COPYRIGHT, SI_ORDER_THIRD + 2,
|
SYSINIT(diagwarn, SI_SUB_COPYRIGHT, SI_ORDER_THIRD + 2,
|
||||||
print_caddr_t, diag_warn);
|
print_caddr_t, diag_warn);
|
||||||
SYSINIT(diagwarn2, SI_SUB_RUN_SCHEDULER, SI_ORDER_THIRD + 2,
|
SYSINIT(diagwarn2, SI_SUB_LAST, SI_ORDER_THIRD + 2,
|
||||||
print_caddr_t, diag_warn);
|
print_caddr_t, diag_warn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1051,5 +1051,5 @@ start_periodic_resettodr(void *arg __unused)
|
|||||||
periodic_resettodr, NULL);
|
periodic_resettodr, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSINIT(periodic_resettodr, SI_SUB_RUN_SCHEDULER, SI_ORDER_MIDDLE,
|
SYSINIT(periodic_resettodr, SI_SUB_LAST, SI_ORDER_MIDDLE,
|
||||||
start_periodic_resettodr, NULL);
|
start_periodic_resettodr, NULL);
|
||||||
|
@ -143,7 +143,7 @@ static struct kproc_desc sched_kp = {
|
|||||||
schedcpu_thread,
|
schedcpu_thread,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
SYSINIT(schedcpu, SI_SUB_RUN_SCHEDULER, SI_ORDER_FIRST, kproc_start,
|
SYSINIT(schedcpu, SI_SUB_LAST, SI_ORDER_FIRST, kproc_start,
|
||||||
&sched_kp);
|
&sched_kp);
|
||||||
SYSINIT(sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL);
|
SYSINIT(sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL);
|
||||||
|
|
||||||
|
@ -68,17 +68,17 @@ _module_run(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define module_init(fn) \
|
#define module_init(fn) \
|
||||||
SYSINIT(fn, SI_SUB_RUN_SCHEDULER, SI_ORDER_FIRST, _module_run, (fn))
|
SYSINIT(fn, SI_SUB_LAST, SI_ORDER_FIRST, _module_run, (fn))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX This is a freebsdism designed to work around not having a module
|
* XXX This is a freebsdism designed to work around not having a module
|
||||||
* load order resolver built in.
|
* load order resolver built in.
|
||||||
*/
|
*/
|
||||||
#define module_init_order(fn, order) \
|
#define module_init_order(fn, order) \
|
||||||
SYSINIT(fn, SI_SUB_RUN_SCHEDULER, (order), _module_run, (fn))
|
SYSINIT(fn, SI_SUB_LAST, (order), _module_run, (fn))
|
||||||
|
|
||||||
#define module_exit(fn) \
|
#define module_exit(fn) \
|
||||||
SYSUNINIT(fn, SI_SUB_RUN_SCHEDULER, SI_ORDER_FIRST, _module_run, (fn))
|
SYSUNINIT(fn, SI_SUB_LAST, SI_ORDER_FIRST, _module_run, (fn))
|
||||||
|
|
||||||
#define module_get(module)
|
#define module_get(module)
|
||||||
#define module_put(module)
|
#define module_put(module)
|
||||||
|
@ -79,7 +79,7 @@ extern volatile int ticks;
|
|||||||
* enumeration values are explicit rather than implicit to provide
|
* enumeration values are explicit rather than implicit to provide
|
||||||
* for binary compatibility with inserted elements.
|
* for binary compatibility with inserted elements.
|
||||||
*
|
*
|
||||||
* The SI_SUB_RUN_SCHEDULER value must have the highest lexical value.
|
* The SI_SUB_LAST value must have the highest lexical value.
|
||||||
*
|
*
|
||||||
* The SI_SUB_SWAP values represent a value used by
|
* The SI_SUB_SWAP values represent a value used by
|
||||||
* the BSD 4.4Lite but not by FreeBSD; it is maintained in dependent
|
* the BSD 4.4Lite but not by FreeBSD; it is maintained in dependent
|
||||||
@ -165,7 +165,7 @@ enum sysinit_sub_id {
|
|||||||
SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs*/
|
SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs*/
|
||||||
SI_SUB_SMP = 0xf000000, /* start the APs*/
|
SI_SUB_SMP = 0xf000000, /* start the APs*/
|
||||||
SI_SUB_RACCTD = 0xf100000, /* start raccd*/
|
SI_SUB_RACCTD = 0xf100000, /* start raccd*/
|
||||||
SI_SUB_RUN_SCHEDULER = 0xfffffff /* scheduler*/
|
SI_SUB_LAST = 0xfffffff /* final initialization */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ static void name ## _add_proc(void *dummy __unused) \
|
|||||||
#name, CTLTYPE_LONG|CTLFLAG_RD|CTLFLAG_MPSAFE, \
|
#name, CTLTYPE_LONG|CTLFLAG_RD|CTLFLAG_MPSAFE, \
|
||||||
ptr, 0, sysctl_dpcpu_long, "LU", descr); \
|
ptr, 0, sysctl_dpcpu_long, "LU", descr); \
|
||||||
} \
|
} \
|
||||||
SYSINIT(name, SI_SUB_RUN_SCHEDULER, SI_ORDER_MIDDLE, name ## _add_proc, NULL);
|
SYSINIT(name, SI_SUB_LAST, SI_ORDER_MIDDLE, name ## _add_proc, NULL);
|
||||||
|
|
||||||
#define SCHED_STAT_DEFINE(name, descr) \
|
#define SCHED_STAT_DEFINE(name, descr) \
|
||||||
DPCPU_DEFINE(unsigned long, name); \
|
DPCPU_DEFINE(unsigned long, name); \
|
||||||
|
@ -147,6 +147,7 @@ int swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred);
|
|||||||
void swap_reserve_force(vm_ooffset_t incr);
|
void swap_reserve_force(vm_ooffset_t incr);
|
||||||
void swap_release(vm_ooffset_t decr);
|
void swap_release(vm_ooffset_t decr);
|
||||||
void swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred);
|
void swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred);
|
||||||
|
void swapper(void);
|
||||||
|
|
||||||
#endif /* VM_H */
|
#endif /* VM_H */
|
||||||
|
|
||||||
|
@ -96,16 +96,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <vm/vm_pager.h>
|
#include <vm/vm_pager.h>
|
||||||
#include <vm/swap_pager.h>
|
#include <vm/swap_pager.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* System initialization
|
|
||||||
*
|
|
||||||
* THIS MUST BE THE LAST INITIALIZATION ITEM!!!
|
|
||||||
*
|
|
||||||
* Note: run scheduling should be divorced from the vm system.
|
|
||||||
*/
|
|
||||||
static void scheduler(void *);
|
|
||||||
SYSINIT(scheduler, SI_SUB_RUN_SCHEDULER, SI_ORDER_ANY, scheduler, NULL);
|
|
||||||
|
|
||||||
#ifndef NO_SWAPPING
|
#ifndef NO_SWAPPING
|
||||||
static int swapout(struct proc *);
|
static int swapout(struct proc *);
|
||||||
static void swapclear(struct proc *);
|
static void swapclear(struct proc *);
|
||||||
@ -695,10 +685,8 @@ faultin(p)
|
|||||||
*
|
*
|
||||||
* Giant is held on entry.
|
* Giant is held on entry.
|
||||||
*/
|
*/
|
||||||
/* ARGSUSED*/
|
void
|
||||||
static void
|
swapper(void)
|
||||||
scheduler(dummy)
|
|
||||||
void *dummy;
|
|
||||||
{
|
{
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
struct thread *td;
|
struct thread *td;
|
||||||
@ -708,9 +696,6 @@ scheduler(dummy)
|
|||||||
int ppri;
|
int ppri;
|
||||||
int pri;
|
int pri;
|
||||||
|
|
||||||
mtx_assert(&Giant, MA_OWNED | MA_NOTRECURSED);
|
|
||||||
mtx_unlock(&Giant);
|
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
if (vm_page_count_min()) {
|
if (vm_page_count_min()) {
|
||||||
VM_WAIT;
|
VM_WAIT;
|
||||||
@ -761,7 +746,7 @@ loop:
|
|||||||
* Nothing to do, back to sleep.
|
* Nothing to do, back to sleep.
|
||||||
*/
|
*/
|
||||||
if ((p = pp) == NULL) {
|
if ((p = pp) == NULL) {
|
||||||
tsleep(&proc0, PVM, "sched", MAXSLP * hz / 2);
|
tsleep(&proc0, PVM, "swapin", MAXSLP * hz / 2);
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
PROC_LOCK(p);
|
PROC_LOCK(p);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user