summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2011-07-04 12:04:52 +0000
committerattilio <attilio@FreeBSD.org>2011-07-04 12:04:52 +0000
commit364d0522f778b206262efce0932d6cea821879c6 (patch)
treef85bc4cd83b575a0c42f08d746e644f6dfc0e2ef /sys/mips
parent95ca970257de274a90a1a867048c5ace5acf532d (diff)
downloadFreeBSD-src-364d0522f778b206262efce0932d6cea821879c6.zip
FreeBSD-src-364d0522f778b206262efce0932d6cea821879c6.tar.gz
With retirement of cpumask_t and usage of cpuset_t for representing a
mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient. Remove them and replace their usage with custom pc_cpuid magic (as, atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))). This change is not targeted for MFC because of struct pcpu members removal and dependency by cpumask_t retirement. MD review by: marcel, marius, alc Tested by: pluknet MD testing by: marcel, marius, gonzo, andreast
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/mips/mp_machdep.c32
-rw-r--r--sys/mips/mips/pmap.c47
2 files changed, 34 insertions, 45 deletions
diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c
index 79a3476..2298124 100644
--- a/sys/mips/mips/mp_machdep.c
+++ b/sys/mips/mips/mp_machdep.c
@@ -75,8 +75,11 @@ ipi_send(struct pcpu *pc, int ipi)
void
ipi_all_but_self(int ipi)
{
+ cpuset_t other_cpus;
- ipi_selected(PCPU_GET(other_cpus), ipi);
+ other_cpus = all_cpus;
+ CPU_CLR(PCPU_GET(cpuid), &other_cpus);
+ ipi_selected(other_cpus, ipi);
}
/* Send an IPI to a set of cpus. */
@@ -86,7 +89,7 @@ ipi_selected(cpuset_t cpus, int ipi)
struct pcpu *pc;
STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) {
- if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) {
+ if (CPU_ISSET(pc->pc_cpuid, &cpus)) {
CTR3(KTR_SMP, "%s: pc: %p, ipi: %x\n", __func__, pc,
ipi);
ipi_send(pc, ipi);
@@ -109,13 +112,10 @@ ipi_cpu(int cpu, u_int ipi)
static int
mips_ipi_handler(void *arg)
{
- int cpu;
- cpuset_t cpumask;
- u_int ipi, ipi_bitmap;
+ u_int cpu, ipi, ipi_bitmap;
int bit;
cpu = PCPU_GET(cpuid);
- cpumask = PCPU_GET(cpumask);
platform_ipi_clear(); /* quiesce the pending ipi interrupt */
@@ -150,14 +150,14 @@ mips_ipi_handler(void *arg)
tlb_save();
/* Indicate we are stopped */
- CPU_OR_ATOMIC(&stopped_cpus, &cpumask);
+ CPU_SET_ATOMIC(cpu, &stopped_cpus);
/* Wait for restart */
- while (!CPU_OVERLAP(&started_cpus, &cpumask))
+ while (!CPU_ISSET(cpu, &started_cpus))
cpu_spinwait();
- CPU_NAND_ATOMIC(&started_cpus, &cpumask);
- CPU_NAND_ATOMIC(&stopped_cpus, &cpumask);
+ CPU_CLR_ATOMIC(cpu, &started_cpus);
+ CPU_CLR_ATOMIC(cpu, &stopped_cpus);
CTR0(KTR_SMP, "IPI_STOP (restart)");
break;
case IPI_PREEMPT:
@@ -243,7 +243,7 @@ void
cpu_mp_start(void)
{
int error, cpuid;
- cpuset_t cpumask, ocpus;
+ cpuset_t cpumask;
mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
@@ -269,16 +269,11 @@ cpu_mp_start(void)
}
CPU_SET(cpuid, &all_cpus);
}
-
- ocpus = all_cpus;
- CPU_CLR(PCPU_GET(cpuid), &ocpus);
- PCPU_SET(other_cpus, ocpus);
}
void
smp_init_secondary(u_int32_t cpuid)
{
- cpuset_t ocpus;
/* TLB */
mips_wr_wired(0);
@@ -316,11 +311,6 @@ smp_init_secondary(u_int32_t cpuid)
CTR1(KTR_SMP, "SMP: AP CPU #%d launched", PCPU_GET(cpuid));
- /* Build our map of 'other' CPUs. */
- ocpus = all_cpus;
- CPU_CLR(PCPU_GET(cpuid), &ocpus);
- PCPU_SET(other_cpus, ocpus);
-
if (bootverbose)
printf("SMP: AP CPU #%d launched.\n", PCPU_GET(cpuid));
diff --git a/sys/mips/mips/pmap.c b/sys/mips/mips/pmap.c
index f05bffa..4d46099 100644
--- a/sys/mips/mips/pmap.c
+++ b/sys/mips/mips/pmap.c
@@ -625,19 +625,18 @@ pmap_init(void)
static __inline void
pmap_invalidate_all_local(pmap_t pmap)
{
+ u_int cpuid;
+
+ cpuid = PCPU_GET(cpuid);
if (pmap == kernel_pmap) {
tlb_invalidate_all();
return;
}
- sched_pin();
- if (CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) {
- sched_unpin();
+ if (CPU_ISSET(cpuid, &pmap->pm_active))
tlb_invalidate_all_user(pmap);
- } else {
- sched_unpin();
- pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
- }
+ else
+ pmap->pm_asid[cpuid].gen = 0;
}
#ifdef SMP
@@ -666,21 +665,20 @@ pmap_invalidate_all(pmap_t pmap)
static __inline void
pmap_invalidate_page_local(pmap_t pmap, vm_offset_t va)
{
+ u_int cpuid;
+
+ cpuid = PCPU_GET(cpuid);
if (is_kernel_pmap(pmap)) {
tlb_invalidate_address(pmap, va);
return;
}
- sched_pin();
- if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) {
- sched_unpin();
+ if (pmap->pm_asid[cpuid].gen != PCPU_GET(asid_generation))
return;
- } else if (!CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) {
- pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
- sched_unpin();
+ else if (!CPU_ISSET(cpuid, &pmap->pm_active)) {
+ pmap->pm_asid[cpuid].gen = 0;
return;
}
- sched_unpin();
tlb_invalidate_address(pmap, va);
}
@@ -719,21 +717,20 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
static __inline void
pmap_update_page_local(pmap_t pmap, vm_offset_t va, pt_entry_t pte)
{
+ u_int cpuid;
+
+ cpuid = PCPU_GET(cpuid);
if (is_kernel_pmap(pmap)) {
tlb_update(pmap, va, pte);
return;
}
- sched_pin();
- if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) {
- sched_unpin();
+ if (pmap->pm_asid[cpuid].gen != PCPU_GET(asid_generation))
return;
- } else if (!CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) {
- pmap->pm_asid[PCPU_GET(cpuid)].gen = 0;
- sched_unpin();
+ else if (!CPU_ISSET(cpuid, &pmap->pm_active)) {
+ pmap->pm_asid[cpuid].gen = 0;
return;
}
- sched_unpin();
tlb_update(pmap, va, pte);
}
@@ -2953,19 +2950,21 @@ pmap_activate(struct thread *td)
{
pmap_t pmap, oldpmap;
struct proc *p = td->td_proc;
+ u_int cpuid;
critical_enter();
pmap = vmspace_pmap(p->p_vmspace);
oldpmap = PCPU_GET(curpmap);
+ cpuid = PCPU_GET(cpuid);
if (oldpmap)
- CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask));
- CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask));
+ CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active);
+ CPU_SET_ATOMIC(cpuid, &pmap->pm_active);
pmap_asid_alloc(pmap);
if (td == curthread) {
PCPU_SET(segbase, pmap->pm_segtab);
- mips_wr_entryhi(pmap->pm_asid[PCPU_GET(cpuid)].asid);
+ mips_wr_entryhi(pmap->pm_asid[cpuid].asid);
}
PCPU_SET(curpmap, pmap);
OpenPOWER on IntegriCloud