scx_utils: Add extra ordering macros for topology

Add extra ordering macros for Core/CPU structs for ease of use with
Rust standard library features. This issue was hit when trying to sort
cores based on the CoreType. See this similar issue for details:
https://github.com/rust-lang/rust/issues/113550

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
This commit is contained in:
Daniel Hodges 2024-09-20 11:41:23 -04:00
parent a3cc4c223f
commit a9f3190b5f
No known key found for this signature in database
GPG Key ID: D295F6D6F3E97B18
2 changed files with 4 additions and 4 deletions

View File

@ -68,7 +68,7 @@ use std::ops::BitOrAssign;
use std::ops::BitXor;
use std::ops::BitXorAssign;
#[derive(Debug, Clone)]
#[derive(Debug, Eq, Clone, Ord, PartialEq, PartialOrd)]
pub struct Cpumask {
mask: BitVec<u64, Lsb0>,
}

View File

@ -99,13 +99,13 @@ lazy_static::lazy_static! {
pub static ref NR_CPUS_POSSIBLE: usize = libbpf_rs::num_possible_cpus().unwrap();
}
#[derive(Debug, Clone, Eq, Hash, PartialEq)]
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum CoreType {
Big { turbo: bool },
Little,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Cpu {
id: usize,
min_freq: usize,
@ -163,7 +163,7 @@ impl Cpu {
}
}
#[derive(Debug, Clone)]
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Core {
id: usize,
pub node_id: usize,