chengshan / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
24d93b
centosplus kernel patch [bug#12818]
24d93b
24d93b
From ac68351410df683a149e7eea09df178884cf2419 Mon Sep 17 00:00:00 2001
24d93b
From: Marcus Sundberg <marcus.sundberg@aptilo.com>
24d93b
Date: Mon, 13 Feb 2017 22:57:11 +0100
24d93b
Subject: [PATCH] [x86] perf: uncore: Avoid kernel panic on missing topology
24d93b
24d93b
The uncore code is heavily dependent on the CPU topology mapping code,
24d93b
so if we do not even have a working topology for the boot CPU we just
24d93b
give up.
24d93b
This happens for example on HPE DL360 Gen9 servers with x2APIC enabled
24d93b
in the firmware settings, where the kernel only finds a single core.
24d93b
---
24d93b
 arch/x86/events/intel/uncore.c | 14 ++++++++++++++
24d93b
 1 file changed, 14 insertions(+)
24d93b
24d93b
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
24d93b
index 77ec6c0..88d79f6 100644
24d93b
--- a/arch/x86/events/intel/uncore.c
24d93b
+++ b/arch/x86/events/intel/uncore.c
24d93b
@@ -1394,6 +1394,20 @@ static int __init intel_uncore_init(void)
24d93b
 	if (is_kdump_kernel())
24d93b
 		return -ENODEV;
24d93b
 
24d93b
+	/* Sanity check - do not even try to proceed if we have no
24d93b
+	   working topology mapping for the boot CPU. */
24d93b
+	if (rh_boot_cpu_data.logical_proc_id < 0 ||
24d93b
+	    topology_phys_to_logical_pkg(boot_cpu_data.phys_proc_id) < 0) {
24d93b
+		printk(KERN_ERR
24d93b
+		       "no mapping between physical and logical CPU, "
24d93b
+		       "boot CPU phys: %d, logical: %d/%d\n",
24d93b
+		       (int)boot_cpu_data.phys_proc_id,
24d93b
+		       (int)rh_boot_cpu_data.logical_proc_id,
24d93b
+		       (int)topology_phys_to_logical_pkg(
24d93b
+			       boot_cpu_data.phys_proc_id));
24d93b
+		return -ENODEV;
24d93b
+	}
24d93b
+
24d93b
 	max_packages = topology_max_packages();
24d93b
 
24d93b
 	pret = uncore_pci_init();
24d93b
-- 
24d93b
2.5.0
24d93b