From f0badd7725b233d8b9efa0524d73e7b681cdf597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20H=C3=A9rault?= Date: Tue, 25 Aug 2026 12:17:14 -0400 Subject: [PATCH] cpu: drop the clock baked into x86 model names Intel's `model name` in `/proc/cpuinfo` already ends in `@ 3.60GHz`, so appending the sysfs `cpuinfo_max_freq` reading printed the frequency twice. Cutting at the ` @ ` before re-running `trim` also lets the ` CPU` suffix strip fire, which the clock suffix had been hiding. Co-authored-by: Amaan Qureshi --- crates/lib/src/cpu.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/lib/src/cpu.rs b/crates/lib/src/cpu.rs index 5b49775..1c8b6a7 100644 --- a/crates/lib/src/cpu.rs +++ b/crates/lib/src/cpu.rs @@ -319,17 +319,23 @@ fn write_model_name(w: &mut StackWriter) { }; let data = &buf[..n]; - let found = if let Some(name) = extract_name(data) { - w.push_str(name); - true - } else { - write_dt_compatible(w) - }; - if !found { + let name = extract_name(data); + if name.is_none() && !write_dt_compatible(w) { return; } - if let Some(mhz) = get_cpu_freq_mhz() { + let mhz = get_cpu_freq_mhz(); + if let Some(name) = name { + // x86 `model name` already ends in `@ GHz`, which hides the + // ` CPU` that trim() would otherwise strip, so re-trim after cutting. + let name = match (mhz, name.find(" @ ")) { + (Some(_), Some(at)) => trim(&name[..at]), + _ => name, + }; + w.push_str(name); + } + + if let Some(mhz) = mhz { w.push_str(" @ "); // Round to nearest 0.01 GHz, then split so carries (e.g. 1999 MHz) // roll into the integer part instead of overflowing the fraction.