Move 4bsd specific experimental IP code into the 4bsd file.
Move the sysctls into kern.sched
This commit is contained in:
parent
df6a77ddcb
commit
82a1dfc16d
@ -101,6 +101,7 @@ static void sched_setup(void *dummy);
|
|||||||
static void maybe_resched(struct thread *td);
|
static void maybe_resched(struct thread *td);
|
||||||
static void updatepri(struct ksegrp *kg);
|
static void updatepri(struct ksegrp *kg);
|
||||||
static void resetpriority(struct ksegrp *kg);
|
static void resetpriority(struct ksegrp *kg);
|
||||||
|
static int forward_wakeup(int cpunum);
|
||||||
|
|
||||||
static struct kproc_desc sched_kp = {
|
static struct kproc_desc sched_kp = {
|
||||||
"schedcpu",
|
"schedcpu",
|
||||||
@ -160,6 +161,44 @@ SYSCTL_PROC(_kern_sched, OID_AUTO, quantum, CTLTYPE_INT | CTLFLAG_RW,
|
|||||||
0, sizeof sched_quantum, sysctl_kern_quantum, "I",
|
0, sizeof sched_quantum, sysctl_kern_quantum, "I",
|
||||||
"Roundrobin scheduling quantum in microseconds");
|
"Roundrobin scheduling quantum in microseconds");
|
||||||
|
|
||||||
|
/* Enable forwarding of wakeups to all other cpus */
|
||||||
|
SYSCTL_NODE(_kern_sched, OID_AUTO, ipiwakeup, CTLFLAG_RD, NULL, "Kernel SMP");
|
||||||
|
|
||||||
|
static int forward_wakeup_enabled = 0;
|
||||||
|
SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, enabled, CTLFLAG_RW,
|
||||||
|
&forward_wakeup_enabled, 0,
|
||||||
|
"Forwarding of wakeup to idle CPUs");
|
||||||
|
|
||||||
|
static int forward_wakeups_requested = 0;
|
||||||
|
SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, requested, CTLFLAG_RD,
|
||||||
|
&forward_wakeups_requested, 0,
|
||||||
|
"Requests for Forwarding of wakeup to idle CPUs");
|
||||||
|
|
||||||
|
static int forward_wakeups_delivered = 0;
|
||||||
|
SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, delivered, CTLFLAG_RD,
|
||||||
|
&forward_wakeups_delivered, 0,
|
||||||
|
"Completed Forwarding of wakeup to idle CPUs");
|
||||||
|
|
||||||
|
static int forward_wakeup_use_mask = 0;
|
||||||
|
SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, usemask, CTLFLAG_RW,
|
||||||
|
&forward_wakeup_use_mask, 0,
|
||||||
|
"Use the mask of idle cpus");
|
||||||
|
|
||||||
|
static int forward_wakeup_use_loop = 0;
|
||||||
|
SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, useloop, CTLFLAG_RW,
|
||||||
|
&forward_wakeup_use_loop, 0,
|
||||||
|
"Use a loop to find idle cpus");
|
||||||
|
|
||||||
|
static int forward_wakeup_use_single = 0;
|
||||||
|
SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, onecpu, CTLFLAG_RW,
|
||||||
|
&forward_wakeup_use_single, 0,
|
||||||
|
"Only signal one idle cpu");
|
||||||
|
|
||||||
|
static int forward_wakeup_use_htt = 0;
|
||||||
|
SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, htt2, CTLFLAG_RW,
|
||||||
|
&forward_wakeup_use_htt, 0,
|
||||||
|
"account for htt");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Arrange to reschedule if necessary, taking the priorities and
|
* Arrange to reschedule if necessary, taking the priorities and
|
||||||
* schedulers into account.
|
* schedulers into account.
|
||||||
@ -694,6 +733,93 @@ sched_wakeup(struct thread *td)
|
|||||||
setrunqueue(td, SRQ_BORING);
|
setrunqueue(td, SRQ_BORING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* enable HTT_2 if you have a 2-way HTT cpu.*/
|
||||||
|
static int
|
||||||
|
forward_wakeup(int cpunum)
|
||||||
|
{
|
||||||
|
cpumask_t map, me, dontuse;
|
||||||
|
cpumask_t map2;
|
||||||
|
struct pcpu *pc;
|
||||||
|
cpumask_t id, map3;
|
||||||
|
|
||||||
|
mtx_assert(&sched_lock, MA_OWNED);
|
||||||
|
|
||||||
|
CTR0(KTR_SMP, "forward_wakeup()");
|
||||||
|
|
||||||
|
if ((!forward_wakeup_enabled) ||
|
||||||
|
(forward_wakeup_use_mask == 0 && forward_wakeup_use_loop == 0))
|
||||||
|
return (0);
|
||||||
|
if (!smp_started || cold || panicstr)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
forward_wakeups_requested++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check the idle mask we received against what we calculated before
|
||||||
|
* in the old version.
|
||||||
|
*/
|
||||||
|
me = PCPU_GET(cpumask);
|
||||||
|
/*
|
||||||
|
* don't bother if we should be doing it ourself..
|
||||||
|
*/
|
||||||
|
if ((me & idle_cpus_mask) && (cpunum == NOCPU || me == (1 << cpunum)))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
dontuse = me | stopped_cpus | hlt_cpus_mask;
|
||||||
|
map3 = 0;
|
||||||
|
if (forward_wakeup_use_loop) {
|
||||||
|
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
|
||||||
|
id = pc->pc_cpumask;
|
||||||
|
if ( (id & dontuse) == 0 &&
|
||||||
|
pc->pc_curthread == pc->pc_idlethread) {
|
||||||
|
map3 |= id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forward_wakeup_use_mask) {
|
||||||
|
map = 0;
|
||||||
|
map = idle_cpus_mask & ~dontuse;
|
||||||
|
|
||||||
|
/* If they are both on, compare and use loop if different */
|
||||||
|
if (forward_wakeup_use_loop) {
|
||||||
|
if (map != map3) {
|
||||||
|
printf("map (%02X) != map3 (%02X)\n",
|
||||||
|
map, map3);
|
||||||
|
map = map3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
map = map3;
|
||||||
|
}
|
||||||
|
/* If we only allow a specific CPU, then mask off all the others */
|
||||||
|
if (cpunum != NOCPU) {
|
||||||
|
KASSERT((cpunum <= mp_maxcpus),("forward_wakeup: bad cpunum."));
|
||||||
|
map &= (1 << cpunum);
|
||||||
|
} else {
|
||||||
|
/* Try choose an idle die. */
|
||||||
|
if (forward_wakeup_use_htt) {
|
||||||
|
map2 = (map & (map >> 1)) & 0x5555;
|
||||||
|
if (map2) {
|
||||||
|
map = map2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set only one bit */
|
||||||
|
if (forward_wakeup_use_single) {
|
||||||
|
map = map & ((~map) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (map) {
|
||||||
|
forward_wakeups_delivered++;
|
||||||
|
ipi_selected(map, IPI_AST);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
if (cpunum == NOCPU)
|
||||||
|
printf("forward_wakeup: Idle processor not found\n");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sched_add(struct thread *td, int flags)
|
sched_add(struct thread *td, int flags)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ cpumask_t logical_cpus_mask;
|
|||||||
|
|
||||||
void (*cpustop_restartfunc)(void);
|
void (*cpustop_restartfunc)(void);
|
||||||
#endif
|
#endif
|
||||||
/* amazingly enough this is used in non SMP code XXX BUG! */
|
/* This is used in modules that need to work in both SMP and UP. */
|
||||||
cpumask_t all_cpus;
|
cpumask_t all_cpus;
|
||||||
|
|
||||||
int mp_ncpus;
|
int mp_ncpus;
|
||||||
@ -102,46 +102,6 @@ SYSCTL_INT(_kern_smp, OID_AUTO, forward_roundrobin_enabled, CTLFLAG_RW,
|
|||||||
&forward_roundrobin_enabled, 0,
|
&forward_roundrobin_enabled, 0,
|
||||||
"Forwarding of roundrobin to all other CPUs");
|
"Forwarding of roundrobin to all other CPUs");
|
||||||
|
|
||||||
#ifdef SCHED_4BSD
|
|
||||||
/* Enable forwarding of wakeups to all other cpus */
|
|
||||||
SYSCTL_NODE(_kern_smp, OID_AUTO, ipiwakeup, CTLFLAG_RD, NULL, "Kernel SMP");
|
|
||||||
|
|
||||||
static int forward_wakeup_enabled = 0;
|
|
||||||
SYSCTL_INT(_kern_smp_ipiwakeup, OID_AUTO, enabled, CTLFLAG_RW,
|
|
||||||
&forward_wakeup_enabled, 0,
|
|
||||||
"Forwarding of wakeup to idle CPUs");
|
|
||||||
|
|
||||||
static int forward_wakeups_requested = 0;
|
|
||||||
SYSCTL_INT(_kern_smp_ipiwakeup, OID_AUTO, requested, CTLFLAG_RD,
|
|
||||||
&forward_wakeups_requested, 0,
|
|
||||||
"Requests for Forwarding of wakeup to idle CPUs");
|
|
||||||
|
|
||||||
static int forward_wakeups_delivered = 0;
|
|
||||||
SYSCTL_INT(_kern_smp_ipiwakeup, OID_AUTO, delivered, CTLFLAG_RD,
|
|
||||||
&forward_wakeups_delivered, 0,
|
|
||||||
"Completed Forwarding of wakeup to idle CPUs");
|
|
||||||
|
|
||||||
static int forward_wakeup_use_mask = 0;
|
|
||||||
SYSCTL_INT(_kern_smp_ipiwakeup, OID_AUTO, usemask, CTLFLAG_RW,
|
|
||||||
&forward_wakeup_use_mask, 0,
|
|
||||||
"Use the mask of idle cpus");
|
|
||||||
|
|
||||||
static int forward_wakeup_use_loop = 0;
|
|
||||||
SYSCTL_INT(_kern_smp_ipiwakeup, OID_AUTO, useloop, CTLFLAG_RW,
|
|
||||||
&forward_wakeup_use_loop, 0,
|
|
||||||
"Use a loop to find idle cpus");
|
|
||||||
|
|
||||||
static int forward_wakeup_use_single = 0;
|
|
||||||
SYSCTL_INT(_kern_smp_ipiwakeup, OID_AUTO, onecpu, CTLFLAG_RW,
|
|
||||||
&forward_wakeup_use_single, 0,
|
|
||||||
"Only signal one idle cpu");
|
|
||||||
|
|
||||||
static int forward_wakeup_use_htt = 0;
|
|
||||||
SYSCTL_INT(_kern_smp_ipiwakeup, OID_AUTO, htt2, CTLFLAG_RW,
|
|
||||||
&forward_wakeup_use_htt, 0,
|
|
||||||
"account for htt");
|
|
||||||
|
|
||||||
#endif /* SCHED_4BSD */
|
|
||||||
/* Variables needed for SMP rendezvous. */
|
/* Variables needed for SMP rendezvous. */
|
||||||
static void (*smp_rv_setup_func)(void *arg);
|
static void (*smp_rv_setup_func)(void *arg);
|
||||||
static void (*smp_rv_action_func)(void *arg);
|
static void (*smp_rv_action_func)(void *arg);
|
||||||
@ -249,95 +209,6 @@ forward_roundrobin(void)
|
|||||||
ipi_selected(map, IPI_AST);
|
ipi_selected(map, IPI_AST);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCHED_4BSD
|
|
||||||
/* enable HTT_2 if you have a 2-way HTT cpu.*/
|
|
||||||
int
|
|
||||||
forward_wakeup(int cpunum)
|
|
||||||
{
|
|
||||||
cpumask_t map, me, dontuse;
|
|
||||||
cpumask_t map2;
|
|
||||||
struct pcpu *pc;
|
|
||||||
cpumask_t id, map3;
|
|
||||||
|
|
||||||
mtx_assert(&sched_lock, MA_OWNED);
|
|
||||||
|
|
||||||
CTR0(KTR_SMP, "forward_wakeup()");
|
|
||||||
|
|
||||||
if ((!forward_wakeup_enabled) ||
|
|
||||||
(forward_wakeup_use_mask == 0 && forward_wakeup_use_loop == 0))
|
|
||||||
return (0);
|
|
||||||
if (!smp_started || cold || panicstr)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
forward_wakeups_requested++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* check the idle mask we received against what we calculated before
|
|
||||||
* in the old version.
|
|
||||||
*/
|
|
||||||
me = PCPU_GET(cpumask);
|
|
||||||
/*
|
|
||||||
* don't bother if we should be doing it ourself..
|
|
||||||
*/
|
|
||||||
if ((me & idle_cpus_mask) && (cpunum == NOCPU || me == (1 << cpunum)))
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
dontuse = me | stopped_cpus | hlt_cpus_mask;
|
|
||||||
map3 = 0;
|
|
||||||
if (forward_wakeup_use_loop) {
|
|
||||||
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
|
|
||||||
id = pc->pc_cpumask;
|
|
||||||
if ( (id & dontuse) == 0 &&
|
|
||||||
pc->pc_curthread == pc->pc_idlethread) {
|
|
||||||
map3 |= id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forward_wakeup_use_mask) {
|
|
||||||
map = 0;
|
|
||||||
map = idle_cpus_mask & ~dontuse;
|
|
||||||
|
|
||||||
/* If they are both on, compare and use loop if different */
|
|
||||||
if (forward_wakeup_use_loop) {
|
|
||||||
if (map != map3) {
|
|
||||||
printf("map (%02X) != map3 (%02X)\n",
|
|
||||||
map, map3);
|
|
||||||
map = map3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
map = map3;
|
|
||||||
}
|
|
||||||
/* If we only allow a specific CPU, then mask off all the others */
|
|
||||||
if (cpunum != NOCPU) {
|
|
||||||
KASSERT((cpunum <= mp_maxcpus),("forward_wakeup: bad cpunum."));
|
|
||||||
map &= (1 << cpunum);
|
|
||||||
} else {
|
|
||||||
/* Try choose an idle die. */
|
|
||||||
if (forward_wakeup_use_htt) {
|
|
||||||
map2 = (map & (map >> 1)) & 0x5555;
|
|
||||||
if (map2) {
|
|
||||||
map = map2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set only one bit */
|
|
||||||
if (forward_wakeup_use_single) {
|
|
||||||
map = map & ((~map) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (map) {
|
|
||||||
forward_wakeups_delivered++;
|
|
||||||
ipi_selected(map, IPI_AST);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (cpunum == NOCPU)
|
|
||||||
printf("forward_wakeup: Idle processor not found\n");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
#endif /* SCHED_4BSD */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When called the executing CPU will send an IPI to all other CPUs
|
* When called the executing CPU will send an IPI to all other CPUs
|
||||||
* requesting that they halt execution.
|
* requesting that they halt execution.
|
||||||
|
@ -96,7 +96,6 @@ void cpu_mp_start(void);
|
|||||||
|
|
||||||
void forward_signal(struct thread *);
|
void forward_signal(struct thread *);
|
||||||
void forward_roundrobin(void);
|
void forward_roundrobin(void);
|
||||||
int forward_wakeup(int cpunum);
|
|
||||||
int restart_cpus(cpumask_t);
|
int restart_cpus(cpumask_t);
|
||||||
int stop_cpus(cpumask_t);
|
int stop_cpus(cpumask_t);
|
||||||
void smp_rendezvous_action(void);
|
void smp_rendezvous_action(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user