void cpu_fixup_topology(void)
{
struct hap_cpuset cpuset;
- int cpu;
+ int cpu, cpu2;
+ int curr_id, prev_id;
int min_id, neg;
/* fill the package id, node id and thread_id. First we'll build a bitmap
if (ha_cpu_topo[cpu].capa < 0)
ha_cpu_topo[cpu].capa = (ha_cpu_topo[cpu].th_cnt > 1) ? 100 : 50;
}
+
+ /* First, on some machines, L3 is not reported. But some also don't
+ * have L3. However, no L3 when there are more than 2 L2 is quite
+ * unheard of, and while we don't really care about firing 2 groups for
+ * 2 L2, we'd rather avoid this if there are 8! In this case we'll add
+ * an L3 instance to fix the situation.
+ */
+ cpu_reorder_by_locality(ha_cpu_topo, cpu_topo_maxcpus);
+
+ prev_id = -2; // make sure it cannot match even unassigned ones
+ curr_id = -1;
+ for (cpu = cpu2 = 0; cpu <= cpu_topo_lastcpu; cpu++) {
+ if (ha_cpu_topo[cpu].ca_id[3] >= 0)
+ continue;
+
+ /* L3 not assigned, count L2 instances */
+ if (!cpu ||
+ (ha_cpu_topo[cpu].pk_id != ha_cpu_topo[cpu-1].pk_id) ||
+ (ha_cpu_topo[cpu].no_id != ha_cpu_topo[cpu-1].no_id) ||
+ (ha_cpu_topo[cpu].ca_id[4] != ha_cpu_topo[cpu-1].ca_id[4])) {
+ curr_id = 0;
+ prev_id = -2;
+ cpu2 = cpu;
+ }
+ else if (ha_cpu_topo[cpu].ca_id[2] != prev_id) {
+ curr_id++;
+ if (curr_id >= 2) {
+ /* let's assign L3 id to zero for all those.
+ * We can go till the end since we'll just skip
+ * them on next passes above.
+ */
+ for (; cpu2 <= cpu_topo_lastcpu; cpu2++) {
+ if (ha_cpu_topo[cpu2].ca_id[3] < 0 &&
+ ha_cpu_topo[cpu2].pk_id == ha_cpu_topo[cpu].pk_id &&
+ ha_cpu_topo[cpu2].no_id == ha_cpu_topo[cpu].no_id &&
+ ha_cpu_topo[cpu2].ca_id[4] == ha_cpu_topo[cpu].ca_id[4])
+ ha_cpu_topo[cpu2].ca_id[3] = 0;
+ }
+ }
+ }
+ }
+
+ cpu_reorder_by_index(ha_cpu_topo, cpu_topo_maxcpus);
}
/* This function is responsible for composing clusters based on existing info