Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp698006rdb; Thu, 22 Feb 2024 17:38:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMG7mRTPjcloxNF+i96HaR/7BeyQMmZ147Vxo1/QQZbQrxR7r8EQkm26BkxVIgqQdCLHblg8Ox3+hzD2UUDwPYnZFQDnqh6ix4yPG5wg== X-Google-Smtp-Source: AGHT+IH8gkkgKb3d7r8qRTinL1/bKLIcyDqdJFvDbl+RDZPbQ+0qx4+SoWt+iKuUdU0nCbO3oRKi X-Received: by 2002:a92:d84a:0:b0:365:4475:9331 with SMTP id h10-20020a92d84a000000b0036544759331mr709136ilq.21.1708652322531; Thu, 22 Feb 2024 17:38:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708652322; cv=pass; d=google.com; s=arc-20160816; b=ku1qf9ohkfE1u0scMwVGf7I+8NL0Wr6jJvW8vvgERHhq5kBfUb8rO5hW+IqJmANBKO WuxAsd9Md7MTq46kJtQKky3FUprkYCFYYGu4m+ZudnHgXzvoA3qUDolhSDzNPJQevp48 DePVk1YapnqjTouE/3dO5kEqRv6StSgcE2QRILs2R3h6BR6Sg8F68OERCLKtOG7e/q/3 c+z3Bcw4HdrSCd1AUb1Mx9ATRPjaoYtVksaIp9N9UT3JuhuuEalgpCJhBjxtnK90ixDW 19zKUuZZNUhpT5rtsEJQt2YgeT8JLPxuExpFk4Zt/tXu3sdhHLEpIxPlBtOaZ0L0fmRj jMlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=fJPIUUm/mIbzRmGTJsg5X63GQ0pru4llRiB5k8zA6Sc=; fh=lLPcIKD3o6/XCqb6KoG8Df8mLLUJks+5Flmx3bbm2ns=; b=WjV59bGnHfiYbdbtKceI8b6Z8EjJyf4rd3FfFUVbFrasDN7cMLojcr++AO2LDKABqw k2aICddLRvayGICwB4/rYE7FeZM2N5rh73His1BOAsoCu1q5zanilCtYj5xje1xwcA6J unZzaNf0xfwzY3Dk7MNrtg+tEOysMJFA617rf3/DwExIXm2fP9hyo3NPogOEM5j+Gyjb oT2XE/U60R6UJNz3xbWhFnXkE508N2TjZTRVx47P7gW0kcWZYqFuiPkYBiLh2A4gJ1Ub by5u3T03NyJLkyfz1YjoS3lf0wtVjSjOD4IMitJBVMrXfqiFHIjDs5wFlqS3xknTHRsg uwGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MtY7VIV0; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-77639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bv192-20020a632ec9000000b005e43cb6847bsi2526821pgb.877.2024.02.22.17.38.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 17:38:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MtY7VIV0; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-77639-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 347022859CD for ; Fri, 23 Feb 2024 01:38:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF7E7125D9; Fri, 23 Feb 2024 01:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MtY7VIV0" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 641425CB5 for ; Fri, 23 Feb 2024 01:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708652200; cv=none; b=IB/482YfdcREh7vFrV1d/GgKqU6NQt9T77YYl5N/N6p1FLQEa8byKvdS0lY5uqLmiAmzDOdxMk4XxaCUm6cYY9Hh7BN0SSpRdv3GtWrdZuEYcP5TQXOQCf2IBxxBTz3yHJTq5mOywHpxL0+1mCpGWwNviQ1+Tse51N2t2y9aO/8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708652200; c=relaxed/simple; bh=+6iflh9OwyDaYSBxEKexc+X2ZO9QrWnV28hXqu/Xngc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mZMPEqOdfv2ADINIZ29cL8YntCT+E1Dlxe5kSKhAaCNdsIrfgUrqPUKSpXzAqs7sZuV5ERG/xmhguTIZXNRzMyXHv7r33LIiL0eUlAy/DBhfwdI6dCt609b5jzMVzpXYMbePgghR3tqE9fmUGRteqQH8LoPvVuMCT6pr64hRDGQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MtY7VIV0; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-608575317f8so6466597b3.3 for ; Thu, 22 Feb 2024 17:36:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708652198; x=1709256998; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=fJPIUUm/mIbzRmGTJsg5X63GQ0pru4llRiB5k8zA6Sc=; b=MtY7VIV0F48GUZzHBCIdYL20n8IZd/HjFzFD9+n5saXUqsxOQEExqmZ7ZhZCwFT4sO o/q5UqQIpI2vmf84c//1yli36S1gglxy7JgUFnQ4S1ERqYmHYRBJU99Dikub0VRIXM7L GgOulXTRtlQdiXO0eZ/QpDjgIFD7jUlTzTDRctpISKXXVDnAypWY06cMqhwWT4O5P12Z +kh6fCIbw3j0gIyUpANYfL0yMRX4DrP6Jt7WSjMHgnOrw4piFGuUQsC+hhJLq624GHGN e1UoJFV7W2hzf8I719SNoWgppdL4R8u9guOOJ5F1I2c1k719oO4G79vUKYzEoT1a87kU 1j2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708652198; x=1709256998; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fJPIUUm/mIbzRmGTJsg5X63GQ0pru4llRiB5k8zA6Sc=; b=l/CTOuNrvgZr3mFFD9QEqhzAjCJZWc1mXPMSJC8ffAm2bGxhA4ceiBZHY/it/LZ8RH OJRZLAKda4vpwLMqQ/MX/pmYMbC+GojAvMHxrpiB+6Bejo5jixLt94JsPSTbF+WTxQBB /0QrV/QtMsKsplcUt5pJsW94HPpYx81Qzzi+EefyXWFDP27QNNeRgcqTt+7vc9CPxoPx ud5KzREDYBVHVjOaXc2PPxyPEistFRtHinTJ87X0sJxxhzFHixLk1jj5FoRLmKOaTkNr gq7WA6wI/elYMWHeMJwK9c2WlDaqLt5TfSAweYc2NqSxwfCVGXTphcCvcPGKYViOCDXf XO4w== X-Forwarded-Encrypted: i=1; AJvYcCVJe3lx4tci9+EhDTywU2xsGFmyTLddl1NAHjrdSEDLbpnRQiDq+df68c27RMDwabUcFrHOfZjlYlVSia8zj07CXHoJVAOy0vYTsRCC X-Gm-Message-State: AOJu0YziotytSphXxwIXfKGchQOJesYvrAdxYa38Wpp0gDm3tyOSS8gy h6dK4uxQV5lZeM1oZEofkvhbRk6xCDVFEJHDwhYPBaumZcwDXFvAFS+ngp02SmMxrqP9zIsoN1B 6CQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a0d:d408:0:b0:608:801a:e66e with SMTP id w8-20020a0dd408000000b00608801ae66emr167575ywd.3.1708652198486; Thu, 22 Feb 2024 17:36:38 -0800 (PST) Date: Thu, 22 Feb 2024 17:35:46 -0800 In-Reply-To: <20240111020048.844847-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240111020048.844847-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <170864814086.3090349.6029084831645798943.b4-ty@google.com> Subject: Re: [PATCH 0/8] KVM: x86/mmu: Allow TDP MMU (un)load to run in parallel From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Pattara Teerapong Content-Type: text/plain; charset="utf-8" On Wed, 10 Jan 2024 18:00:40 -0800, Sean Christopherson wrote: > This series is the result of digging into why deleting a memslot, which on > x86 forces all vCPUs to reload a new MMU root, causes noticeably more jitter > in vCPUs and other tasks when running with the TDP MMU than the Shadow MMU > (with TDP enabled). > > Patch 1 addresses the most obvious issue by simply zapping at a finer > granularity so that if a different task, e.g. a vCPU, wants to run on the > pCPU doing the zapping, it doesn't have to wait for KVM to zap an entire > 1GiB region, which can take a hundreds of microseconds (or more). The > shadow MMU checks for need_resched() (and mmu_lock contention, see below) > every 10 zaps, which is why the shadow MMU doesn't induce the same level > of jitter. > > [...] Applied to kvm-x86 mmu, thanks! [1/8] KVM: x86/mmu: Zap invalidated TDP MMU roots at 4KiB granularity https://github.com/kvm-x86/linux/commit/8ca983631f3c [2/8] KVM: x86/mmu: Don't do TLB flush when zappings SPTEs in invalid roots https://github.com/kvm-x86/linux/commit/fcdffe97f80e [3/8] KVM: x86/mmu: Allow passing '-1' for "all" as_id for TDP MMU iterators https://github.com/kvm-x86/linux/commit/6577f1efdff4 [4/8] KVM: x86/mmu: Skip invalid roots when zapping leaf SPTEs for GFN range https://github.com/kvm-x86/linux/commit/99b85fda91b1 [5/8] KVM: x86/mmu: Skip invalid TDP MMU roots when write-protecting SPTEs https://github.com/kvm-x86/linux/commit/d746182337c2 [6/8] KVM: x86/mmu: Check for usable TDP MMU root while holding mmu_lock for read https://github.com/kvm-x86/linux/commit/f5238c2a60f1 [7/8] KVM: x86/mmu: Alloc TDP MMU roots while holding mmu_lock for read https://github.com/kvm-x86/linux/commit/dab285e4ec73 [8/8] KVM: x86/mmu: Free TDP MMU roots while holding mmy_lock for read https://github.com/kvm-x86/linux/commit/576a15de8d29 -- https://github.com/kvm-x86/linux/tree/next