Index: cpu.c =================================================================== RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v retrieving revision 1.100 diff -u -p -r1.100 cpu.c --- cpu.c 23 Nov 2023 01:00:44 -0000 1.100 +++ cpu.c 9 Jan 2024 01:03:09 -0000 @@ -254,7 +254,7 @@ void cpu_flush_bp_noop(void); void cpu_flush_bp_psci(void); #if NKSTAT > 0 -void cpu_kstat_attach(struct cpu_info *ci); +void cpu_kstat_attach(struct device *); void cpu_opp_kstat_attach(struct cpu_info *ci); #endif @@ -305,6 +305,11 @@ cpu_identify(struct cpu_info *ci) snprintf(cpu_model, sizeof(cpu_model), "Unknown"); } +#if NKSTAT > 0 + /* let kstat show all this info again */ + config_mountroot(ci->ci_dev, cpu_kstat_attach); +#endif + /* Print cache information. */ ctr = READ_SPECIALREG(ctr_el0); @@ -945,10 +950,6 @@ cpu_attach(struct device *parent, struct } cpu_init(); - -#if NKSTAT > 0 - cpu_kstat_attach(ci); -#endif #ifdef MULTIPROCESSOR } #endif @@ -1193,10 +1194,6 @@ cpu_init_secondary(struct cpu_info *ci) spllower(IPL_NONE); -#if NKSTAT > 0 - cpu_kstat_attach(ci); -#endif - sched_toidle(); } @@ -1841,14 +1838,16 @@ cpu_psci_init(struct cpu_info *ci) #if NKSTAT > 0 struct cpu_kstats { + struct kstat_kv ck_mpidr; struct kstat_kv ck_impl; struct kstat_kv ck_part; struct kstat_kv ck_rev; }; void -cpu_kstat_attach(struct cpu_info *ci) +cpu_kstat_attach(struct device *self) { + struct cpu_info *ci = cpu_info[self->dv_unit]; struct kstat *ks; struct cpu_kstats *ck; @@ -1857,17 +1856,23 @@ cpu_kstat_attach(struct cpu_info *ci) const struct cpu_cores *coreselecter = cpu_cores_none; size_t i; - ks = kstat_create(ci->ci_dev->dv_xname, 0, "mach", 0, KSTAT_T_KV, 0); + ks = kstat_create(ci->ci_dev->dv_xname, 0, "arm-cpu", 0, + KSTAT_T_KV, 0); if (ks == NULL) { - printf("%s: unable to create cpu kstats\n", - ci->ci_dev->dv_xname); - /* printf? */ + printf("%s: unable to create cpu kstats\n", self->dv_xname); return; } - ck = malloc(sizeof(*ck), M_DEVBUF, M_WAITOK); + ck = malloc(sizeof(*ck), M_DEVBUF, M_WAITOK|M_ZERO); + + kstat_kv_init(&ck->ck_mpidr, "mpidr", KSTAT_KV_T_ISTR); + snprintf(kstat_kv_istr(&ck->ck_mpidr), + sizeof(kstat_kv_istr(&ck->ck_mpidr)), "%llx", ci->ci_mpidr); + sched_peg_curproc(ci); midr = READ_SPECIALREG(midr_el1); + atomic_clearbits_int(&curproc->p_flag, P_CPUPEG); + impl = CPU_IMPL(midr); part = CPU_PART(midr);