- Implement a mechanism for allowing schedulers to place scheduler dependant
data in the scheduler independant structures (proc, ksegrp, kse, thread). - Implement unused stubs for this mechanism in sched_4bsd. Approved by: re Reviewed by: luigi, trb Tested on: x86, alpha
This commit is contained in:
parent
075c3f0781
commit
de028f5a4a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=107126
@ -64,6 +64,7 @@
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/vmmeter.h>
|
||||
@ -316,6 +317,11 @@ proc0_init(void *dummy __unused)
|
||||
ke = &kse0;
|
||||
kg = &ksegrp0;
|
||||
|
||||
ke->ke_sched = kse0_sched;
|
||||
kg->kg_sched = ksegrp0_sched;
|
||||
p->p_sched = proc0_sched;
|
||||
td->td_sched = thread0_sched;
|
||||
|
||||
/*
|
||||
* Initialize magic number.
|
||||
*/
|
||||
|
@ -39,9 +39,10 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/kse.h>
|
||||
@ -101,9 +102,6 @@ thread_ctor(void *mem, int size, void *arg)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
td->td_state = TDS_INACTIVE;
|
||||
td->td_flags |= TDF_UNBOUND;
|
||||
@ -117,9 +115,6 @@ thread_dtor(void *mem, int size, void *arg)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
|
||||
#ifdef INVARIANTS
|
||||
@ -152,14 +147,12 @@ thread_init(void *mem, int size)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
mtx_lock(&Giant);
|
||||
pmap_new_thread(td, 0);
|
||||
mtx_unlock(&Giant);
|
||||
cpu_thread_setup(td);
|
||||
td->td_sched = (struct td_sched *)&td[1];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -170,12 +163,31 @@ thread_fini(void *mem, int size)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
pmap_dispose_thread(td);
|
||||
}
|
||||
/*
|
||||
* Initialize type-stable parts of a kse (when newly created).
|
||||
*/
|
||||
static void
|
||||
kse_init(void *mem, int size)
|
||||
{
|
||||
struct kse *ke;
|
||||
|
||||
ke = (struct kse *)mem;
|
||||
ke->ke_sched = (struct ke_sched *)&ke[1];
|
||||
}
|
||||
/*
|
||||
* Initialize type-stable parts of a ksegrp (when newly created).
|
||||
*/
|
||||
static void
|
||||
ksegrp_init(void *mem, int size)
|
||||
{
|
||||
struct ksegrp *kg;
|
||||
|
||||
kg = (struct ksegrp *)mem;
|
||||
kg->kg_sched = (struct kg_sched *)&kg[1];
|
||||
}
|
||||
|
||||
/*
|
||||
* KSE is linked onto the idle queue.
|
||||
@ -609,7 +621,7 @@ threadinit(void)
|
||||
{
|
||||
|
||||
#ifndef __ia64__
|
||||
thread_zone = uma_zcreate("THREAD", sizeof (struct thread),
|
||||
thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(),
|
||||
thread_ctor, thread_dtor, thread_init, thread_fini,
|
||||
UMA_ALIGN_CACHE, 0);
|
||||
#else
|
||||
@ -620,16 +632,16 @@ threadinit(void)
|
||||
* in the system startup while contigmalloc() still works. Once we
|
||||
* have them, keep them. Sigh.
|
||||
*/
|
||||
thread_zone = uma_zcreate("THREAD", sizeof (struct thread),
|
||||
thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(),
|
||||
thread_ctor, thread_dtor, thread_init, thread_fini,
|
||||
UMA_ALIGN_CACHE, UMA_ZONE_NOFREE);
|
||||
uma_prealloc(thread_zone, 512); /* XXX arbitary */
|
||||
#endif
|
||||
ksegrp_zone = uma_zcreate("KSEGRP", sizeof (struct ksegrp),
|
||||
NULL, NULL, NULL, NULL,
|
||||
ksegrp_zone = uma_zcreate("KSEGRP", sched_sizeof_ksegrp(),
|
||||
NULL, NULL, ksegrp_init, NULL,
|
||||
UMA_ALIGN_CACHE, 0);
|
||||
kse_zone = uma_zcreate("KSE", sizeof (struct kse),
|
||||
NULL, NULL, NULL, NULL,
|
||||
kse_zone = uma_zcreate("KSE", sched_sizeof_kse(),
|
||||
NULL, NULL, kse_init, NULL,
|
||||
UMA_ALIGN_CACHE, 0);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kse.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/smp.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/filedesc.h>
|
||||
@ -123,7 +124,7 @@ procinit()
|
||||
LIST_INIT(&zombproc);
|
||||
pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash);
|
||||
pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash);
|
||||
proc_zone = uma_zcreate("PROC", sizeof (struct proc),
|
||||
proc_zone = uma_zcreate("PROC", sched_sizeof_proc(),
|
||||
proc_ctor, proc_dtor, proc_init, proc_fini,
|
||||
UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
|
||||
uihashinit();
|
||||
@ -137,8 +138,6 @@ proc_ctor(void *mem, int size, void *arg)
|
||||
{
|
||||
struct proc *p;
|
||||
|
||||
KASSERT((size == sizeof(struct proc)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct proc)));
|
||||
p = (struct proc *)mem;
|
||||
}
|
||||
|
||||
@ -154,8 +153,6 @@ proc_dtor(void *mem, int size, void *arg)
|
||||
struct kse *ke;
|
||||
|
||||
/* INVARIANTS checks go here */
|
||||
KASSERT((size == sizeof(struct proc)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct proc)));
|
||||
p = (struct proc *)mem;
|
||||
KASSERT((p->p_numthreads == 1),
|
||||
("bad number of threads in exiting process"));
|
||||
@ -194,9 +191,8 @@ proc_init(void *mem, int size)
|
||||
struct ksegrp *kg;
|
||||
struct kse *ke;
|
||||
|
||||
KASSERT((size == sizeof(struct proc)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct proc)));
|
||||
p = (struct proc *)mem;
|
||||
p->p_sched = (struct p_sched *)&p[1];
|
||||
vm_proc_new(p);
|
||||
td = thread_alloc();
|
||||
ke = kse_alloc();
|
||||
@ -215,8 +211,6 @@ proc_fini(void *mem, int size)
|
||||
struct ksegrp *kg;
|
||||
struct kse *ke;
|
||||
|
||||
KASSERT((size == sizeof(struct proc)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct proc)));
|
||||
p = (struct proc *)mem;
|
||||
KASSERT((p->p_numthreads == 1),
|
||||
("bad number of threads in freeing process"));
|
||||
|
@ -39,9 +39,10 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/kse.h>
|
||||
@ -101,9 +102,6 @@ thread_ctor(void *mem, int size, void *arg)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
td->td_state = TDS_INACTIVE;
|
||||
td->td_flags |= TDF_UNBOUND;
|
||||
@ -117,9 +115,6 @@ thread_dtor(void *mem, int size, void *arg)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
|
||||
#ifdef INVARIANTS
|
||||
@ -152,14 +147,12 @@ thread_init(void *mem, int size)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
mtx_lock(&Giant);
|
||||
pmap_new_thread(td, 0);
|
||||
mtx_unlock(&Giant);
|
||||
cpu_thread_setup(td);
|
||||
td->td_sched = (struct td_sched *)&td[1];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -170,12 +163,31 @@ thread_fini(void *mem, int size)
|
||||
{
|
||||
struct thread *td;
|
||||
|
||||
KASSERT((size == sizeof(struct thread)),
|
||||
("size mismatch: %d != %d\n", size, (int)sizeof(struct thread)));
|
||||
|
||||
td = (struct thread *)mem;
|
||||
pmap_dispose_thread(td);
|
||||
}
|
||||
/*
|
||||
* Initialize type-stable parts of a kse (when newly created).
|
||||
*/
|
||||
static void
|
||||
kse_init(void *mem, int size)
|
||||
{
|
||||
struct kse *ke;
|
||||
|
||||
ke = (struct kse *)mem;
|
||||
ke->ke_sched = (struct ke_sched *)&ke[1];
|
||||
}
|
||||
/*
|
||||
* Initialize type-stable parts of a ksegrp (when newly created).
|
||||
*/
|
||||
static void
|
||||
ksegrp_init(void *mem, int size)
|
||||
{
|
||||
struct ksegrp *kg;
|
||||
|
||||
kg = (struct ksegrp *)mem;
|
||||
kg->kg_sched = (struct kg_sched *)&kg[1];
|
||||
}
|
||||
|
||||
/*
|
||||
* KSE is linked onto the idle queue.
|
||||
@ -609,7 +621,7 @@ threadinit(void)
|
||||
{
|
||||
|
||||
#ifndef __ia64__
|
||||
thread_zone = uma_zcreate("THREAD", sizeof (struct thread),
|
||||
thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(),
|
||||
thread_ctor, thread_dtor, thread_init, thread_fini,
|
||||
UMA_ALIGN_CACHE, 0);
|
||||
#else
|
||||
@ -620,16 +632,16 @@ threadinit(void)
|
||||
* in the system startup while contigmalloc() still works. Once we
|
||||
* have them, keep them. Sigh.
|
||||
*/
|
||||
thread_zone = uma_zcreate("THREAD", sizeof (struct thread),
|
||||
thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(),
|
||||
thread_ctor, thread_dtor, thread_init, thread_fini,
|
||||
UMA_ALIGN_CACHE, UMA_ZONE_NOFREE);
|
||||
uma_prealloc(thread_zone, 512); /* XXX arbitary */
|
||||
#endif
|
||||
ksegrp_zone = uma_zcreate("KSEGRP", sizeof (struct ksegrp),
|
||||
NULL, NULL, NULL, NULL,
|
||||
ksegrp_zone = uma_zcreate("KSEGRP", sched_sizeof_ksegrp(),
|
||||
NULL, NULL, ksegrp_init, NULL,
|
||||
UMA_ALIGN_CACHE, 0);
|
||||
kse_zone = uma_zcreate("KSE", sizeof (struct kse),
|
||||
NULL, NULL, NULL, NULL,
|
||||
kse_zone = uma_zcreate("KSE", sched_sizeof_kse(),
|
||||
NULL, NULL, kse_init, NULL,
|
||||
UMA_ALIGN_CACHE, 0);
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,10 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/sx.h>
|
||||
|
||||
struct ke_sched *kse0_sched = NULL;
|
||||
struct kg_sched *ksegrp0_sched = NULL;
|
||||
struct p_sched *proc0_sched = NULL;
|
||||
struct td_sched *thread0_sched = NULL;
|
||||
|
||||
static int sched_quantum; /* Roundrobin scheduling quantum in ticks. */
|
||||
#define SCHED_QUANTUM (hz / 10); /* Default sched quantum */
|
||||
@ -618,3 +622,24 @@ sched_userret(struct thread *td)
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
sched_sizeof_kse(void)
|
||||
{
|
||||
return (sizeof(struct kse));
|
||||
}
|
||||
int
|
||||
sched_sizeof_ksegrp(void)
|
||||
{
|
||||
return (sizeof(struct ksegrp));
|
||||
}
|
||||
int
|
||||
sched_sizeof_proc(void)
|
||||
{
|
||||
return (sizeof(struct proc));
|
||||
}
|
||||
int
|
||||
sched_sizeof_thread(void)
|
||||
{
|
||||
return (sizeof(struct thread));
|
||||
}
|
||||
|
@ -158,7 +158,11 @@ struct pargs {
|
||||
* for write access.
|
||||
*/
|
||||
struct ithd;
|
||||
struct ke_sched;
|
||||
struct kg_sched;
|
||||
struct nlminfo;
|
||||
struct p_sched;
|
||||
struct td_sched;
|
||||
struct trapframe;
|
||||
|
||||
/*
|
||||
@ -321,6 +325,7 @@ struct thread {
|
||||
vm_offset_t td_altkstack; /* Kernel VA of alternate kstack. */
|
||||
int td_altkstack_pages; /* Size of the alternate kstack */
|
||||
struct mdthread td_md; /* (k) Any machine-dependent fields. */
|
||||
struct td_sched *td_sched; /* Scheduler specific data */
|
||||
};
|
||||
/* flags kept in td_flags */
|
||||
#define TDF_UNBOUND 0x000001 /* May give away the kse, uses the kg runq. */
|
||||
@ -442,6 +447,7 @@ struct kse {
|
||||
struct thread *ke_tdspare; /* spare thread for upcalls */
|
||||
#define ke_endzero ke_dummy
|
||||
u_char ke_dummy;
|
||||
struct ke_sched *ke_sched; /* Scheduler specific data */
|
||||
};
|
||||
|
||||
/* flags kept in ke_flags */
|
||||
@ -498,6 +504,7 @@ struct ksegrp {
|
||||
int kg_numthreads; /* Num threads in total */
|
||||
int kg_idle_kses; /* num KSEs idle */
|
||||
int kg_kses; /* Num KSEs in group. */
|
||||
struct kg_sched *kg_sched; /* Scheduler specific data */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -594,6 +601,7 @@ struct proc {
|
||||
struct proc *p_leader; /* (b) */
|
||||
void *p_emuldata; /* (c) Emulator state data. */
|
||||
struct label p_label; /* process (not subject) MAC label */
|
||||
struct p_sched *p_sched; /* Scheduler specific data */
|
||||
};
|
||||
|
||||
#define p_rlimit p_limit->pl_rlimit
|
||||
|
@ -62,4 +62,18 @@ void sched_add(struct kse *ke);
|
||||
void sched_rem(struct kse *ke);
|
||||
struct kse *sched_choose(void);
|
||||
|
||||
/*
|
||||
* These procedures tell the process data structure allocation code how
|
||||
* many bytes to actually allocate.
|
||||
*/
|
||||
int sched_sizeof_kse(void);
|
||||
int sched_sizeof_ksegrp(void);
|
||||
int sched_sizeof_proc(void);
|
||||
int sched_sizeof_thread(void);
|
||||
|
||||
extern struct ke_sched *kse0_sched;
|
||||
extern struct kg_sched *ksegrp0_sched;
|
||||
extern struct p_sched *proc0_sched;
|
||||
extern struct td_sched *thread0_sched;
|
||||
|
||||
#endif /* !_SYS_SCHED_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user