Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions profiles/pci/power_management/profiles.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ vendor_ids = "8086"
device_ids = "*"
cpu_family = "6"
cpu_models = "151 154 183 186 191 170 172 189 204 213"
cpu_hybrid = true
priority = 5
packages = 'intel-lpmd'
post_install = """
Expand Down
6 changes: 6 additions & 0 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ pub fn get_all_devices_of_profile(devices: &ListOfDevicesT, profile: &Profile) -
}
}

if let Some(cpu_hybrid) = profile.cpu_hybrid
&& cpu_hybrid != crate::hwd_misc::is_hybrid_cpu()
{
return vec![];
}

if let Some(gc_versions) = &profile.gc_versions {
if let Some(hwd_gc_versions) = crate::hwd_misc::get_gc_versions() {
return get_all_devices_from_gc_versions(devices, &hwd_gc_versions, gc_versions);
Expand Down
11 changes: 11 additions & 0 deletions src/hwd_misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ fn parse_cpu_info(content: &str) -> Option<CpuInfo> {
Some(CpuInfo { vendor: vendor?, family: family?, model: model? })
}

/// Checks whether the CPU is hybrid, i.e. has E-cores.
///
/// The kernel registers the Atom (E-core) perf PMU under `/sys/devices/cpu_atom` on hybrid CPUs.
/// Non-hybrid dies of hybrid SoCs (e.g. Alder Lake-S without E-cores) still expose the PMU, but
/// without any Atom CPU in its `cpus` list, so the file has to contain a CPU number.
#[must_use]
pub(crate) fn is_hybrid_cpu() -> bool {
std::fs::read_to_string("/sys/devices/cpu_atom/cpus")
.is_ok_and(|s| s.bytes().any(|b| b.is_ascii_digit()))
}

#[must_use]
pub fn get_sysfs_busid_from_amdgpu_path(amdgpu_path: &str) -> &str {
amdgpu_path.split('/')
Expand Down
7 changes: 7 additions & 0 deletions src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub struct Profile {
pub gc_versions: Option<Vec<String>>,
pub cpu_family: Option<String>,
pub cpu_models: Option<Vec<String>>,
pub cpu_hybrid: Option<bool>,
pub chassis_types: Option<Vec<String>>,
pub environment_types: Option<Vec<String>>,
pub driver_conflict_group: Option<String>,
Expand Down Expand Up @@ -76,6 +77,7 @@ impl Default for Profile {
gc_versions: None,
cpu_family: None,
cpu_models: None,
cpu_hybrid: None,
chassis_types: None,
environment_types: None,
driver_conflict_group: None,
Expand Down Expand Up @@ -258,6 +260,7 @@ fn parse_profile(node: &toml::Table, profile_name: &str) -> Result<Profile> {
gc_versions: parse_whitespace_list(node, "gc_versions"),
cpu_family: node.get("cpu_family").and_then(|x| x.as_str().map(str::to_string)),
cpu_models: parse_whitespace_list(node, "cpu_models"),
cpu_hybrid: node.get("cpu_hybrid").and_then(toml::Value::as_bool),
chassis_types: parse_whitespace_list(node, "chassis_types"),
environment_types: parse_whitespace_list(node, "environment_types"),
driver_conflict_group: node
Expand Down Expand Up @@ -469,6 +472,9 @@ fn profile_into_toml(profile: &Profile) -> toml::Table {
if let Some(cpu_models) = &profile.cpu_models {
table.insert("cpu_models".to_owned(), cpu_models.join(" ").into());
}
if let Some(cpu_hybrid) = profile.cpu_hybrid {
table.insert("cpu_hybrid".to_owned(), cpu_hybrid.into());
}
if let Some(chassis_types) = &profile.chassis_types {
table.insert("chassis_types".to_owned(), chassis_types.join(" ").into());
}
Expand Down Expand Up @@ -771,6 +777,7 @@ mod tests {
assert_eq!(parsed_profiles[0].priority, 5);
assert_eq!(parsed_profiles[0].packages, "intel-lpmd");
assert_eq!(parsed_profiles[0].cpu_family, Some("6".to_owned()));
assert_eq!(parsed_profiles[0].cpu_hybrid, Some(true));
assert_eq!(
parsed_profiles[0].cpu_models,
Some(vec![
Expand Down
1 change: 1 addition & 0 deletions tests/profiles/cpu-profile-test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ vendor_ids = "8086"
device_ids = "*"
cpu_family = "6"
cpu_models = "151 154 183 186 191 170 172 189 204 213"
cpu_hybrid = true
priority = 5
packages = 'intel-lpmd'
post_install = """
Expand Down
Loading