/*
- * Copyright (c) 2003-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2003-2009 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
*/
#include <vm/vm_kern.h>
#include <kern/kalloc.h>
+#include <kern/etimer.h>
#include <mach/machine.h>
#include <i386/cpu_threads.h>
#include <i386/cpuid.h>
#include <i386/machine_cpu.h>
-#include <i386/lock.h>
-#include <i386/perfmon.h>
#include <i386/pmCPU.h>
+#include <i386/lock.h>
//#define TOPO_DEBUG 1
#if TOPO_DEBUG
#define DBG(x...)
#endif /* TOPO_DEBUG */
+
void validate_topology(void);
+/* Only for 32bit values */
+#define bit(n) (1U << (n))
#define bitmask(h,l) ((bit(h)|(bit(h)-1)) & ~(bit(l)-1))
#define bitfield(x,h,l) (((x) & bitmask(h,l)) >> l)
*/
topoParms.maxSharingLLC = nCPUsSharing;
- topoParms.nCoresSharingLLC = nCPUsSharing;
+ topoParms.nCoresSharingLLC = nCPUsSharing / (cpuinfo->thread_count /
+ cpuinfo->core_count);
topoParms.nLCPUsSharingLLC = nCPUsSharing;
/*
topoParms.nLThreadsPerPackage = topoParms.nLThreadsPerCore * topoParms.nLCoresPerPackage;
topoParms.nPThreadsPerPackage = topoParms.nPThreadsPerCore * topoParms.nPCoresPerPackage;
+ DBG("\nCache Topology Parameters:\n");
+ DBG("\tLLC Depth: %d\n", topoParms.LLCDepth);
+ DBG("\tCores Sharing LLC: %d\n", topoParms.nCoresSharingLLC);
+ DBG("\tThreads Sharing LLC: %d\n", topoParms.nLCPUsSharingLLC);
+ DBG("\tmax Sharing of LLC: %d\n", topoParms.maxSharingLLC);
+
DBG("\nLogical Topology Parameters:\n");
DBG("\tThreads per Core: %d\n", topoParms.nLThreadsPerCore);
DBG("\tCores per Die: %d\n", topoParms.nLCoresPerDie);
cur->type = bitfield(cache_info[eax], 4, 0);
cur->level = bitfield(cache_info[eax], 7, 5);
+ cur->nlcpus = (bitfield(cache_info[eax], 25, 14) + 1);
+ if (cpuid_info()->cpuid_model == 26)
+ cur->nlcpus /= cpu_is_hyperthreaded() ? 1 : 2;
cur->maxcpus = (bitfield(cache_info[eax], 25, 14) + 1);
cur->line_size = bitfield(cache_info[ebx], 11, 0) + 1;
cur->partitions = bitfield(cache_info[ebx], 21, 12) + 1;
x86_match_cache(x86_cpu_cache_t *list, x86_cpu_cache_t *matcher)
{
x86_cpu_cache_t *cur_cache;
-
+
cur_cache = list;
while (cur_cache != NULL) {
if (cur_cache->maxcpus == matcher->maxcpus
x86_lcpu_init(cpu);
- /*
- * Allocate performance counter structure.
- */
- simple_unlock(&x86_topo_lock);
- cpup->lcpu.pmc = pmc_alloc();
- simple_lock(&x86_topo_lock);
-
/*
* Assume that all cpus have the same features.
*/
/*
* Make sure that the die has the correct number of cores.
*/
- DBG("Die(%d)->cores: ");
+ DBG("Die(%d)->cores: ", die->pdie_num);
nCores = 0;
core = die->cores;
while (core != NULL) {
*/
nCPUs = 0;
lcpu = core->lcpus;
- DBG("Core(%d)->lcpus: ");
+ DBG("Core(%d)->lcpus: ", core->pcore_num);
while (lcpu != NULL) {
if (lcpu->core == NULL)
panic("CPU(%d)->core is NULL",