diff options
| author | Zide Chen <zide.chen@intel.com> | 2026-06-02 07:49:07 -0700 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2026-06-04 11:38:37 +0200 |
| commit | 2aa7dacf8a3d928303df9c770c1bd7f50d1f8f2a (patch) | |
| tree | 019116bb3aaa57c351983201e8e595ea219e26fc | |
| parent | ce044cfb7a365742b2e9229a4b70cf2a663d7270 (diff) | |
| download | linux-2aa7dacf8a3d928303df9c770c1bd7f50d1f8f2a.tar.gz linux-2aa7dacf8a3d928303df9c770c1bd7f50d1f8f2a.zip | |
perf/x86/intel/uncore: Fix uncore_die_to_cpu() for offline dies
If the die is offline when uncore_die_to_cpu() is called, it silently
returns 0, which is misleading. Return -1 in this case to indicate
that all CPUs on the die are offline and the caller can take care of
it accordingly.
Opportunistically, replace -EPERM with -ENODEV, as -ENODEV is
the appropriate error when no CPUs are online across all dies.
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://patch.msgid.link/20260602144908.263680-7-zide.chen@intel.com
| -rw-r--r-- | arch/x86/events/intel/uncore.c | 2 | ||||
| -rw-r--r-- | arch/x86/events/intel/uncore_snbep.c | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 22256ded2d67..4b3a1fa5b41b 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -91,7 +91,7 @@ int uncore_device_to_die(struct pci_dev *dev) */ int uncore_die_to_cpu(int die) { - int res = 0, cpu; + int res = -1, cpu; for_each_online_cpu(cpu) { if (topology_logical_die_id(cpu) == die) { diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 772b78237424..334dc384b5b9 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3772,12 +3772,17 @@ static void pmu_free_topology(struct intel_uncore_type *type) static int skx_pmu_get_topology(struct intel_uncore_type *type, int (*topology_cb)(struct intel_uncore_type*, int, int, u64)) { - int die, ret = -EPERM; + int die, ret = -ENODEV; u64 cpu_bus_msr; + int cpu; cpus_read_lock(); for (die = 0; die < uncore_max_dies(); die++) { - ret = skx_msr_cpu_bus_read(uncore_die_to_cpu(die), &cpu_bus_msr); + cpu = uncore_die_to_cpu(die); + if (cpu == -1) + continue; + + ret = skx_msr_cpu_bus_read(cpu, &cpu_bus_msr); if (ret) break; |
