arch/x86/mm/amdtopology.c

Source file repositories/reference/linux-study-clean/arch/x86/mm/amdtopology.c

File Facts

System
Linux kernel
Corpus path
arch/x86/mm/amdtopology.c
Extension
.c
Size
3874 bytes
Lines
175
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if ((base & 3) == 0) {
			if (i < numnodes)
				pr_info("Skipping disabled node %d\n", i);
			continue;
		}
		if (nodeid >= numnodes) {
			pr_info("Ignoring excess node %d (%Lx:%Lx)\n", nodeid,
				base, limit);
			continue;
		}

		if (!limit) {
			pr_info("Skipping node entry %d (base %Lx)\n",
				i, base);
			continue;
		}
		if ((base >> 8) & 3 || (limit >> 8) & 3) {
			pr_err("Node %d using interleaving mode %Lx/%Lx\n",
			       nodeid, (base >> 8) & 3, (limit >> 8) & 3);
			return -EINVAL;
		}
		if (node_isset(nodeid, numa_nodes_parsed)) {
			pr_info("Node %d already present, skipping\n",
				nodeid);
			continue;
		}

		limit >>= 16;
		limit++;
		limit <<= 24;

		if (limit > end)
			limit = end;
		if (limit <= base)
			continue;

		base >>= 16;
		base <<= 24;

		if (base < start)
			base = start;
		if (limit > end)
			limit = end;
		if (limit == base) {
			pr_err("Empty node %d\n", nodeid);
			continue;
		}
		if (limit < base) {
			pr_err("Node %d bogus settings %Lx-%Lx.\n",
			       nodeid, base, limit);
			continue;
		}

		/* Could sort here, but pun for now. Should not happen anyroads. */
		if (prevbase > base) {
			pr_err("Node map not sorted %Lx,%Lx\n",
			       prevbase, base);
			return -EINVAL;
		}

		pr_info("Node %d MemBase %016Lx Limit %016Lx\n",
			nodeid, base, limit);

		prevbase = base;
		numa_add_memblk(nodeid, base, limit);
		node_set(nodeid, numa_nodes_parsed);
	}

	if (nodes_empty(numa_nodes_parsed))
		return -ENOENT;

	/*
	 * We seem to have valid NUMA configuration. Map apicids to nodes
	 * using the size of the core domain in the APIC space.
	 */
	cores = topology_get_domain_size(TOPO_CORE_DOMAIN);

	apicid = boot_cpu_physical_apicid;
	if (apicid > 0)
		pr_info("BSP APIC ID: %02x\n", apicid);

	for_each_node_mask(i, numa_nodes_parsed) {
		for (j = 0; j < cores; j++, apicid++)
			set_apicid_to_node(apicid, i);
	}
	return 0;
}

Annotation

Implementation Notes