From patchwork Tue Mar 5 22:42:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krister Johansen X-Patchwork-Id: 1908477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tq9b02fLvz23qV for ; Wed, 6 Mar 2024 09:43:39 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rhdVL-00021X-AU; Tue, 05 Mar 2024 22:43:23 +0000 Received: from bird.elm.relay.mailchannels.net ([23.83.212.17]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rhdVG-00021K-Fr for kernel-team@lists.ubuntu.com; Tue, 05 Mar 2024 22:43:18 +0000 X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 547453616F1 for ; Tue, 5 Mar 2024 22:43:16 +0000 (UTC) Received: from pdx1-sub0-mail-a314.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D2A33361A85 for ; Tue, 5 Mar 2024 22:43:15 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1709678595; a=rsa-sha256; cv=none; b=sREw24N5EjcBaMPgNtAXZck7dxLiKi8NuWoH3U6NCjBm6KePupsRgFDSKU0hMMsIU2P+S0 a+pmea3Rsj/nitzMcD2gPAMIRm7cnStlR6cl++M2CnNU6h8Y57HW//S/lVnprNI6A9b887 nhfXOMFz5CP2JsboxfaKg+GRt/1Fm9pjZTlIiuXMWwWW8Yalx7MojLuL60mGoD/gwiLujv 8R1JCqgZjXf90YdJ7kXu9TwZmdZiKtP+q9jqWR5pAtS3mPhsw5HOMbQCE579l1AtZLbQzs mGGMVsZB4WXguR8d2Yjhw4xdZAQE3C0otQ5V+7uLrRTetmzIf5/epmZf3LDACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709678595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: dkim-signature; bh=fV3vpB56syc8mkDmH+QoVwVtQyS93Oaot/AXGGaqp8g=; b=aRGRffybwLo3Vn+p0L4Bn2qLynBlyxzRQkagDySv7+YDqGcWdCMTABu8jJzXpD3CJ5rXMq At+tiLea4tdH3ruITQr6V3q0nZSGTIFWHOWpsgCeHsDPhLYAUJ1dYdDwB4OIoR8xqLRhAn 2P+iwWuOLDFFdVY2hKXDmv89yxCdkClvuFhq8mA1Mt4c85Kcaqs3Ks13Jcbk9P87jtcrwJ QHFCjsg2P5AboIPwGOiNP7+FsgtsmIVUrUs96CiFD4uqa4GZi+SF++thsFiwzPRINcpy2C QK6YgdVKCq4Zd61MhRVSdRBkulRqhIkJr6kFUgNSGyYSv11i6vogZDghMkcY1A== ARC-Authentication-Results: i=1; rspamd-55b4bfd7cb-5pw8w; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@templeofstupid.com X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|kjlx@templeofstupid.com X-MailChannels-Auth-Id: dreamhost X-Callous-Share: 1551552c7ff0cadd_1709678596095_462879341 X-MC-Loop-Signature: 1709678596095:1182263262 X-MC-Ingress-Time: 1709678596095 Received: from pdx1-sub0-mail-a314.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.124.220.170 (trex/6.9.2); Tue, 05 Mar 2024 22:43:16 +0000 Received: from kmjvbox.templeofstupid.com (c-73-222-159-162.hsd1.ca.comcast.net [73.222.159.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kjlx@templeofstupid.com) by pdx1-sub0-mail-a314.dreamhost.com (Postfix) with ESMTPSA id 4Tq9ZW4WlPz2J for ; Tue, 5 Mar 2024 14:43:15 -0800 (PST) Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e01cd by kmjvbox.templeofstupid.com (DragonFly Mail Agent v0.12); Tue, 05 Mar 2024 14:42:53 -0800 Date: Tue, 5 Mar 2024 14:42:53 -0800 From: Krister Johansen To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 0/2] KVM: arm64: fix softlockups in stage2_apply_range Message-ID: MIME-Version: 1.0 Content-Disposition: inline Received-SPF: pass client-ip=23.83.212.17; envelope-from=kjlx@templeofstupid.com; helo=bird.elm.relay.mailchannels.net X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2056227 [Impact] Tearing down kvm VMs on arm64 can cause softlockups to appear on console. When terminating VMs with > 100Gb of memory and 4k pages, the memory unmap times often exceed 20 seconds, which can trigger the softlockup detector. Portions of the unmap path also have interrupts disabled while tlb invalidation instructions run, which can further contribute to latency problems. My team has observed networking latency problems if the cpu where the teardown is occurring is also mapped to handle a NIC interrupt. Fortunately, a solution has been in place since Linux 6.1. A small pair of patches modify stage2_apply_range to operate on smaller memory ranges before performing a cond_resched. With these patches applied, softlockups are no longer observed when tearing down VMs with large amounts of memory. Although I also submitted the patches to 5.15 LTS (link to LTS submission in "Backport" section), I'd appreciate it if Ubuntu were willing to take this submission in parallel since the impact has left us unable to utilize arm64 for kvm until we can either migrate our hypervisors to hugepages, pick up this fix, or some combination of the two. [Backport] Backport the following fixes from linux 6.1: 3b5c082bbf KVM: arm64: Work out supported block level at compile time 5994bc9e05 KVM: arm64: Limit stage2_apply_range() batch size to largest block The fix is in 5994bc9e05 and 3b5c082bbf is a dependency that was submitted as part of the series. The original submission is here: https://lore.kernel.org/all/20221007234151.461779-1-oliver.upton@linux.dev/ I've also submitted the patches to 5.15 LTS here: https://lore.kernel.org/stable/cover.1709665227.git.kjlx@templeofstupid.com/ Both fixes cherry picked cleanly and there were no conflicts. [Test] Executed a variation of the test from 5994bc9e05 as well as my own run of kvm_page_table_test on a VM with 4k pages and a memory size > 100Gb. Without the patches, softlockups were observed in both tests. With the patches applied, the tests ran without incident. This was tested against both LTS 5.15.150 and linux-aws-5.15.0-1055. [Potential Regression] Regression potential is low. These patches have been present in Linux since 6.1 and appear to have needed no further maintenance. Oliver Upton (2): KVM: arm64: Work out supported block level at compile time KVM: arm64: Limit stage2_apply_range() batch size to largest block arch/arm64/include/asm/kvm_pgtable.h | 18 +++++++++++++----- arch/arm64/include/asm/stage2_pgtable.h | 20 -------------------- arch/arm64/kvm/mmu.c | 9 ++++++++- 3 files changed, 21 insertions(+), 26 deletions(-)