Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2018-05-25 09:55:53 +0200
committerJohannes Thumshirn <jthumshirn@suse.de>2018-05-25 09:55:53 +0200
commit1daa82fe7a2ef3513c3148e2161c82dfea5d65ba (patch)
tree1ca2c970900f7dc0370f1529e548e4e9caac0591
parenta951ac5dda18aa5ccaeabeb5d0e8a9ebd897225e (diff)
parente63bf1ea2cba510db340aca73dbfe9ad457ec0ed (diff)
Merge branch 'SLE15' into SLE12-SP4
Conflicts: series.conf
-rw-r--r--patches.arch/x86-smpboot-fix-_max_logical_packages-estimate.patch35
-rw-r--r--patches.arch/x86-smpboot-fix-uncore_pci_remove-indexing-bug-when-hot-removing-a-physical-cpu.patch114
-rw-r--r--patches.arch/x86-topology-avoid-wasting-128k-for-package-id-array.patch203
-rw-r--r--series.conf2
4 files changed, 331 insertions, 23 deletions
diff --git a/patches.arch/x86-smpboot-fix-_max_logical_packages-estimate.patch b/patches.arch/x86-smpboot-fix-_max_logical_packages-estimate.patch
index 3c11551bb1..462526e0ad 100644
--- a/patches.arch/x86-smpboot-fix-_max_logical_packages-estimate.patch
+++ b/patches.arch/x86-smpboot-fix-_max_logical_packages-estimate.patch
@@ -40,13 +40,15 @@ Link: https://lkml.kernel.org/r/20171114124257.22013-4-prarit@redhat.com
Acked-by: Borislav Petkov <bp@suse.de>
---
- arch/x86/kernel/smpboot.c | 69 ++++++----------------------------------------
- 1 file changed, 10 insertions(+), 59 deletions(-)
+ arch/x86/kernel/smpboot.c | 55 +++++++++--------------------------------------
+ 1 file changed, 10 insertions(+), 45 deletions(-)
+diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
+index da5e162636fd..3d01df7d7cf6 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
-@@ -298,12 +298,6 @@ int topology_update_package_map(unsigned
- if (test_and_set_bit(pkg, physical_package_map))
+@@ -310,12 +310,6 @@ int topology_update_package_map(unsigned int pkg, unsigned int cpu)
+ if (new >= 0)
goto found;
- if (logical_packages >= __max_logical_packages) {
@@ -58,14 +60,13 @@ Acked-by: Borislav Petkov <bp@suse.de>
new = logical_packages++;
if (new != pkg) {
pr_info("CPU %u Converting physical %u to logical package %u\n",
-@@ -329,58 +323,6 @@ int topology_phys_to_logical_pkg(unsigne
+@@ -326,44 +320,6 @@ int topology_update_package_map(unsigned int pkg, unsigned int cpu)
+ return 0;
}
- EXPORT_SYMBOL(topology_phys_to_logical_pkg);
-static void __init smp_init_package_map(struct cpuinfo_x86 *c, unsigned int cpu)
-{
- unsigned int ncpus;
-- size_t size;
-
- /*
- * Today neither Intel nor AMD support heterogenous systems. That
@@ -96,19 +97,6 @@ Acked-by: Borislav Petkov <bp@suse.de>
- }
-
- __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
-- logical_packages = 0;
--
-- /*
-- * Possibly larger than what we need as the number of apic ids per
-- * package can be smaller than the actual used apic ids.
-- */
-- max_physical_pkg_id = DIV_ROUND_UP(MAX_LOCAL_APIC, ncpus);
-- size = max_physical_pkg_id * sizeof(unsigned int);
-- physical_to_logical_pkg = kmalloc(size, GFP_KERNEL);
-- memset(physical_to_logical_pkg, 0xff, size);
-- size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long);
-- physical_package_map = kzalloc(size, GFP_KERNEL);
--
- pr_info("Max logical packages: %u\n", __max_logical_packages);
-
- topology_update_package_map(c->phys_proc_id, cpu);
@@ -117,16 +105,16 @@ Acked-by: Borislav Petkov <bp@suse.de>
void __init smp_store_boot_cpu_info(void)
{
int id = 0; /* CPU 0 */
-@@ -388,7 +330,7 @@ void __init smp_store_boot_cpu_info(void
+@@ -371,7 +327,7 @@ void __init smp_store_boot_cpu_info(void)
*c = boot_cpu_data;
c->cpu_index = id;
- smp_init_package_map(c, id);
+ topology_update_package_map(c->phys_proc_id, id);
+ c->initialized = true;
}
- /*
-@@ -1383,7 +1325,16 @@ void __init native_smp_prepare_boot_cpu(
+@@ -1341,7 +1297,16 @@ void __init native_smp_prepare_boot_cpu(void)
void __init native_smp_cpus_done(unsigned int max_cpus)
{
@@ -143,3 +131,4 @@ Acked-by: Borislav Petkov <bp@suse.de>
if (x86_has_numa_in_package)
set_sched_topology(x86_numa_in_package_topology);
+
diff --git a/patches.arch/x86-smpboot-fix-uncore_pci_remove-indexing-bug-when-hot-removing-a-physical-cpu.patch b/patches.arch/x86-smpboot-fix-uncore_pci_remove-indexing-bug-when-hot-removing-a-physical-cpu.patch
new file mode 100644
index 0000000000..8915f3dda1
--- /dev/null
+++ b/patches.arch/x86-smpboot-fix-uncore_pci_remove-indexing-bug-when-hot-removing-a-physical-cpu.patch
@@ -0,0 +1,114 @@
+From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
+Date: Thu, 8 Feb 2018 09:19:08 -0500
+Subject: x86/smpboot: Fix uncore_pci_remove() indexing bug when hot-removing a
+ physical CPU
+Git-commit: 295cc7eb314eb3321fb6d67ca6f7305f5c50d10f
+Patch-mainline: v4.16-rc2
+References: bsc#1091543
+
+When a physical CPU is hot-removed, the following warning messages
+are shown while the uncore device is removed in uncore_pci_remove():
+
+ WARNING: CPU: 120 PID: 5 at arch/x86/events/intel/uncore.c:988
+ uncore_pci_remove+0xf1/0x110
+ ...
+ CPU: 120 PID: 5 Comm: kworker/u1024:0 Not tainted 4.15.0-rc8 #1
+ Workqueue: kacpi_hotplug acpi_hotplug_work_fn
+ ...
+ Call Trace:
+ pci_device_remove+0x36/0xb0
+ device_release_driver_internal+0x145/0x210
+ pci_stop_bus_device+0x76/0xa0
+ pci_stop_root_bus+0x44/0x60
+ acpi_pci_root_remove+0x1f/0x80
+ acpi_bus_trim+0x54/0x90
+ acpi_bus_trim+0x2e/0x90
+ acpi_device_hotplug+0x2bc/0x4b0
+ acpi_hotplug_work_fn+0x1a/0x30
+ process_one_work+0x141/0x340
+ worker_thread+0x47/0x3e0
+ kthread+0xf5/0x130
+
+When uncore_pci_remove() runs, it tries to get the package ID to
+clear the value of uncore_extra_pci_dev[].dev[] by using
+topology_phys_to_logical_pkg(). The warning messesages are
+shown because topology_phys_to_logical_pkg() returns -1.
+
+ arch/x86/events/intel/uncore.c:
+ static void uncore_pci_remove(struct pci_dev *pdev)
+ {
+ ...
+ phys_id = uncore_pcibus_to_physid(pdev->bus);
+ ...
+ pkg = topology_phys_to_logical_pkg(phys_id); // returns -1
+ for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
+ if (uncore_extra_pci_dev[pkg].dev[i] == pdev) {
+ uncore_extra_pci_dev[pkg].dev[i] = NULL;
+ break;
+ }
+ }
+ WARN_ON_ONCE(i >= UNCORE_EXTRA_PCI_DEV_MAX); // <=========== HERE!!
+
+topology_phys_to_logical_pkg() tries to find
+cpuinfo_x86->phys_proc_id that matches the phys_pkg argument.
+
+ arch/x86/kernel/smpboot.c:
+ int topology_phys_to_logical_pkg(unsigned int phys_pkg)
+ {
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+ if (c->initialized && c->phys_proc_id == phys_pkg)
+ return c->logical_proc_id;
+ }
+ return -1;
+ }
+
+However, the phys_proc_id was already set to 0 by remove_siblinginfo()
+when the CPU was offlined.
+
+So, topology_phys_to_logical_pkg() cannot find the correct
+logical_proc_id and always returns -1.
+
+As the result, uncore_pci_remove() calls WARN_ON_ONCE() and the warning
+messages are shown.
+
+What is worse is that the bogus 'pkg' index results in two bugs:
+
+ - We dereference uncore_extra_pci_dev[] with a negative index
+ - We fail to clean up a stale pointer in uncore_extra_pci_dev[][]
+
+To fix these bugs, remove the clearing of ->phys_proc_id from remove_siblinginfo().
+
+This should not cause any problems, because ->phys_proc_id is not
+used after it is hot-removed and it is re-set while hot-adding.
+
+Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
+Acked-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: yasu.isimatu@gmail.com
+Cc: <stable@vger.kernel.org>
+Fixes: 30bb9811856f ("x86/topology: Avoid wasting 128k for package id array")
+Link: http://lkml.kernel.org/r/ed738d54-0f01-b38b-b794-c31dc118c207@gmail.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kernel/smpboot.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
+index 6f27facbaa9b..cfc61e1d45e2 100644
+--- a/arch/x86/kernel/smpboot.c
++++ b/arch/x86/kernel/smpboot.c
+@@ -1430,7 +1430,6 @@ static void remove_siblinginfo(int cpu)
+ cpumask_clear(cpu_llc_shared_mask(cpu));
+ cpumask_clear(topology_sibling_cpumask(cpu));
+ cpumask_clear(topology_core_cpumask(cpu));
+- c->phys_proc_id = 0;
+ c->cpu_core_id = 0;
+ cpumask_clear_cpu(cpu, cpu_sibling_setup_mask);
+ recompute_smt_state();
+
diff --git a/patches.arch/x86-topology-avoid-wasting-128k-for-package-id-array.patch b/patches.arch/x86-topology-avoid-wasting-128k-for-package-id-array.patch
new file mode 100644
index 0000000000..24a26b4ef7
--- /dev/null
+++ b/patches.arch/x86-topology-avoid-wasting-128k-for-package-id-array.patch
@@ -0,0 +1,203 @@
+From: Andi Kleen <ak@linux.intel.com>
+Date: Tue, 14 Nov 2017 07:42:56 -0500
+Subject: x86/topology: Avoid wasting 128k for package id array
+Git-commit: 30bb9811856f667042e746d8033883b1091a46ce
+Patch-mainline: v4.15-rc1
+References: bsc#1091543
+
+Analyzing large early boot allocations unveiled the logical package id
+storage as a prominent memory waste. Since commit 1f12e32f4cd5
+("x86/topology: Create logical package id") every 64-bit system allocates a
+128k array to convert logical package ids.
+
+This happens because the array is sized for MAX_LOCAL_APIC which is always
+32k on 64bit systems, and it needs 4 bytes for each entry.
+
+This is fairly wasteful, especially for the common case of having only one
+socket, which uses exactly 4 byte out of 128K.
+
+There is no user of the package id map which is performance critical, so
+the lookup is not required to be O(1). Store the logical processor id in
+cpu_data and use a loop based lookup.
+
+To keep the mapping stable accross cpu hotplug operations, add a flag to
+cpu_data which is set when the CPU is brought up the first time. When the
+flag is set, then cpu_data is not reinitialized by copying boot_cpu_data on
+subsequent bringups.
+
+[ tglx: Rename the flag to 'initialized', use proper pointers instead of
+ repeated cpu_data(x) evaluation and massage changelog. ]
+
+Signed-off-by: Andi Kleen <ak@linux.intel.com>
+Signed-off-by: Prarit Bhargava <prarit@redhat.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Tom Lendacky <thomas.lendacky@amd.com>
+Cc: Christian Borntraeger <borntraeger@de.ibm.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Kan Liang <kan.liang@intel.com>
+Cc: He Chen <he.chen@linux.intel.com>
+Cc: Stephane Eranian <eranian@google.com>
+Cc: Dave Hansen <dave.hansen@intel.com>
+Cc: Piotr Luc <piotr.luc@intel.com>
+Cc: Andy Lutomirski <luto@kernel.org>
+Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
+Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
+Cc: Borislav Petkov <bp@suse.de>
+Cc: Tim Chen <tim.c.chen@linux.intel.com>
+Cc: Mathias Krause <minipli@googlemail.com>
+Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
+Link: https://lkml.kernel.org/r/20171114124257.22013-3-prarit@redhat.com
+
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/include/asm/processor.h | 1
+ arch/x86/kernel/smpboot.c | 73 +++++++++++++++------------------------
+ 2 files changed, 30 insertions(+), 44 deletions(-)
+
+--- a/arch/x86/include/asm/processor.h
++++ b/arch/x86/include/asm/processor.h
+@@ -131,6 +131,7 @@ struct cpuinfo_x86 {
+ /* Index into per_cpu list: */
+ u16 cpu_index;
+ u32 microcode;
++ unsigned initialized : 1;
+ };
+
+ struct cpuid_regs {
+--- a/arch/x86/kernel/smpboot.c
++++ b/arch/x86/kernel/smpboot.c
+@@ -100,9 +100,6 @@ DEFINE_PER_CPU_READ_MOSTLY(struct cpuinf
+ EXPORT_PER_CPU_SYMBOL(cpu_info);
+
+ /* Logical package management. We might want to allocate that dynamically */
+-static int *physical_to_logical_pkg __read_mostly;
+-static unsigned long *physical_package_map __read_mostly;;
+-static unsigned int max_physical_pkg_id __read_mostly;
+ unsigned int __max_logical_packages __read_mostly;
+ EXPORT_SYMBOL(__max_logical_packages);
+ static unsigned int logical_packages __read_mostly;
+@@ -279,23 +276,36 @@ static void notrace start_secondary(void
+ }
+
+ /**
++ * topology_phys_to_logical_pkg - Map a physical package id to a logical
++ *
++ * Returns logical package id or -1 if not found
++ */
++int topology_phys_to_logical_pkg(unsigned int phys_pkg)
++{
++ int cpu;
++
++ for_each_possible_cpu(cpu) {
++ struct cpuinfo_x86 *c = &cpu_data(cpu);
++
++ if (c->initialized && c->phys_proc_id == phys_pkg)
++ return c->logical_proc_id;
++ }
++ return -1;
++}
++EXPORT_SYMBOL(topology_phys_to_logical_pkg);
++
++/**
+ * topology_update_package_map - Update the physical to logical package map
+ * @pkg: The physical package id as retrieved via CPUID
+ * @cpu: The cpu for which this is updated
+ */
+ int topology_update_package_map(unsigned int pkg, unsigned int cpu)
+ {
+- unsigned int new;
+-
+- /* Called from early boot ? */
+- if (!physical_package_map)
+- return 0;
++ int new;
+
+- if (pkg >= max_physical_pkg_id)
+- return -EINVAL;
+-
+- /* Set the logical package id */
+- if (test_and_set_bit(pkg, physical_package_map))
++ /* Already available somewhere? */
++ new = topology_phys_to_logical_pkg(pkg);
++ if (new >= 0)
+ goto found;
+
+ if (logical_packages >= __max_logical_packages) {
+@@ -309,30 +319,14 @@ int topology_update_package_map(unsigned
+ pr_info("CPU %u Converting physical %u to logical package %u\n",
+ cpu, pkg, new);
+ }
+- physical_to_logical_pkg[pkg] = new;
+-
+ found:
+- cpu_data(cpu).logical_proc_id = physical_to_logical_pkg[pkg];
++ cpu_data(cpu).logical_proc_id = new;
+ return 0;
+ }
+
+-/**
+- * topology_phys_to_logical_pkg - Map a physical package id to a logical
+- *
+- * Returns logical package id or -1 if not found
+- */
+-int topology_phys_to_logical_pkg(unsigned int phys_pkg)
+-{
+- if (phys_pkg >= max_physical_pkg_id)
+- return -1;
+- return physical_to_logical_pkg[phys_pkg];
+-}
+-EXPORT_SYMBOL(topology_phys_to_logical_pkg);
+-
+ static void __init smp_init_package_map(struct cpuinfo_x86 *c, unsigned int cpu)
+ {
+ unsigned int ncpus;
+- size_t size;
+
+ /*
+ * Today neither Intel nor AMD support heterogenous systems. That
+@@ -363,19 +357,6 @@ static void __init smp_init_package_map(
+ }
+
+ __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
+- logical_packages = 0;
+-
+- /*
+- * Possibly larger than what we need as the number of apic ids per
+- * package can be smaller than the actual used apic ids.
+- */
+- max_physical_pkg_id = DIV_ROUND_UP(MAX_LOCAL_APIC, ncpus);
+- size = max_physical_pkg_id * sizeof(unsigned int);
+- physical_to_logical_pkg = kmalloc(size, GFP_KERNEL);
+- memset(physical_to_logical_pkg, 0xff, size);
+- size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long);
+- physical_package_map = kzalloc(size, GFP_KERNEL);
+-
+ pr_info("Max logical packages: %u\n", __max_logical_packages);
+
+ topology_update_package_map(c->phys_proc_id, cpu);
+@@ -389,6 +370,7 @@ void __init smp_store_boot_cpu_info(void
+ *c = boot_cpu_data;
+ c->cpu_index = id;
+ smp_init_package_map(c, id);
++ c->initialized = true;
+ }
+
+ /*
+@@ -399,13 +381,16 @@ void smp_store_cpu_info(int id)
+ {
+ struct cpuinfo_x86 *c = &cpu_data(id);
+
+- *c = boot_cpu_data;
++ /* Copy boot_cpu_data only on the first bringup */
++ if (!c->initialized)
++ *c = boot_cpu_data;
+ c->cpu_index = id;
+ /*
+ * During boot time, CPU0 has this setup already. Save the info when
+ * bringing up AP or offlined CPU0.
+ */
+ identify_secondary_cpu(c);
++ c->initialized = true;
+ }
+
+ static bool
diff --git a/series.conf b/series.conf
index 9c98e5fb9c..bf702fe5b0 100644
--- a/series.conf
+++ b/series.conf
@@ -8912,6 +8912,7 @@
patches.suse/objtool-Fix-cross-build.patch
patches.arch/x86-acpi-handle-sci-interrupts-above-legacy-space-gracefully.patch
patches.arch/x86-acpi-reduce-code-duplication-in-mp_override_legacy_irq.patch
+ patches.arch/x86-topology-avoid-wasting-128k-for-package-id-array.patch
patches.arch/x86-smpboot-fix-_max_logical_packages-estimate.patch
patches.arch/17.2-x86-entry-64-fix-entry_syscall_64_after_hwframe-irq-tracing.patch
patches.fixes/genirq-Track-whether-the-trigger-type-has-been-set.patch
@@ -11100,6 +11101,7 @@
patches.suse/x86-mm-rename-flush_tlb_single-and-flush_tlb_one-to-_flush_tlb_one_.patch
patches.arch/09.0-x86-spectre-fix-an-error-message.patch
patches.suse/x86-entry-64-fix-cr3-restore-in-paranoid_exit.patch
+ patches.arch/x86-smpboot-fix-uncore_pci_remove-indexing-bug-when-hot-removing-a-physical-cpu.patch
patches.arch/x86-platform-uv-fix-gam-range-table-entries-less-than-1gb
patches.fixes/x86-mm-mm-hwpoison-don-t-unconditionally-unmap-kernel-1-1-pages.patch
patches.drivers/PM-runtime-Update-links_count-also-if-CONFIG_SRCU