- i386_cpu_info_t *cpuinfo;
-
- topoParms.stable = FALSE;
-
- cpuinfo = cpuid_info();
-
- PE_parse_boot_argn("-topo", &topo_dbg, sizeof(topo_dbg));
-
- /*
- * We need to start with getting the LLC information correct.
- */
- x86_LLC_info();
-
- /*
- * Compute the number of threads (logical CPUs) per core.
- */
- DIVISOR_GUARD(cpuinfo->core_count);
- topoParms.nLThreadsPerCore = cpuinfo->thread_count / cpuinfo->core_count;
- DIVISOR_GUARD(cpuinfo->cpuid_cores_per_package);
- topoParms.nPThreadsPerCore = cpuinfo->cpuid_logical_per_package / cpuinfo->cpuid_cores_per_package;
-
- /*
- * Compute the number of dies per package.
- */
- DIVISOR_GUARD(topoParms.nCoresSharingLLC);
- topoParms.nLDiesPerPackage = cpuinfo->core_count / topoParms.nCoresSharingLLC;
- DIVISOR_GUARD(topoParms.nPThreadsPerCore);
- DIVISOR_GUARD(topoParms.maxSharingLLC / topoParms.nPThreadsPerCore);
- topoParms.nPDiesPerPackage = cpuinfo->cpuid_cores_per_package / (topoParms.maxSharingLLC / topoParms.nPThreadsPerCore);
-
-
- /*
- * Compute the number of cores per die.
- */
- topoParms.nLCoresPerDie = topoParms.nCoresSharingLLC;
- topoParms.nPCoresPerDie = (topoParms.maxSharingLLC / topoParms.nPThreadsPerCore);
-
- /*
- * Compute the number of threads per die.
- */
- topoParms.nLThreadsPerDie = topoParms.nLThreadsPerCore * topoParms.nLCoresPerDie;
- topoParms.nPThreadsPerDie = topoParms.nPThreadsPerCore * topoParms.nPCoresPerDie;
-
- /*
- * Compute the number of cores per package.
- */
- topoParms.nLCoresPerPackage = topoParms.nLCoresPerDie * topoParms.nLDiesPerPackage;
- topoParms.nPCoresPerPackage = topoParms.nPCoresPerDie * topoParms.nPDiesPerPackage;
-
- /*
- * Compute the number of threads per package.
- */
- topoParms.nLThreadsPerPackage = topoParms.nLThreadsPerCore * topoParms.nLCoresPerPackage;
- topoParms.nPThreadsPerPackage = topoParms.nPThreadsPerCore * topoParms.nPCoresPerPackage;
-
- TOPO_DBG("\nCache Topology Parameters:\n");
- TOPO_DBG("\tLLC Depth: %d\n", topoParms.LLCDepth);
- TOPO_DBG("\tCores Sharing LLC: %d\n", topoParms.nCoresSharingLLC);
- TOPO_DBG("\tThreads Sharing LLC: %d\n", topoParms.nLCPUsSharingLLC);
- TOPO_DBG("\tmax Sharing of LLC: %d\n", topoParms.maxSharingLLC);
-
- TOPO_DBG("\nLogical Topology Parameters:\n");
- TOPO_DBG("\tThreads per Core: %d\n", topoParms.nLThreadsPerCore);
- TOPO_DBG("\tCores per Die: %d\n", topoParms.nLCoresPerDie);
- TOPO_DBG("\tThreads per Die: %d\n", topoParms.nLThreadsPerDie);
- TOPO_DBG("\tDies per Package: %d\n", topoParms.nLDiesPerPackage);
- TOPO_DBG("\tCores per Package: %d\n", topoParms.nLCoresPerPackage);
- TOPO_DBG("\tThreads per Package: %d\n", topoParms.nLThreadsPerPackage);
-
- TOPO_DBG("\nPhysical Topology Parameters:\n");
- TOPO_DBG("\tThreads per Core: %d\n", topoParms.nPThreadsPerCore);
- TOPO_DBG("\tCores per Die: %d\n", topoParms.nPCoresPerDie);
- TOPO_DBG("\tThreads per Die: %d\n", topoParms.nPThreadsPerDie);
- TOPO_DBG("\tDies per Package: %d\n", topoParms.nPDiesPerPackage);
- TOPO_DBG("\tCores per Package: %d\n", topoParms.nPCoresPerPackage);
- TOPO_DBG("\tThreads per Package: %d\n", topoParms.nPThreadsPerPackage);
-
- topoParmsInited = TRUE;
+ i386_cpu_info_t *cpuinfo;
+
+ topoParms.stable = FALSE;
+
+ cpuinfo = cpuid_info();
+
+ PE_parse_boot_argn("-topo", &topo_dbg, sizeof(topo_dbg));
+
+ /*
+ * We need to start with getting the LLC information correct.
+ */
+ x86_LLC_info();
+
+ /*
+ * Compute the number of threads (logical CPUs) per core.
+ */
+ DIVISOR_GUARD(cpuinfo->core_count);
+ topoParms.nLThreadsPerCore = cpuinfo->thread_count / cpuinfo->core_count;
+ DIVISOR_GUARD(cpuinfo->cpuid_cores_per_package);
+ topoParms.nPThreadsPerCore = cpuinfo->cpuid_logical_per_package / cpuinfo->cpuid_cores_per_package;
+
+ /*
+ * Compute the number of dies per package.
+ */
+ DIVISOR_GUARD(topoParms.nCoresSharingLLC);
+ topoParms.nLDiesPerPackage = cpuinfo->core_count / topoParms.nCoresSharingLLC;
+ DIVISOR_GUARD(topoParms.nPThreadsPerCore);
+ DIVISOR_GUARD(topoParms.maxSharingLLC / topoParms.nPThreadsPerCore);
+ topoParms.nPDiesPerPackage = cpuinfo->cpuid_cores_per_package / (topoParms.maxSharingLLC / topoParms.nPThreadsPerCore);
+
+
+ /*
+ * Compute the number of cores per die.
+ */
+ topoParms.nLCoresPerDie = topoParms.nCoresSharingLLC;
+ topoParms.nPCoresPerDie = (topoParms.maxSharingLLC / topoParms.nPThreadsPerCore);
+
+ /*
+ * Compute the number of threads per die.
+ */
+ topoParms.nLThreadsPerDie = topoParms.nLThreadsPerCore * topoParms.nLCoresPerDie;
+ topoParms.nPThreadsPerDie = topoParms.nPThreadsPerCore * topoParms.nPCoresPerDie;
+
+ /*
+ * Compute the number of cores per package.
+ */
+ topoParms.nLCoresPerPackage = topoParms.nLCoresPerDie * topoParms.nLDiesPerPackage;
+ topoParms.nPCoresPerPackage = topoParms.nPCoresPerDie * topoParms.nPDiesPerPackage;
+
+ /*
+ * Compute the number of threads per package.
+ */
+ topoParms.nLThreadsPerPackage = topoParms.nLThreadsPerCore * topoParms.nLCoresPerPackage;
+ topoParms.nPThreadsPerPackage = topoParms.nPThreadsPerCore * topoParms.nPCoresPerPackage;
+
+ TOPO_DBG("\nCache Topology Parameters:\n");
+ TOPO_DBG("\tLLC Depth: %d\n", topoParms.LLCDepth);
+ TOPO_DBG("\tCores Sharing LLC: %d\n", topoParms.nCoresSharingLLC);
+ TOPO_DBG("\tThreads Sharing LLC: %d\n", topoParms.nLCPUsSharingLLC);
+ TOPO_DBG("\tmax Sharing of LLC: %d\n", topoParms.maxSharingLLC);
+
+ TOPO_DBG("\nLogical Topology Parameters:\n");
+ TOPO_DBG("\tThreads per Core: %d\n", topoParms.nLThreadsPerCore);
+ TOPO_DBG("\tCores per Die: %d\n", topoParms.nLCoresPerDie);
+ TOPO_DBG("\tThreads per Die: %d\n", topoParms.nLThreadsPerDie);
+ TOPO_DBG("\tDies per Package: %d\n", topoParms.nLDiesPerPackage);
+ TOPO_DBG("\tCores per Package: %d\n", topoParms.nLCoresPerPackage);
+ TOPO_DBG("\tThreads per Package: %d\n", topoParms.nLThreadsPerPackage);
+
+ TOPO_DBG("\nPhysical Topology Parameters:\n");
+ TOPO_DBG("\tThreads per Core: %d\n", topoParms.nPThreadsPerCore);
+ TOPO_DBG("\tCores per Die: %d\n", topoParms.nPCoresPerDie);
+ TOPO_DBG("\tThreads per Die: %d\n", topoParms.nPThreadsPerDie);
+ TOPO_DBG("\tDies per Package: %d\n", topoParms.nPDiesPerPackage);
+ TOPO_DBG("\tCores per Package: %d\n", topoParms.nPCoresPerPackage);
+ TOPO_DBG("\tThreads per Package: %d\n", topoParms.nPThreadsPerPackage);
+
+ topoParmsInited = TRUE;
- x86_cpu_cache_t *root = NULL;
- x86_cpu_cache_t *cur = NULL;
- x86_cpu_cache_t *last = NULL;
- struct cpu_cache *cachep;
- int i;
-
- /*
- * Cons up a list driven not by CPUID leaf 4 (deterministic cache params)
- * but by the table above plus parameters already cracked from cpuid...
- */
- for (i = 0, cachep = &cpu_caches[0]; i < LCACHE_MAX; i++, cachep++) {
-
- if (cachep->type == 0 || cpuid_info()->cache_size[i] == 0)
- continue;
-
- cur = x86_cache_alloc();
- if (cur == NULL)
- break;
-
- cur->type = cachep->type;
- cur->level = cachep->level;
- cur->nlcpus = 0;
- cur->maxcpus = cpuid_info()->cache_sharing[i];
- cur->partitions = cpuid_info()->cache_partitions[i];
- cur->cache_size = cpuid_info()->cache_size[i];
- cur->line_size = cpuid_info()->cache_linesize;
-
- if (last == NULL) {
- root = cur;
- last = cur;
- } else {
- last->next = cur;
- last = cur;
+ x86_cpu_cache_t *root = NULL;
+ x86_cpu_cache_t *cur = NULL;
+ x86_cpu_cache_t *last = NULL;
+ struct cpu_cache *cachep;
+ int i;
+
+ /*
+ * Cons up a list driven not by CPUID leaf 4 (deterministic cache params)
+ * but by the table above plus parameters already cracked from cpuid...
+ */
+ for (i = 0, cachep = &cpu_caches[0]; i < LCACHE_MAX; i++, cachep++) {
+ if (cachep->type == 0 || cpuid_info()->cache_size[i] == 0) {
+ continue;
+ }
+
+ cur = x86_cache_alloc();
+ if (cur == NULL) {
+ break;
+ }
+
+ cur->type = cachep->type;
+ cur->level = cachep->level;
+ cur->nlcpus = 0;
+ cur->maxcpus = cpuid_info()->cache_sharing[i];
+ cur->partitions = cpuid_info()->cache_partitions[i];
+ cur->cache_size = cpuid_info()->cache_size[i];
+ cur->line_size = cpuid_info()->cache_linesize;
+
+ if (last == NULL) {
+ root = cur;
+ last = cur;
+ } else {
+ last->next = cur;
+ last = cur;
+ }
+ num_Lx_caches[cur->level - 1] += 1;
- } while (core == NULL);
-
-
- /*
- * Done manipulating the topology, so others can get in.
- */
- machine_info.logical_cpu_max += 1;
- simple_unlock(&x86_topo_lock);
-
- /*
- * Add the logical CPU to the other topology structures.
- */
- x86_core_add_lcpu(core, &cpup->lcpu);
- x86_die_add_lcpu(core->die, &cpup->lcpu);
- x86_package_add_lcpu(core->package, &cpup->lcpu);
- x86_lcpu_add_caches(&cpup->lcpu);
-
- return (void *) core;
+
+ /*
+ * Get the package that the logical CPU is in.
+ */
+ do {
+ pkg = x86_package_find(cpu);
+ if (pkg == NULL) {
+ /*
+ * Package structure hasn't been created yet, do it now.
+ */
+ simple_unlock(&x86_topo_lock);
+ pkg = x86_package_alloc(cpu);
+ mp_safe_spin_lock(&x86_topo_lock);
+ if (x86_package_find(cpu) != NULL) {
+ x86_package_free(pkg);
+ continue;
+ }
+
+ /*
+ * Add the new package to the global list of packages.
+ */
+ pkg->next = x86_pkgs;
+ x86_pkgs = pkg;
+ }
+ } while (pkg == NULL);
+
+ /*
+ * Get the die that the logical CPU is in.
+ */
+ do {
+ die = x86_die_find(cpu);
+ if (die == NULL) {
+ /*
+ * Die structure hasn't been created yet, do it now.
+ */
+ simple_unlock(&x86_topo_lock);
+ die = x86_die_alloc(cpu);
+ mp_safe_spin_lock(&x86_topo_lock);
+ if (x86_die_find(cpu) != NULL) {
+ x86_die_free(die);
+ continue;
+ }
+
+ /*
+ * Add the die to the package.
+ */
+ x86_package_add_die(pkg, die);
+ }
+ } while (die == NULL);
+
+ /*
+ * Get the core for this logical CPU.
+ */
+ do {
+ core = x86_core_find(cpu);
+ if (core == NULL) {
+ /*
+ * Allocate the core structure now.
+ */
+ simple_unlock(&x86_topo_lock);
+ core = x86_core_alloc(cpu);
+ mp_safe_spin_lock(&x86_topo_lock);
+ if (x86_core_find(cpu) != NULL) {
+ x86_core_free(core);
+ continue;
+ }
+
+ /*
+ * Add the core to the die & package.
+ */
+ x86_die_add_core(die, core);
+ x86_package_add_core(pkg, core);
+ machine_info.physical_cpu_max += 1;
+ }
+ } while (core == NULL);
+
+
+ /*
+ * Done manipulating the topology, so others can get in.
+ */
+ machine_info.logical_cpu_max += 1;
+ simple_unlock(&x86_topo_lock);
+
+ /*
+ * Add the logical CPU to the other topology structures.
+ */
+ x86_core_add_lcpu(core, &cpup->lcpu);
+ x86_die_add_lcpu(core->die, &cpup->lcpu);
+ x86_package_add_lcpu(core->package, &cpup->lcpu);
+ x86_lcpu_add_caches(&cpup->lcpu);
+
+ return (void *) core;
- x86_core_t *core;
- cpu_data_t *cpup = current_cpu_datap();
-
- simple_lock(&x86_topo_lock);
- machine_info.logical_cpu -= 1;
- core = cpup->lcpu.core;
- core->active_lcpus -= 1;
- if (core->active_lcpus == 0)
- machine_info.physical_cpu -= 1;
- simple_unlock(&x86_topo_lock);
-
- /*
- * Let the power management code determine the best way to "stop"
- * the processor.
- */
- ml_set_interrupts_enabled(FALSE);
- while (1) {
- pmCPUHalt(PM_HALT_NORMAL);
- }
- /* NOT REACHED */
+ x86_core_t *core;
+ cpu_data_t *cpup = current_cpu_datap();
+
+ mp_safe_spin_lock(&x86_topo_lock);
+ machine_info.logical_cpu -= 1;
+ core = cpup->lcpu.core;
+ core->active_lcpus -= 1;
+ if (core->active_lcpus == 0) {
+ machine_info.physical_cpu -= 1;
+ }
+ simple_unlock(&x86_topo_lock);
+
+ /*
+ * Let the power management code determine the best way to "stop"
+ * the processor.
+ */
+ ml_set_interrupts_enabled(FALSE);
+ while (1) {
+ pmCPUHalt(PM_HALT_NORMAL);
+ }
+ /* NOT REACHED */
- x86_pkg_t *pkg;
- x86_die_t *die;
- x86_core_t *core;
- x86_lcpu_t *lcpu;
- uint32_t nDies;
- uint32_t nCores;
- uint32_t nCPUs;
-
- if (topo_dbg)
- debug_topology_print();
-
- /*
- * XXX
- *
- * Right now this only works if the number of CPUs started is the total
- * number of CPUs. However, when specifying cpus=n the topology is only
- * partially constructed and the checks below will fail.
- *
- * We should *always* build the complete topology and only start the CPUs
- * indicated by cpus=n. Until that happens, this code will not check the
- * topology if the number of cpus defined is < that described the the
- * topology parameters.
- */
- nCPUs = topoParms.nPackages * topoParms.nLThreadsPerPackage;
- if (nCPUs > real_ncpus)
- return;
-
- pkg = x86_pkgs;
- while (pkg != NULL) {
- /*
- * Make sure that the package has the correct number of dies.
- */
- nDies = 0;
- die = pkg->dies;
- while (die != NULL) {
- if (die->package == NULL)
- panic("Die(%d)->package is NULL",
- die->pdie_num);
- if (die->package != pkg)
- panic("Die %d points to package %d, should be %d",
- die->pdie_num, die->package->lpkg_num, pkg->lpkg_num);
-
- TOPO_DBG("Die(%d)->package %d\n",
- die->pdie_num, pkg->lpkg_num);
-
- /*
- * Make sure that the die has the correct number of cores.
- */
- TOPO_DBG("Die(%d)->cores: ", die->pdie_num);
- nCores = 0;
- core = die->cores;
- while (core != NULL) {
- if (core->die == NULL)
- panic("Core(%d)->die is NULL",
- core->pcore_num);
- if (core->die != die)
- panic("Core %d points to die %d, should be %d",
- core->pcore_num, core->die->pdie_num, die->pdie_num);
- nCores += 1;
- TOPO_DBG("%d ", core->pcore_num);
- core = core->next_in_die;
- }
- TOPO_DBG("\n");
-
- if (nCores != topoParms.nLCoresPerDie)
- panic("Should have %d Cores, but only found %d for Die %d",
- topoParms.nLCoresPerDie, nCores, die->pdie_num);
-
- /*
- * Make sure that the die has the correct number of CPUs.
- */
- TOPO_DBG("Die(%d)->lcpus: ", die->pdie_num);
- nCPUs = 0;
- lcpu = die->lcpus;
- while (lcpu != NULL) {
- if (lcpu->die == NULL)
- panic("CPU(%d)->die is NULL",
- lcpu->cpu_num);
- if (lcpu->die != die)
- panic("CPU %d points to die %d, should be %d",
- lcpu->cpu_num, lcpu->die->pdie_num, die->pdie_num);
- nCPUs += 1;
- TOPO_DBG("%d ", lcpu->cpu_num);
- lcpu = lcpu->next_in_die;
- }
- TOPO_DBG("\n");
-
- if (nCPUs != topoParms.nLThreadsPerDie)
- panic("Should have %d Threads, but only found %d for Die %d",
- topoParms.nLThreadsPerDie, nCPUs, die->pdie_num);
-
- nDies += 1;
- die = die->next_in_pkg;
+ x86_pkg_t *pkg;
+ x86_die_t *die;
+ x86_core_t *core;
+ x86_lcpu_t *lcpu;
+ uint32_t nDies;
+ uint32_t nCores;
+ uint32_t nCPUs;
+
+ if (topo_dbg) {
+ debug_topology_print();
- nCores = 0;
- core = pkg->cores;
- while (core != NULL) {
- if (core->package == NULL)
- panic("Core(%d)->package is NULL",
- core->pcore_num);
- if (core->package != pkg)
- panic("Core %d points to package %d, should be %d",
- core->pcore_num, core->package->lpkg_num, pkg->lpkg_num);
- TOPO_DBG("Core(%d)->package %d\n",
- core->pcore_num, pkg->lpkg_num);
-
- /*
- * Make sure that the core has the correct number of CPUs.
- */
- nCPUs = 0;
- lcpu = core->lcpus;
- TOPO_DBG("Core(%d)->lcpus: ", core->pcore_num);
- while (lcpu != NULL) {
- if (lcpu->core == NULL)
- panic("CPU(%d)->core is NULL",
- lcpu->cpu_num);
- if (lcpu->core != core)
- panic("CPU %d points to core %d, should be %d",
- lcpu->cpu_num, lcpu->core->pcore_num, core->pcore_num);
- TOPO_DBG("%d ", lcpu->cpu_num);
- nCPUs += 1;
- lcpu = lcpu->next_in_core;
- }
- TOPO_DBG("\n");
-
- if (nCPUs != topoParms.nLThreadsPerCore)
- panic("Should have %d Threads, but only found %d for Core %d",
- topoParms.nLThreadsPerCore, nCPUs, core->pcore_num);
- nCores += 1;
- core = core->next_in_pkg;
+ nCPUs = topoParms.nPackages * topoParms.nLThreadsPerPackage;
+ if (nCPUs != real_ncpus) {
+ panic("x86_validate_topology() %d threads but %d registered from MADT",
+ nCPUs, real_ncpus);
- if (nCores != topoParms.nLCoresPerPackage)
- panic("Should have %d Cores, but only found %d for package %d",
- topoParms.nLCoresPerPackage, nCores, pkg->lpkg_num);
+ pkg = x86_pkgs;
+ while (pkg != NULL) {
+ /*
+ * Make sure that the package has the correct number of dies.
+ */
+ nDies = 0;
+ die = pkg->dies;
+ while (die != NULL) {
+ if (die->package == NULL) {
+ panic("Die(%d)->package is NULL",
+ die->pdie_num);
+ }
+ if (die->package != pkg) {
+ panic("Die %d points to package %d, should be %d",
+ die->pdie_num, die->package->lpkg_num, pkg->lpkg_num);
+ }
+
+ TOPO_DBG("Die(%d)->package %d\n",
+ die->pdie_num, pkg->lpkg_num);
+
+ /*
+ * Make sure that the die has the correct number of cores.
+ */
+ TOPO_DBG("Die(%d)->cores: ", die->pdie_num);
+ nCores = 0;
+ core = die->cores;
+ while (core != NULL) {
+ if (core->die == NULL) {
+ panic("Core(%d)->die is NULL",
+ core->pcore_num);
+ }
+ if (core->die != die) {
+ panic("Core %d points to die %d, should be %d",
+ core->pcore_num, core->die->pdie_num, die->pdie_num);
+ }
+ nCores += 1;
+ TOPO_DBG("%d ", core->pcore_num);
+ core = core->next_in_die;
+ }
+ TOPO_DBG("\n");
+
+ if (nCores != topoParms.nLCoresPerDie) {
+ panic("Should have %d Cores, but only found %d for Die %d",
+ topoParms.nLCoresPerDie, nCores, die->pdie_num);
+ }
+
+ /*
+ * Make sure that the die has the correct number of CPUs.
+ */
+ TOPO_DBG("Die(%d)->lcpus: ", die->pdie_num);
+ nCPUs = 0;
+ lcpu = die->lcpus;
+ while (lcpu != NULL) {
+ if (lcpu->die == NULL) {
+ panic("CPU(%d)->die is NULL",
+ lcpu->cpu_num);
+ }
+ if (lcpu->die != die) {
+ panic("CPU %d points to die %d, should be %d",
+ lcpu->cpu_num, lcpu->die->pdie_num, die->pdie_num);
+ }
+ nCPUs += 1;
+ TOPO_DBG("%d ", lcpu->cpu_num);
+ lcpu = lcpu->next_in_die;
+ }
+ TOPO_DBG("\n");
+
+ if (nCPUs != topoParms.nLThreadsPerDie) {
+ panic("Should have %d Threads, but only found %d for Die %d",
+ topoParms.nLThreadsPerDie, nCPUs, die->pdie_num);
+ }
+
+ nDies += 1;
+ die = die->next_in_pkg;
+ }
- if (nCPUs != topoParms.nLThreadsPerPackage)
- panic("Should have %d Threads, but only found %d for package %d",
- topoParms.nLThreadsPerPackage, nCPUs, pkg->lpkg_num);
+ /*
+ * Make sure that the package has the correct number of cores.
+ */
+ nCores = 0;
+ core = pkg->cores;
+ while (core != NULL) {
+ if (core->package == NULL) {
+ panic("Core(%d)->package is NULL",
+ core->pcore_num);
+ }
+ if (core->package != pkg) {
+ panic("Core %d points to package %d, should be %d",
+ core->pcore_num, core->package->lpkg_num, pkg->lpkg_num);
+ }
+ TOPO_DBG("Core(%d)->package %d\n",
+ core->pcore_num, pkg->lpkg_num);
+
+ /*
+ * Make sure that the core has the correct number of CPUs.
+ */
+ nCPUs = 0;
+ lcpu = core->lcpus;
+ TOPO_DBG("Core(%d)->lcpus: ", core->pcore_num);
+ while (lcpu != NULL) {
+ if (lcpu->core == NULL) {
+ panic("CPU(%d)->core is NULL",
+ lcpu->cpu_num);
+ }
+ if (lcpu->core != core) {
+ panic("CPU %d points to core %d, should be %d",
+ lcpu->cpu_num, lcpu->core->pcore_num, core->pcore_num);
+ }
+ TOPO_DBG("%d ", lcpu->cpu_num);
+ nCPUs += 1;
+ lcpu = lcpu->next_in_core;
+ }
+ TOPO_DBG("\n");
+
+ if (nCPUs != topoParms.nLThreadsPerCore) {
+ panic("Should have %d Threads, but only found %d for Core %d",
+ topoParms.nLThreadsPerCore, nCPUs, core->pcore_num);
+ }
+ nCores += 1;
+ core = core->next_in_pkg;
+ }
+ if (nCores != topoParms.nLCoresPerPackage) {
+ panic("Should have %d Cores, but only found %d for package %d",
+ topoParms.nLCoresPerPackage, nCores, pkg->lpkg_num);
+ }
+
+ /*
+ * Make sure that the package has the correct number of CPUs.
+ */
+ nCPUs = 0;
+ lcpu = pkg->lcpus;
+ while (lcpu != NULL) {
+ if (lcpu->package == NULL) {
+ panic("CPU(%d)->package is NULL",
+ lcpu->cpu_num);
+ }
+ if (lcpu->package != pkg) {
+ panic("CPU %d points to package %d, should be %d",
+ lcpu->cpu_num, lcpu->package->lpkg_num, pkg->lpkg_num);
+ }
+ TOPO_DBG("CPU(%d)->package %d\n",
+ lcpu->cpu_num, pkg->lpkg_num);
+ nCPUs += 1;
+ lcpu = lcpu->next_in_pkg;
+ }
+
+ if (nCPUs != topoParms.nLThreadsPerPackage) {
+ panic("Should have %d Threads, but only found %d for package %d",
+ topoParms.nLThreadsPerPackage, nCPUs, pkg->lpkg_num);
+ }
+
+ pkg = pkg->next;
+ }
- x86_pkg_t *pkg;
- x86_die_t *die;
- x86_core_t *core;
- x86_lcpu_t *cpu;
-
- pkg = x86_pkgs;
- while (pkg != NULL) {
- kprintf("Package:\n");
- kprintf(" Physical: %d\n", pkg->ppkg_num);
- kprintf(" Logical: %d\n", pkg->lpkg_num);
-
- die = pkg->dies;
- while (die != NULL) {
- kprintf(" Die:\n");
- kprintf(" Physical: %d\n", die->pdie_num);
- kprintf(" Logical: %d\n", die->ldie_num);
-
- core = die->cores;
- while (core != NULL) {
- kprintf(" Core:\n");
- kprintf(" Physical: %d\n", core->pcore_num);
- kprintf(" Logical: %d\n", core->lcore_num);
-
- cpu = core->lcpus;
- while (cpu != NULL) {
- kprintf(" LCPU:\n");
- kprintf(" CPU #: %d\n", cpu->cpu_num);
- kprintf(" Physical: %d\n", cpu->pnum);
- kprintf(" Logical: %d\n", cpu->lnum);
- kprintf(" Flags: ");
- if (cpu->master)
- kprintf("MASTER ");
- if (cpu->primary)
- kprintf("PRIMARY");
- if (!cpu->master && !cpu->primary)
- kprintf("(NONE)");
- kprintf("\n");
-
- cpu = cpu->next_in_core;
+ x86_pkg_t *pkg;
+ x86_die_t *die;
+ x86_core_t *core;
+ x86_lcpu_t *cpu;
+
+ pkg = x86_pkgs;
+ while (pkg != NULL) {
+ kprintf("Package:\n");
+ kprintf(" Physical: %d\n", pkg->ppkg_num);
+ kprintf(" Logical: %d\n", pkg->lpkg_num);
+
+ die = pkg->dies;
+ while (die != NULL) {
+ kprintf(" Die:\n");
+ kprintf(" Physical: %d\n", die->pdie_num);
+ kprintf(" Logical: %d\n", die->ldie_num);
+
+ core = die->cores;
+ while (core != NULL) {
+ kprintf(" Core:\n");
+ kprintf(" Physical: %d\n", core->pcore_num);
+ kprintf(" Logical: %d\n", core->lcore_num);
+
+ cpu = core->lcpus;
+ while (cpu != NULL) {
+ kprintf(" LCPU:\n");
+ kprintf(" CPU #: %d\n", cpu->cpu_num);
+ kprintf(" Physical: %d\n", cpu->pnum);
+ kprintf(" Logical: %d\n", cpu->lnum);
+ kprintf(" Flags: ");
+ if (cpu->master) {
+ kprintf("MASTER ");
+ }
+ if (cpu->primary) {
+ kprintf("PRIMARY");
+ }
+ if (!cpu->master && !cpu->primary) {
+ kprintf("(NONE)");
+ }
+ kprintf("\n");
+
+ cpu = cpu->next_in_core;
+ }
+
+ core = core->next_in_die;
+ }
+
+ die = die->next_in_pkg;