From 6a5261726113e1035d35a6a46dcc23e4da067ceb Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 9 Jul 2020 14:56:16 -0400 Subject: [PATCH] Fixes for 4.9 Signed-off-by: Sasha Levin --- ...m-s390-reduce-number-of-io-pins-to-1.patch | 73 +++++++++++++++++++ queue-4.9/series | 1 + 2 files changed, 74 insertions(+) create mode 100644 queue-4.9/kvm-s390-reduce-number-of-io-pins-to-1.patch create mode 100644 queue-4.9/series diff --git a/queue-4.9/kvm-s390-reduce-number-of-io-pins-to-1.patch b/queue-4.9/kvm-s390-reduce-number-of-io-pins-to-1.patch new file mode 100644 index 00000000000..c651fd0f5c4 --- /dev/null +++ b/queue-4.9/kvm-s390-reduce-number-of-io-pins-to-1.patch @@ -0,0 +1,73 @@ +From 8c5721b13bef1cbc61c3dce8fe814a47bd13bf07 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Jun 2020 10:36:20 +0200 +Subject: KVM: s390: reduce number of IO pins to 1 + +From: Christian Borntraeger + +[ Upstream commit 774911290c589e98e3638e73b24b0a4d4530e97c ] + +The current number of KVM_IRQCHIP_NUM_PINS results in an order 3 +allocation (32kb) for each guest start/restart. This can result in OOM +killer activity even with free swap when the memory is fragmented +enough: + +kernel: qemu-system-s39 invoked oom-killer: gfp_mask=0x440dc0(GFP_KERNEL_ACCOUNT|__GFP_COMP|__GFP_ZERO), order=3, oom_score_adj=0 +kernel: CPU: 1 PID: 357274 Comm: qemu-system-s39 Kdump: loaded Not tainted 5.4.0-29-generic #33-Ubuntu +kernel: Hardware name: IBM 8562 T02 Z06 (LPAR) +kernel: Call Trace: +kernel: ([<00000001f848fe2a>] show_stack+0x7a/0xc0) +kernel: [<00000001f8d3437a>] dump_stack+0x8a/0xc0 +kernel: [<00000001f8687032>] dump_header+0x62/0x258 +kernel: [<00000001f8686122>] oom_kill_process+0x172/0x180 +kernel: [<00000001f8686abe>] out_of_memory+0xee/0x580 +kernel: [<00000001f86e66b8>] __alloc_pages_slowpath+0xd18/0xe90 +kernel: [<00000001f86e6ad4>] __alloc_pages_nodemask+0x2a4/0x320 +kernel: [<00000001f86b1ab4>] kmalloc_order+0x34/0xb0 +kernel: [<00000001f86b1b62>] kmalloc_order_trace+0x32/0xe0 +kernel: [<00000001f84bb806>] kvm_set_irq_routing+0xa6/0x2e0 +kernel: [<00000001f84c99a4>] kvm_arch_vm_ioctl+0x544/0x9e0 +kernel: [<00000001f84b8936>] kvm_vm_ioctl+0x396/0x760 +kernel: [<00000001f875df66>] do_vfs_ioctl+0x376/0x690 +kernel: [<00000001f875e304>] ksys_ioctl+0x84/0xb0 +kernel: [<00000001f875e39a>] __s390x_sys_ioctl+0x2a/0x40 +kernel: [<00000001f8d55424>] system_call+0xd8/0x2c8 + +As far as I can tell s390x does not use the iopins as we bail our for +anything other than KVM_IRQ_ROUTING_S390_ADAPTER and the chip/pin is +only used for KVM_IRQ_ROUTING_IRQCHIP. So let us use a small number to +reduce the memory footprint. + +Signed-off-by: Christian Borntraeger +Reviewed-by: Cornelia Huck +Reviewed-by: David Hildenbrand +Link: https://lore.kernel.org/r/20200617083620.5409-1-borntraeger@de.ibm.com +Signed-off-by: Sasha Levin +--- + arch/s390/include/asm/kvm_host.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h +index 5792590d0e7c4..0b3c26e6930d9 100644 +--- a/arch/s390/include/asm/kvm_host.h ++++ b/arch/s390/include/asm/kvm_host.h +@@ -32,12 +32,12 @@ + #define KVM_USER_MEM_SLOTS 32 + + /* +- * These seem to be used for allocating ->chip in the routing table, +- * which we don't use. 4096 is an out-of-thin-air value. If we need +- * to look at ->chip later on, we'll need to revisit this. ++ * These seem to be used for allocating ->chip in the routing table, which we ++ * don't use. 1 is as small as we can get to reduce the needed memory. If we ++ * need to look at ->chip later on, we'll need to revisit this. + */ + #define KVM_NR_IRQCHIPS 1 +-#define KVM_IRQCHIP_NUM_PINS 4096 ++#define KVM_IRQCHIP_NUM_PINS 1 + #define KVM_HALT_POLL_NS_DEFAULT 80000 + + /* s390-specific vcpu->requests bit members */ +-- +2.25.1 + diff --git a/queue-4.9/series b/queue-4.9/series new file mode 100644 index 00000000000..6f2e982ca83 --- /dev/null +++ b/queue-4.9/series @@ -0,0 +1 @@ +kvm-s390-reduce-number-of-io-pins-to-1.patch -- 2.47.3