Deleted Added
full compact
36c36
< __FBSDID("$FreeBSD: head/sys/kern/subr_smp.c 134416 2004-08-28 00:49:55Z obrien $");
---
> __FBSDID("$FreeBSD: head/sys/kern/subr_smp.c 134591 2004-09-01 06:42:02Z julian $");
51a52,53
> #include "opt_sched.h"
>
54a57,60
> cpumask_t all_cpus;
> cpumask_t idle_cpus_mask;
> cpumask_t hlt_cpus_mask;
> cpumask_t logical_cpus_mask;
65d70
< cpumask_t all_cpus;
98a104,143
> #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 */
205a251,272
> #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++;
>
206a274,340
> * 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 */
>
> /*