1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

Define struct pcpu_md as the only MD field of struct pcpu (pc_acpi_id

excluded, as it's used by MI code) and mode the sysctl variables from
pcpu_stats to pcpu_md.
Adjust all references accordingly.

While nearby, change the PCPU sysctl tree so that they match the CPU
device sysctl tree -- they are now children of a static node called
"machdep.cpu" and are named only with their cpu ID.
This commit is contained in:
Marcel Moolenaar 2009-12-07 06:41:27 +00:00
parent 6e8021eae1
commit 58a0206d63
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200207
8 changed files with 81 additions and 75 deletions

View File

@ -64,9 +64,9 @@ void
pcpu_initclock(void)
{
PCPU_SET(clockadj, 0);
PCPU_SET(clock, ia64_get_itc());
ia64_set_itm(PCPU_GET(clock) + ia64_clock_reload);
PCPU_SET(md.clockadj, 0);
PCPU_SET(md.clock, ia64_get_itc());
ia64_set_itm(PCPU_GET(md.clock) + ia64_clock_reload);
ia64_set_itv(CLOCK_VECTOR); /* highest priority class */
ia64_srlz_d();
}

View File

@ -91,7 +91,7 @@ ASSYM(MC_SPECIAL_RNAT, offsetof(mcontext_t, mc_special.rnat));
ASSYM(PAGE_SHIFT, PAGE_SHIFT);
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(PC_CURRENT_PMAP, offsetof(struct pcpu, pc_current_pmap));
ASSYM(PC_CURRENT_PMAP, offsetof(struct pcpu, pc_md.current_pmap));
ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
ASSYM(PC_IDLETHREAD, offsetof(struct pcpu, pc_idlethread));

View File

@ -127,16 +127,16 @@ interrupt(struct trapframe *tf)
* read the vector.
*/
if (vector == 0) {
PCPU_INC(stats.pcs_nextints);
PCPU_INC(md.stats.pcs_nextints);
inta = ib->ib_inta;
if (inta == 15) {
PCPU_INC(stats.pcs_nstrays);
PCPU_INC(md.stats.pcs_nstrays);
__asm __volatile("mov cr.eoi = r0;; srlz.d");
goto stray;
}
vector = (int)inta;
} else if (vector == 15) {
PCPU_INC(stats.pcs_nstrays);
PCPU_INC(md.stats.pcs_nstrays);
goto stray;
}
@ -145,7 +145,7 @@ interrupt(struct trapframe *tf)
itc = ia64_get_itc();
PCPU_INC(stats.pcs_nclks);
PCPU_INC(md.stats.pcs_nclks);
#ifdef EVCNT_COUNTERS
clock_intr_evcnt.ev_count++;
#else
@ -154,8 +154,8 @@ interrupt(struct trapframe *tf)
critical_enter();
adj = PCPU_GET(clockadj);
clk = PCPU_GET(clock);
adj = PCPU_GET(md.clockadj);
clk = PCPU_GET(md.clock);
delta = itc - clk;
count = 0;
while (delta >= ia64_clock_reload) {
@ -186,40 +186,40 @@ interrupt(struct trapframe *tf)
adj = 0;
adjust_excess++;
}
PCPU_SET(clock, clk);
PCPU_SET(clockadj, adj);
PCPU_SET(md.clock, clk);
PCPU_SET(md.clockadj, adj);
critical_exit();
ia64_srlz_d();
#ifdef SMP
} else if (vector == ipi_vector[IPI_AST]) {
PCPU_INC(stats.pcs_nasts);
PCPU_INC(md.stats.pcs_nasts);
CTR1(KTR_SMP, "IPI_AST, cpuid=%d", PCPU_GET(cpuid));
} else if (vector == ipi_vector[IPI_HIGH_FP]) {
PCPU_INC(stats.pcs_nhighfps);
PCPU_INC(md.stats.pcs_nhighfps);
ia64_highfp_save_ipi();
} else if (vector == ipi_vector[IPI_RENDEZVOUS]) {
PCPU_INC(stats.pcs_nrdvs);
PCPU_INC(md.stats.pcs_nrdvs);
CTR1(KTR_SMP, "IPI_RENDEZVOUS, cpuid=%d", PCPU_GET(cpuid));
enable_intr();
smp_rendezvous_action();
disable_intr();
} else if (vector == ipi_vector[IPI_STOP]) {
PCPU_INC(stats.pcs_nstops);
PCPU_INC(md.stats.pcs_nstops);
cpumask_t mybit = PCPU_GET(cpumask);
/* Make sure IPI_STOP_HARD is mapped to IPI_STOP. */
KASSERT(IPI_STOP == IPI_STOP_HARD,
("%s: IPI_STOP_HARD not handled.", __func__));
savectx(PCPU_PTR(pcb));
savectx(PCPU_PTR(md.pcb));
atomic_set_int(&stopped_cpus, mybit);
while ((started_cpus & mybit) == 0)
cpu_spinwait();
atomic_clear_int(&started_cpus, mybit);
atomic_clear_int(&stopped_cpus, mybit);
} else if (vector == ipi_vector[IPI_PREEMPT]) {
PCPU_INC(stats.pcs_npreempts);
PCPU_INC(md.stats.pcs_npreempts);
CTR1(KTR_SMP, "IPI_PREEMPT, cpuid=%d", PCPU_GET(cpuid));
__asm __volatile("mov cr.eoi = r0;; srlz.d");
enable_intr();
@ -228,7 +228,7 @@ interrupt(struct trapframe *tf)
goto stray;
#endif
} else {
PCPU_INC(stats.pcs_nhwints);
PCPU_INC(md.stats.pcs_nhwints);
atomic_add_int(&td->td_intr_nesting_level, 1);
ia64_dispatch_intr(tf, vector);
atomic_subtract_int(&td->td_intr_nesting_level, 1);

View File

@ -101,6 +101,8 @@ __FBSDID("$FreeBSD$");
#include <i386/include/specialreg.h>
SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RD, 0, "");
u_int64_t processor_frequency;
u_int64_t bus_frequency;
u_int64_t itc_frequency;
@ -307,57 +309,58 @@ cpu_startup(void *dummy)
* Create sysctl tree for per-CPU information.
*/
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
pcs = &pc->pc_stats;
snprintf(nodename, sizeof(nodename), "cpu%u", pc->pc_cpuid);
sysctl_ctx_init(&pcs->pcs_sysctl_ctx);
pcs->pcs_sysctl_tree = SYSCTL_ADD_NODE(&pcs->pcs_sysctl_ctx,
SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, nodename,
snprintf(nodename, sizeof(nodename), "%u", pc->pc_cpuid);
sysctl_ctx_init(&pc->pc_md.sysctl_ctx);
pc->pc_md.sysctl_tree = SYSCTL_ADD_NODE(&pc->pc_md.sysctl_ctx,
SYSCTL_STATIC_CHILDREN(_machdep_cpu), OID_AUTO, nodename,
CTLFLAG_RD, NULL, "");
if (pcs->pcs_sysctl_tree == NULL)
if (pc->pc_md.sysctl_tree == NULL)
continue;
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
pcs = &pc->pc_md.stats;
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nasts", CTLFLAG_RD, &pcs->pcs_nasts,
"Number of IPI_AST interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nclks", CTLFLAG_RD, &pcs->pcs_nclks,
"Number of clock interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nextints", CTLFLAG_RD, &pcs->pcs_nextints,
"Number of ExtINT interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nhighfps", CTLFLAG_RD, &pcs->pcs_nhighfps,
"Number of IPI_HIGH_FP interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nhwints", CTLFLAG_RD, &pcs->pcs_nhwints,
"Number of hardware (device) interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"npreempts", CTLFLAG_RD, &pcs->pcs_npreempts,
"Number of IPI_PREEMPT interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nrdvs", CTLFLAG_RD, &pcs->pcs_nrdvs,
"Number of IPI_RENDEZVOUS interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nstops", CTLFLAG_RD, &pcs->pcs_nstops,
"Number of IPI_STOP interrupts");
SYSCTL_ADD_ULONG(&pcs->pcs_sysctl_ctx,
SYSCTL_CHILDREN(pcs->pcs_sysctl_tree), OID_AUTO,
SYSCTL_ADD_ULONG(&pc->pc_md.sysctl_ctx,
SYSCTL_CHILDREN(pc->pc_md.sysctl_tree), OID_AUTO,
"nstrays", CTLFLAG_RD, &pcs->pcs_nstrays,
"Number of stray vectors");
}

View File

@ -121,7 +121,7 @@ ia64_ap_startup(void)
pcpup = ap_pcpu;
ia64_set_k4((intptr_t)pcpup);
vhpt = PCPU_GET(vhpt);
vhpt = PCPU_GET(md.vhpt);
map_vhpt(vhpt);
ia64_set_pta(vhpt + (1 << 8) + (pmap_vhpt_log2size << 2) + 1);
ia64_srlz_i();
@ -226,7 +226,7 @@ cpu_mp_add(u_int acpiid, u_int apicid, u_int apiceid)
pc = pcpup;
pc->pc_acpi_id = acpiid;
pc->pc_lid = lid;
pc->pc_md.lid = lid;
all_cpus |= (1UL << cpuid);
}
@ -240,8 +240,8 @@ cpu_mp_announce()
pc = pcpu_find(i);
if (pc != NULL) {
printf("cpu%d: ACPI Id=%x, SAPIC Id=%x, SAPIC Eid=%x",
i, pc->pc_acpi_id, LID_SAPIC_ID(pc->pc_lid),
LID_SAPIC_EID(pc->pc_lid));
i, pc->pc_acpi_id, LID_SAPIC_ID(pc->pc_md.lid),
LID_SAPIC_EID(pc->pc_md.lid));
if (i == 0)
printf(" (BSP)\n");
else
@ -258,12 +258,12 @@ cpu_mp_start()
ap_spin = 1;
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
pc->pc_current_pmap = kernel_pmap;
pc->pc_md.current_pmap = kernel_pmap;
pc->pc_other_cpus = all_cpus & ~pc->pc_cpumask;
if (pc->pc_cpuid > 0) {
ap_pcpu = pc;
pc->pc_vhpt = pmap_alloc_vhpt();
if (pc->pc_vhpt == 0) {
pc->pc_md.vhpt = pmap_alloc_vhpt();
if (pc->pc_md.vhpt == 0) {
printf("SMP: WARNING: unable to allocate VHPT"
" for cpu%d", pc->pc_cpuid);
continue;
@ -281,13 +281,13 @@ cpu_mp_start()
do {
DELAY(1000);
} while (--ap_delay > 0);
pc->pc_awake = ap_awake;
pc->pc_md.awake = ap_awake;
if (!ap_awake)
printf("SMP: WARNING: cpu%d did not wake up\n",
pc->pc_cpuid);
} else
pc->pc_awake = 1;
pc->pc_md.awake = 1;
}
}
@ -304,7 +304,7 @@ cpu_mp_unleash(void *dummy)
smp_cpus = 0;
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
cpus++;
if (pc->pc_awake) {
if (pc->pc_md.awake) {
kproc_create(ia64_store_mca_state,
(void*)((uintptr_t)pc->pc_cpuid), NULL, 0, 0,
"mca %u", pc->pc_cpuid);
@ -367,7 +367,7 @@ ipi_send(struct pcpu *cpu, int ipi)
uint64_t vector;
pipi = __MEMIO_ADDR(ia64_lapic_address |
((cpu->pc_lid & LID_SAPIC_MASK) >> 12));
((cpu->pc_md.lid & LID_SAPIC_MASK) >> 12));
vector = (uint64_t)(ipi_vector[ipi] & 0xff);
KASSERT(vector != 0, ("IPI %d is not assigned a vector", ipi));
*pipi = vector;

View File

@ -426,7 +426,7 @@ pmap_bootstrap()
phys_avail[i] = base + size;
base = IA64_PHYS_TO_RR7(base);
PCPU_SET(vhpt, base);
PCPU_SET(md.vhpt, base);
if (bootverbose)
printf("VHPT: address=%#lx, size=%#lx\n", base, size);
@ -455,7 +455,7 @@ pmap_bootstrap()
kernel_pmap->pm_rid[i] = 0;
kernel_pmap->pm_active = 1;
TAILQ_INIT(&kernel_pmap->pm_pvlist);
PCPU_SET(current_pmap, kernel_pmap);
PCPU_SET(md.current_pmap, kernel_pmap);
/*
* Region 5 is mapped via the vhpt.
@ -543,13 +543,13 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
struct pcpu *pc;
u_int vhpt_ofs;
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(current_pmap)),
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(md.current_pmap)),
("invalidating TLB for non-current pmap"));
vhpt_ofs = ia64_thash(va) - PCPU_GET(vhpt);
vhpt_ofs = ia64_thash(va) - PCPU_GET(md.vhpt);
critical_enter();
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
pte = (struct ia64_lpte *)(pc->pc_vhpt + vhpt_ofs);
pte = (struct ia64_lpte *)(pc->pc_md.vhpt + vhpt_ofs);
if (pte->tag == ia64_ttag(va))
pte->tag = 1UL << 63;
}
@ -581,7 +581,7 @@ static void
pmap_invalidate_all(pmap_t pmap)
{
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(current_pmap)),
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(md.current_pmap)),
("invalidating TLB for non-current pmap"));
#ifdef SMP
@ -1162,7 +1162,7 @@ pmap_remove_pte(pmap_t pmap, struct ia64_lpte *pte, vm_offset_t va,
int error;
vm_page_t m;
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(current_pmap)),
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(md.current_pmap)),
("removing pte for non-current pmap"));
/*
@ -1330,7 +1330,7 @@ pmap_remove_page(pmap_t pmap, vm_offset_t va)
{
struct ia64_lpte *pte;
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(current_pmap)),
KASSERT((pmap == kernel_pmap || pmap == PCPU_GET(md.current_pmap)),
("removing page for non-current pmap"));
pte = pmap_find_vhpt(va);
@ -2241,7 +2241,7 @@ pmap_switch(pmap_t pm)
int i;
critical_enter();
prevpm = PCPU_GET(current_pmap);
prevpm = PCPU_GET(md.current_pmap);
if (prevpm == pm)
goto out;
if (prevpm != NULL)
@ -2258,7 +2258,7 @@ pmap_switch(pmap_t pm)
}
atomic_set_32(&pm->pm_active, PCPU_GET(cpumask));
}
PCPU_SET(current_pmap, pm);
PCPU_SET(md.current_pmap, pm);
ia64_srlz_d();
out:

View File

@ -33,7 +33,7 @@
#include <machine/frame.h>
#include <machine/ia64_cpu.h>
#define KDB_STOPPEDPCB(pc) (&(pc)->pc_pcb)
#define KDB_STOPPEDPCB(pc) (&(pc)->pc_md.pcb)
static __inline void
kdb_cpu_clear_singlestep(void)

View File

@ -43,23 +43,26 @@ struct pcpu_stats {
u_long pcs_nrdvs; /* IPI_RENDEZVOUS counter. */
u_long pcs_nstops; /* IPI_STOP counter. */
u_long pcs_nstrays; /* Stray interrupt counter. */
};
struct pcpu_md {
struct pcb pcb; /* Used by IPI_STOP */
struct pmap *current_pmap; /* active pmap */
vm_offset_t vhpt; /* Address of VHPT */
uint64_t lid; /* local CPU ID */
uint64_t clock; /* Clock counter. */
uint64_t clockadj; /* Clock adjust. */
uint32_t awake:1; /* CPU is awake? */
struct pcpu_stats stats; /* Interrupt stats. */
#ifdef _KERNEL
struct sysctl_ctx_list pcs_sysctl_ctx;
struct sysctl_oid *pcs_sysctl_tree;
struct sysctl_ctx_list sysctl_ctx;
struct sysctl_oid *sysctl_tree;
#endif
};
#define PCPU_MD_FIELDS \
struct pcb pc_pcb; /* Used by IPI_STOP */ \
struct pmap *pc_current_pmap; /* active pmap */ \
vm_offset_t pc_vhpt; /* Address of VHPT */ \
uint64_t pc_lid; /* local CPU ID */ \
uint64_t pc_clock; /* Clock counter. */ \
uint64_t pc_clockadj; /* Clock adjust. */ \
uint32_t pc_awake:1; /* CPU is awake? */ \
uint32_t pc_acpi_id; /* ACPI CPU id. */ \
struct pcpu_stats pc_stats
struct pcpu_md pc_md /* MD fields. */
#ifdef _KERNEL