From f3197c3833315dbdde621916f266b0f96218351e Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Sat, 7 Aug 2021 03:02:15 -0400 Subject: [PATCH] arch: Add `numa-node-id` property to CPU node For the purpose of identification, each NUMA node is associated with a unique token known as a `numa-node-id`. For the purpose of device tree binding, a `numa-node-id` is a 32-bit integer. The CPU node is associated with a NUMA node by the presence of a `numa-node-id` property which contains the node id of the device. Signed-off-by: Henry Wang --- arch/src/aarch64/fdt.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/src/aarch64/fdt.rs b/arch/src/aarch64/fdt.rs index 36e392c57..5f8199619 100644 --- a/arch/src/aarch64/fdt.rs +++ b/arch/src/aarch64/fdt.rs @@ -105,7 +105,7 @@ pub fn create_fdt, + numa_nodes: &NumaNodes, ) -> FdtWriterResult<()> { // See https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/arm/cpus.yaml. let cpus_node = fdt.begin_node("cpus")?; @@ -164,6 +165,17 @@ fn create_cpu_nodes( // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0488c/BABHBJCI.html. fdt.property_u32("reg", (mpidr & 0x7FFFFF) as u32)?; fdt.property_u32("phandle", cpu_id as u32 + FIRST_VCPU_PHANDLE)?; + + // Add `numa-node-id` property if there is any numa config. + if numa_nodes.len() > 1 { + for numa_node_idx in 0..numa_nodes.len() { + let numa_node = numa_nodes.get(&(numa_node_idx as u32)); + if numa_node.unwrap().cpus.contains(&(cpu_id as u8)) { + fdt.property_u32("numa-node-id", numa_node_idx as u32)?; + } + } + } + fdt.end_node(cpu_node)?; }