From dde4f373b9dc589a388a8c50bd8aca3a270f8e31 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Mon, 14 Sep 2026 20:10:09 +0530 Subject: [PATCH 1/6] Show CPU count, cores and threads in the popover Also presume the same CPU model for multi-socket so only show single line with model name instead of one line per physical CPU. --- src/Resources/CPU.vala | 26 ++++++++----------- .../SystemView/SystemCPUInfoPopover.vala | 4 +++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Resources/CPU.vala b/src/Resources/CPU.vala index 7b3aae88d..e00f204f6 100644 --- a/src/Resources/CPU.vala +++ b/src/Resources/CPU.vala @@ -16,6 +16,9 @@ public class Monitor.CPU : Object { public uint ? revision; public string ? model_name; + public uint physical_cpus; + public uint physical_cores_per_cpu; + public uint logical_threads_per_cpu; public string ? model; public string ? family; public string ? microcode; @@ -77,7 +80,7 @@ public class Monitor.CPU : Object { parse_cpuinfo (); - model_name = get_cpu_info (); + model_name = get_cpu_info (out physical_cpus, out physical_cores_per_cpu, out logical_threads_per_cpu); debug ("CPU name: %s", model_name); @@ -259,7 +262,7 @@ public class Monitor.CPU : Object { } // straight from elementary about-plug - private string ? get_cpu_info () { + private string ? get_cpu_info (out uint cpus, out uint cores, out uint threads) { unowned GTop.SysInfo ? info = GTop.glibtop_get_sysinfo (); if (info == null) { @@ -307,21 +310,14 @@ public class Monitor.CPU : Object { string result = ""; foreach (var cpu in counts.entries) { - if (result.length > 0) { - result += "\n"; - } - - if (cpu.@value == 2) { - result += _("Dual-Core %s").printf ((cpu.key)); - } else if (cpu.@value == 4) { - result += _("Quad-Core %s").printf ((cpu.key)); - } else if (cpu.@value == 6) { - result += _("Hexa-Core %s").printf ((cpu.key)); - } else { - result += "%u\u00D7 %s ".printf (cpu.@value, (cpu.key)); - } + result += "%s".printf ((cpu.key)); + cores = cpu.@value; + break; } + cpus = counts.size; + threads = (uint) info.ncpu / cpus; + return Utils.Strings.beautify (result); } } diff --git a/src/Views/SystemView/SystemCPUInfoPopover.vala b/src/Views/SystemView/SystemCPUInfoPopover.vala index a6ba8bc4d..ad71f0e50 100755 --- a/src/Views/SystemView/SystemCPUInfoPopover.vala +++ b/src/Views/SystemView/SystemCPUInfoPopover.vala @@ -59,6 +59,10 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { activate_on_single_click = false }; + listbox.append (label (_("CPUs:") + " %u".printf (cpu.physical_cpus))); + listbox.append (label (_("Cores per CPU:") + " %u".printf (cpu.physical_cores_per_cpu))); + listbox.append (label (_("Threads per CPU:") + " %u".printf (cpu.logical_threads_per_cpu))); + listbox.append (label (_("Model:") + " " + cpu.model)); listbox.append (label (_("Model:") + " " + cpu.model)); listbox.append (label (_("Family:") + " " + cpu.family)); listbox.append (label (_("Microcode ver.:") + " " + cpu.microcode)); From a97b649d7de55478a062a3264de214c828d86569 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Fri, 25 Sep 2026 12:18:13 +0530 Subject: [PATCH 2/6] Simpler get_cpu_info () and fix for multi-cpu --- src/Resources/CPU.vala | 56 +++++++------------ .../SystemView/SystemCPUInfoPopover.vala | 3 +- 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/src/Resources/CPU.vala b/src/Resources/CPU.vala index 1fbbc3ddb..1d6ae14c2 100644 --- a/src/Resources/CPU.vala +++ b/src/Resources/CPU.vala @@ -18,7 +18,7 @@ public class Monitor.CPU : Object { public string ? model_name; public uint physical_cpus; public uint physical_cores_per_cpu; - public uint logical_threads_per_cpu; + public uint logical_threads_per_core; public string ? model; public string ? family; public string ? microcode; @@ -80,7 +80,7 @@ public class Monitor.CPU : Object { parse_cpuinfo (); - model_name = get_cpu_info (out physical_cpus, out physical_cores_per_cpu, out logical_threads_per_cpu); + model_name = get_cpu_info (out physical_cpus, out physical_cores_per_cpu, out logical_threads_per_core); debug ("CPU name: %s", model_name); @@ -259,27 +259,26 @@ public class Monitor.CPU : Object { } } - // straight from elementary about-plug - private string ? get_cpu_info (out uint cpus, out uint cores, out uint threads) { + private string ? get_cpu_info (out uint cpus, out uint cores_per_cpu, out uint threads_per_core) { unowned GTop.SysInfo ? info = GTop.glibtop_get_sysinfo (); if (info == null) { return null; } - var counts = new Gee.HashMap (); - const string[] KEYS = { "model name", "cpu", "Processor" }; + cpus = 1; + cores_per_cpu = 1; + threads_per_core = 1; + + string ? model = null; + + var core_ids = new Gee.HashSet (); + var physical_ids = new Gee.HashSet (); for (int i = 0; i < info.ncpu; i++) { unowned GLib.HashTable values = info.cpuinfo[i].values; - string ? model = null; - foreach (var key in KEYS) { - model = values.lookup (key); - if (model != null) { - break; - } - } + model = values.lookup ("model name"); if (model == null) { debug ("Try ARM decoding for CPU %d", i); @@ -289,33 +288,18 @@ public class Monitor.CPU : Object { } } - string ? core_count = values.lookup ("cpu cores"); - if (core_count != null) { - counts.@set (model, int.parse (core_count)); - continue; - } - - if (!counts.has_key (model)) { - counts.@set (model, 1); - } else { - counts.@set (model, counts.@get (model) + 1); - } - } - - if (counts.size == 0) { - return null; + core_ids.add (values.lookup ("core id")); + physical_ids.add (values.lookup ("physical id")); } - string result = ""; - foreach (var cpu in counts.entries) { - result += "%s".printf ((cpu.key)); - cores = cpu.@value; - break; + if (model == null) { + return "unknown"; } - cpus = counts.size; - threads = (uint) info.ncpu / cpus; + cpus = physical_ids.size; + cores_per_cpu = core_ids.size; + threads_per_core = (uint) info.ncpu / cores_per_cpu / cpus; - return Utils.Strings.beautify (result); + return Utils.Strings.beautify (model); } } diff --git a/src/Views/SystemView/SystemCPUInfoPopover.vala b/src/Views/SystemView/SystemCPUInfoPopover.vala index 65a11e276..4731e691f 100755 --- a/src/Views/SystemView/SystemCPUInfoPopover.vala +++ b/src/Views/SystemView/SystemCPUInfoPopover.vala @@ -61,8 +61,7 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { listbox.append (label (_("CPUs:") + " %u".printf (cpu.physical_cpus))); listbox.append (label (_("Cores per CPU:") + " %u".printf (cpu.physical_cores_per_cpu))); - listbox.append (label (_("Threads per CPU:") + " %u".printf (cpu.logical_threads_per_cpu))); - listbox.append (label (_("Model:") + " " + cpu.model)); + listbox.append (label (_("Threads per core:") + " %u".printf (cpu.logical_threads_per_core))); listbox.append (label (_("Model:") + " " + cpu.model)); listbox.append (label (_("Family:") + " " + cpu.family)); listbox.append (label (_("Microcode ver.:") + " " + cpu.microcode)); From 2050a5d6596f970600ba7b8d9c0848cee306ee41 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Fri, 25 Sep 2026 12:20:43 +0530 Subject: [PATCH 3/6] Fix likely translation format issues --- src/Views/SystemView/SystemCPUInfoPopover.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Views/SystemView/SystemCPUInfoPopover.vala b/src/Views/SystemView/SystemCPUInfoPopover.vala index 4731e691f..3a37b82f7 100755 --- a/src/Views/SystemView/SystemCPUInfoPopover.vala +++ b/src/Views/SystemView/SystemCPUInfoPopover.vala @@ -59,9 +59,9 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { activate_on_single_click = false }; - listbox.append (label (_("CPUs:") + " %u".printf (cpu.physical_cpus))); - listbox.append (label (_("Cores per CPU:") + " %u".printf (cpu.physical_cores_per_cpu))); - listbox.append (label (_("Threads per core:") + " %u".printf (cpu.logical_threads_per_core))); + listbox.append (label (_("CPUs: %u").printf (cpu.physical_cpus))); + listbox.append (label (_("Cores per CPU: %u").printf (cpu.physical_cores_per_cpu))); + listbox.append (label (_("Threads per core: %u").printf (cpu.logical_threads_per_core))); listbox.append (label (_("Model:") + " " + cpu.model)); listbox.append (label (_("Family:") + " " + cpu.family)); listbox.append (label (_("Microcode ver.:") + " " + cpu.microcode)); From fbce8f8585974e28c243195d38dc203a705dc5d6 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Fri, 25 Sep 2026 12:24:14 +0530 Subject: [PATCH 4/6] Include totals in cpu info popover --- src/Views/SystemView/SystemCPUInfoPopover.vala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Views/SystemView/SystemCPUInfoPopover.vala b/src/Views/SystemView/SystemCPUInfoPopover.vala index 3a37b82f7..3782c8c89 100755 --- a/src/Views/SystemView/SystemCPUInfoPopover.vala +++ b/src/Views/SystemView/SystemCPUInfoPopover.vala @@ -59,9 +59,11 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { activate_on_single_click = false }; + var total_cores = cpu.physical_cores_per_cpu * cpu.physical_cpus; + var total_threads = cpu.logical_threads_per_core * total_cores; listbox.append (label (_("CPUs: %u").printf (cpu.physical_cpus))); - listbox.append (label (_("Cores per CPU: %u").printf (cpu.physical_cores_per_cpu))); - listbox.append (label (_("Threads per core: %u").printf (cpu.logical_threads_per_core))); + listbox.append (label (_("Cores per CPU: %u (Total %u)").printf (cpu.physical_cores_per_cpu, total_cores))); + listbox.append (label (_("Threads per core: %u (Total %u)").printf (cpu.logical_threads_per_core, total_threads))); listbox.append (label (_("Model:") + " " + cpu.model)); listbox.append (label (_("Family:") + " " + cpu.family)); listbox.append (label (_("Microcode ver.:") + " " + cpu.microcode)); From 91832e559c5f4b53b75dfb75854271579c263a47 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Fri, 25 Sep 2026 12:32:25 +0530 Subject: [PATCH 5/6] Concise cpu info --- src/Views/SystemView/SystemCPUInfoPopover.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Views/SystemView/SystemCPUInfoPopover.vala b/src/Views/SystemView/SystemCPUInfoPopover.vala index 3782c8c89..12f6b9d6c 100755 --- a/src/Views/SystemView/SystemCPUInfoPopover.vala +++ b/src/Views/SystemView/SystemCPUInfoPopover.vala @@ -62,8 +62,8 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { var total_cores = cpu.physical_cores_per_cpu * cpu.physical_cpus; var total_threads = cpu.logical_threads_per_core * total_cores; listbox.append (label (_("CPUs: %u").printf (cpu.physical_cpus))); - listbox.append (label (_("Cores per CPU: %u (Total %u)").printf (cpu.physical_cores_per_cpu, total_cores))); - listbox.append (label (_("Threads per core: %u (Total %u)").printf (cpu.logical_threads_per_core, total_threads))); + listbox.append (label (_("Cores: %u").printf (total_cores))); + listbox.append (label (_("Threads: %u").printf (total_threads))); listbox.append (label (_("Model:") + " " + cpu.model)); listbox.append (label (_("Family:") + " " + cpu.family)); listbox.append (label (_("Microcode ver.:") + " " + cpu.microcode)); From e3d7ca165f76953a118ddb05c68014636222cacd Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Sat, 26 Sep 2026 09:05:21 +0530 Subject: [PATCH 6/6] Add "Total" wording to CPU info --- src/Views/SystemView/SystemCPUInfoPopover.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Views/SystemView/SystemCPUInfoPopover.vala b/src/Views/SystemView/SystemCPUInfoPopover.vala index 12f6b9d6c..9a832fefa 100755 --- a/src/Views/SystemView/SystemCPUInfoPopover.vala +++ b/src/Views/SystemView/SystemCPUInfoPopover.vala @@ -61,9 +61,9 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { var total_cores = cpu.physical_cores_per_cpu * cpu.physical_cpus; var total_threads = cpu.logical_threads_per_core * total_cores; - listbox.append (label (_("CPUs: %u").printf (cpu.physical_cpus))); - listbox.append (label (_("Cores: %u").printf (total_cores))); - listbox.append (label (_("Threads: %u").printf (total_threads))); + listbox.append (label (_("Total CPUs: %u").printf (cpu.physical_cpus))); + listbox.append (label (_("Total cores: %u").printf (total_cores))); + listbox.append (label (_("Total threads: %u").printf (total_threads))); listbox.append (label (_("Model:") + " " + cpu.model)); listbox.append (label (_("Family:") + " " + cpu.family)); listbox.append (label (_("Microcode ver.:") + " " + cpu.microcode));