mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-12 09:58:36 +00:00
Add scheduler CORE, the work I have done half a year ago, recent,
I picked it up again. The scheduler is forked from ULE, but the algorithm to detect an interactive process is almost completely different with ULE, it comes from Linux paper "Understanding the Linux 2.6.8.1 CPU Scheduler", although I still use same word "score" as a priority boost in ULE scheduler. Briefly, the scheduler has following characteristic: 1. Timesharing process's nice value is seriously respected, timeslice and interaction detecting algorithm are based on nice value. 2. per-cpu scheduling queue and load balancing. 3. O(1) scheduling. 4. Some cpu affinity code in wakeup path. 5. Support POSIX SCHED_FIFO and SCHED_RR. Unlike scheduler 4BSD and ULE which using fuzzy RQ_PPQ, the scheduler uses 256 priority queues. Unlike ULE which using pull and push, the scheduelr uses pull method, the main reason is to let relative idle cpu do the work, but current the whole scheduler is protected by the big sched_lock, so the benefit is not visible, it really can be worse than nothing because all other cpu are locked out when we are doing balancing work, which the 4BSD scheduelr does not have this problem. The scheduler does not support hyperthreading very well, in fact, the scheduler does not make the difference between physical CPU and logical CPU, this should be improved in feature. The scheduler has priority inversion problem on MP machine, it is not good for realtime scheduling, it can cause realtime process starving. As a result, it seems the MySQL super-smack runs better on my Pentium-D machine when using libthr, despite on UP or SMP kernel.
This commit is contained in:
parent
05922cdfcc
commit
b41f1452d9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=159570
@ -28,6 +28,7 @@ makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
|
||||
|
||||
#options SCHED_ULE # ULE scheduler
|
||||
options SCHED_4BSD # 4BSD scheduler
|
||||
#options SCHED_CORE # CORE scheduler
|
||||
options PREEMPTION # Enable kernel thread preemption
|
||||
options INET # InterNETworking
|
||||
options INET6 # IPv6 communications protocols
|
||||
|
@ -166,6 +166,7 @@ options ROOTDEVNAME=\"ufs:da0s2e\"
|
||||
# over time.
|
||||
#
|
||||
options SCHED_4BSD
|
||||
#options SCHED_CORE
|
||||
#options SCHED_ULE
|
||||
|
||||
#####################################################################
|
||||
|
@ -1324,6 +1324,7 @@ kern/linker_if.m standard
|
||||
kern/md4c.c optional netsmb
|
||||
kern/md5c.c standard
|
||||
kern/sched_4bsd.c optional sched_4bsd
|
||||
kern/sched_core.c optional sched_core
|
||||
kern/sched_ule.c optional sched_ule
|
||||
kern/serdev_if.m optional puc | scc
|
||||
kern/subr_autoconf.c standard
|
||||
|
@ -128,6 +128,7 @@ PPS_SYNC opt_ntp.h
|
||||
PREEMPTION opt_sched.h
|
||||
QUOTA
|
||||
SCHED_4BSD opt_sched.h
|
||||
SCHED_CORE opt_sched.h
|
||||
SCHED_ULE opt_sched.h
|
||||
SHOW_BUSYBUFS
|
||||
SLEEPQUEUE_PROFILING
|
||||
|
@ -30,6 +30,7 @@ makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
|
||||
|
||||
#options SCHED_ULE # ULE scheduler
|
||||
options SCHED_4BSD # 4BSD scheduler
|
||||
#options SCHED_CORE # CORE scheduler
|
||||
options PREEMPTION # Enable kernel thread preemption
|
||||
options INET # InterNETworking
|
||||
options INET6 # IPv6 communications protocols
|
||||
|
@ -201,6 +201,7 @@ hardclock_cpu(int usermode)
|
||||
* Run current process's virtual and profile time, as needed.
|
||||
*/
|
||||
mtx_lock_spin_flags(&sched_lock, MTX_QUIET);
|
||||
sched_tick();
|
||||
if (p->p_flag & P_SA) {
|
||||
/* XXXKSE What to do? */
|
||||
} else {
|
||||
|
@ -308,7 +308,12 @@ adjustrunqueue( struct thread *td, int newpri)
|
||||
if ((td->td_proc->p_flag & P_HADTHREADS) == 0) {
|
||||
/* We only care about the kse in the run queue. */
|
||||
td->td_priority = newpri;
|
||||
if (ke->ke_rqindex != (newpri / RQ_PPQ)) {
|
||||
#ifndef SCHED_CORE
|
||||
if (ke->ke_rqindex != (newpri / RQ_PPQ))
|
||||
#else
|
||||
if (ke->ke_rqindex != newpri)
|
||||
#endif
|
||||
{
|
||||
sched_rem(td);
|
||||
sched_add(td, SRQ_BORING);
|
||||
}
|
||||
|
@ -1386,5 +1386,10 @@ sched_pctcpu(struct thread *td)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
sched_tick(void)
|
||||
{
|
||||
}
|
||||
#define KERN_SWITCH_INCLUDE 1
|
||||
#include "kern/kern_switch.c"
|
||||
|
2329
sys/kern/sched_core.c
Normal file
2329
sys/kern/sched_core.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -2007,5 +2007,10 @@ sched_sizeof_thread(void)
|
||||
{
|
||||
return (sizeof(struct thread) + sizeof(struct td_sched));
|
||||
}
|
||||
|
||||
void
|
||||
sched_tick(void)
|
||||
{
|
||||
}
|
||||
#define KERN_SWITCH_INCLUDE 1
|
||||
#include "kern/kern_switch.c"
|
||||
|
@ -78,6 +78,7 @@ void sched_wakeup(struct thread *td);
|
||||
void sched_add(struct thread *td, int flags);
|
||||
void sched_clock(struct thread *td);
|
||||
void sched_rem(struct thread *td);
|
||||
void sched_tick(void);
|
||||
|
||||
/*
|
||||
* Binding makes cpu affinity permanent while pinning is used to temporarily
|
||||
|
Loading…
Reference in New Issue
Block a user