Account for the case when distance information is not available
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
use crate::acpi::srat::Srat;
|
||||
|
||||
pub fn init_srat(srat: &Srat) {
|
||||
// todo
|
||||
}
|
||||
|
||||
+16
-4
@@ -77,11 +77,10 @@ impl<'a> Iterator for SratIter<'a> {
|
||||
*(entry.add(2) as *const GiccAffinity)
|
||||
}),
|
||||
// ignore GIC ITS Affinity and Generic Initiator Affinity
|
||||
4 | 5 => {
|
||||
_ => {
|
||||
self.i += entry_len as u32;
|
||||
continue;
|
||||
}
|
||||
_ => SratEntry::Unknown(unsafe { *entry }),
|
||||
});
|
||||
self.i += entry_len as u32;
|
||||
return entry;
|
||||
@@ -97,8 +96,7 @@ pub enum SratEntry {
|
||||
ProcessorLocalAffinity(ProcessorLocalAffinity),
|
||||
GiccAffinity(GiccAffinity),
|
||||
// unimplemented: Gic Its Affinity and Generic Initiator Affinity
|
||||
// our current focus is only on memory and cpus
|
||||
Unknown(u8),
|
||||
// our current focus is only on memory and cpus
|
||||
}
|
||||
|
||||
#[repr(C, packed)]
|
||||
@@ -144,3 +142,17 @@ struct GiccAffinity {
|
||||
flags: u32,
|
||||
clock_domain: u32,
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn to_usize(low: u32, high: u32) -> usize {
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
return low as usize;
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
{
|
||||
let mut low_and_high = [0u8; 8];
|
||||
low_and_high[0..=3].copy_from_slice(low.to_le_bytes().as_slice());
|
||||
low_and_high[4..=7].copy_from_slice(high.to_le_bytes().as_slice());
|
||||
usize::from_le_bytes(low_and_high)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-15
@@ -1,24 +1,10 @@
|
||||
use core::iter;
|
||||
|
||||
use crate::{
|
||||
acpi::srat::{Srat, SratEntry},
|
||||
acpi::srat::{to_usize, Srat, SratEntry},
|
||||
numa::{self, NUMA_NODES},
|
||||
};
|
||||
|
||||
#[inline(always)]
|
||||
fn to_usize(low: u32, high: u32) -> usize {
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
return low as usize;
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
{
|
||||
let mut low_and_high = [0u8; 8];
|
||||
low_and_high[0..=3].copy_from_slice(low.to_le_bytes().as_slice());
|
||||
low_and_high[4..=7].copy_from_slice(high.to_le_bytes().as_slice());
|
||||
usize::from_le_bytes(low_and_high)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn to_single_int(high: &[u8; 3], low: u8) -> u32 {
|
||||
let mut high_and_low = [0u8; 4];
|
||||
|
||||
+32
-9
@@ -54,7 +54,8 @@ pub fn init() {
|
||||
#[cfg(any(target_arch = "riscv64", target_arch = "aarch64"))]
|
||||
{
|
||||
if !flag {
|
||||
todo!()
|
||||
// todo!()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,20 +161,42 @@ fn put_for_adoption(
|
||||
distances: Vec<(u32, u8)>,
|
||||
memories: Option<Vec<NumaMemory>>,
|
||||
cpus: Option<Vec<NumaCpu>>,
|
||||
orphan_node_id: u32,
|
||||
orphan_node_id: u32, // id of the node containing only memory / CPU (orphan)
|
||||
) {
|
||||
if let Some(memories) = memories {
|
||||
assert!(cpus.is_none());
|
||||
let (nearest_node_id, distance) = distances.first().unwrap();
|
||||
let nearest_node = nodes.get_mut(nearest_node_id).unwrap();
|
||||
nearest_node.memory.extend(memories);
|
||||
let foster_node = if !distances.is_empty() {
|
||||
let (nearest_node_id, distance) = distances.first().unwrap();
|
||||
nodes.get_mut(nearest_node_id).unwrap()
|
||||
} else {
|
||||
let foster_node_id = {
|
||||
let mut node_ids = nodes.keys();
|
||||
let foster_node = node_ids
|
||||
.find(|node_id| **node_id != orphan_node_id)
|
||||
.unwrap();
|
||||
*foster_node
|
||||
};
|
||||
nodes.get_mut(&foster_node_id).unwrap() // panic not possible since there must be atleast one other domain with a cpu
|
||||
};
|
||||
foster_node.memory.extend(memories);
|
||||
} else if let Some(cpus) = cpus {
|
||||
assert!(memories.is_none());
|
||||
let (nearest_node_id, distance) = distances.first().unwrap();
|
||||
let nearest_node = nodes.get_mut(nearest_node_id).unwrap();
|
||||
nearest_node.cpus.extend(cpus);
|
||||
let foster_node = if !distances.is_empty() {
|
||||
let (nearest_node_id, distance) = distances.first().unwrap();
|
||||
nodes.get_mut(nearest_node_id).unwrap()
|
||||
} else {
|
||||
let foster_node_id = {
|
||||
let mut node_ids = nodes.keys();
|
||||
let foster_node = node_ids
|
||||
.find(|node_id| **node_id != orphan_node_id)
|
||||
.unwrap();
|
||||
*foster_node
|
||||
};
|
||||
nodes.get_mut(&foster_node_id).unwrap() // panic not possible since there must be atleast one other domain with memory
|
||||
};
|
||||
foster_node.cpus.extend(cpus);
|
||||
} else {
|
||||
panic!()
|
||||
unreachable!() // this should never happen
|
||||
};
|
||||
|
||||
for (_, node) in nodes {
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@ use crate::{
|
||||
arch::interrupt,
|
||||
context::{self, switch::SwitchResult},
|
||||
memory::{PhysicalAddress, RmmA, RmmArch},
|
||||
numa, profiling, scheme,
|
||||
numa::{self, NUMA_NODES},
|
||||
profiling, scheme,
|
||||
sync::CleanLockToken,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user