Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4984932rwb; Tue, 8 Aug 2023 18:08:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeMVp/16ug160xuDPDtOtJ78IaT8rmtqqS0IFjyUqitir930ugU/BXMgD/cngRxToUPqn0 X-Received: by 2002:aa7:c3c4:0:b0:522:37ca:a51c with SMTP id l4-20020aa7c3c4000000b0052237caa51cmr851784edr.40.1691543316485; Tue, 08 Aug 2023 18:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691543316; cv=none; d=google.com; s=arc-20160816; b=F6OrFPekglP7j4jodUhBLC2p17pZ9cXV3bxNbtw3JI5KRe5N2o4l71BYmh28e7DTh4 WvtsNXLf6UPXUD67IVvzQU5Xckjl4jbaIptDUdE4badOe8gVf3Mjo1yMylMP9xJJ+hLd yLzVFRSAgAFROfgDXOyuuaXK0wVR1F7Cuaddvj8Lc0J/479fQkzmeXETdW8bFBjoSmw0 aGDk3Z+dL+YcwydDB7TJ3vcVKuSAIatSbhUfRZx8vq9rCSa/mOr52Jl7Kul+g8oOlmdl 0mfoGRslvKaCAVOWdZi12uUwMfNatOsp14y8OU7Bp7Oo1WSiACjxQiK3LKIKL6as/lYU QuBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ceh3/nJpRP3LCUTMqceYFYfxrY0H2MNGDIBSz6bT86E=; fh=yw5tXiXa6fgZNcqMuRzw9eeT6vziy3WnhZBwRz1vFio=; b=KeEmZ3b7jUSOQkMsNypYR/40kdUczDMjAQQ/4oJvpsKy89Ztd1k3M3qIzmAT/0Rdhd vNLESY4lv/FLIcxewnfj/Boh2NuuGM+5Y5DeV5NC0vB9Y3iQVJ4nQS095ru8nI5nmup9 1aghythdQnMfRx6ekGikuD5g7uHKiA7D8kF3kGRh7x6Sz6ys5DnQEzw+jsvak4qoRNl3 UYjcQBo2jitBDrwBGCv7/IfcZdwH3MDPXeZszFQO+idq9BNHUaNu5m8N8FdvOz3cTAg+ AkV/3Ci3AfYQmqL8Yr1unPzSss20BXw7Bl1CpPFQqWBNxXAENdLvXr1mRfc9R+KoQ2IL t/pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=lYWCq7XV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n20-20020aa7d054000000b005233f9be637si2915764edo.554.2023.08.08.18.08.12; Tue, 08 Aug 2023 18:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=lYWCq7XV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232336AbjHHXOc (ORCPT + 99 others); Tue, 8 Aug 2023 19:14:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbjHHXOH (ORCPT ); Tue, 8 Aug 2023 19:14:07 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3614C2107 for ; Tue, 8 Aug 2023 16:13:49 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-57320c10635so74063387b3.3 for ; Tue, 08 Aug 2023 16:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691536428; x=1692141228; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ceh3/nJpRP3LCUTMqceYFYfxrY0H2MNGDIBSz6bT86E=; b=lYWCq7XVM6FudJxW5r6RH/4QIo159OCh6BgBZTBQDRkAKhfeKsfGNQQCUQnkN8KvPr t2l9cZJpTHvXHX31KaawaEBmdl57OidB6o+0jjp9TDmM0VLLVpgNjiCEG1/+aYqFU6hC eAp6ynp7sqYoyVQ64la2au+GLVmINvRuVrGSHYiSeGeSQjAXxRWyTBZdKnV0DHkwK074 YgL4nZU6PyCxpLCA6hze9IY8+wLAXkT7Chl05pETXiSkaPo3evGfyJZWaUFGflARAI1I CWJ4pe0DcCV/6ZrRmXGPD36mbRDc3h8lapnceaa/GYhujd1Sc5T65R444ON8TKY8zetm jTqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691536428; x=1692141228; 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=ceh3/nJpRP3LCUTMqceYFYfxrY0H2MNGDIBSz6bT86E=; b=M4x1Bv9pfKE2+n7U5LeTOzLXsBfQKMic8Foz6ti+GBLCp5NuWaKsHx/Pfx9+Of5kwm ESEy0a72soIdBPtKcxo6celCyvq+SJZYm0Vr/lZRc2P6QDkhM52ze+2+miyUiFdVESOh ZXIwisfqFm3+dMgtixKsC+PNdgik511tGtML25kfoBqHsZZWY9DjevLOM7cjDg+exKsS nfw+i78Z8aaPebxsDArIhmyw5SQBlOZLU6priR+GocEEru0qvBdVwohWoClr0aDiwQhN HcWDFr7hAxoFugdZGt9Yr5hu++QgVdUazOxiFkctSIIBVwHCfzsCI42qiQgypbCa4cGr gLyg== X-Gm-Message-State: AOJu0YxZzE8ng1mWAXUSD6cnbFwnM9oueeC09sHK0VqWf0Ml3yfUBT/G XkQ7j9q64SyGPyB4YGsg/Rlxz7RDMQu6 X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a25:ab50:0:b0:d10:5b67:843c with SMTP id u74-20020a25ab50000000b00d105b67843cmr20552ybi.4.1691536428387; Tue, 08 Aug 2023 16:13:48 -0700 (PDT) Date: Tue, 8 Aug 2023 23:13:29 +0000 In-Reply-To: <20230808231330.3855936-1-rananta@google.com> Mime-Version: 1.0 References: <20230808231330.3855936-1-rananta@google.com> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230808231330.3855936-14-rananta@google.com> Subject: [PATCH v8 13/14] KVM: arm64: Invalidate the table entries upon a range From: Raghavendra Rao Ananta To: Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose Cc: Paolo Bonzini , Sean Christopherson , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Reiji Watanabe , Colton Lewis , Raghavendra Rao Anata , David Matlack , Fuad Tabba , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Gavin Shan , Shaoqin Huang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, during the operations such as a hugepage collapse, KVM would flush the entire VM's context using 'vmalls12e1is' TLBI operation. Specifically, if the VM is faulting on many hugepages (say after dirty-logging), it creates a performance penalty for the guest whose pages have already been faulted earlier as they would have to refill their TLBs again. Instead, leverage kvm_tlb_flush_vmid_range() for table entries. If the system supports it, only the required range will be flushed. Else, it'll fallback to the previous mechanism. Signed-off-by: Raghavendra Rao Ananta Reviewed-by: Gavin Shan Reviewed-by: Shaoqin Huang --- arch/arm64/kvm/hyp/pgtable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 5d14d5d5819a1..5ef098af17362 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -806,7 +806,8 @@ static bool stage2_try_break_pte(const struct kvm_pgtable_visit_ctx *ctx, * evicted pte value (if any). */ if (kvm_pte_table(ctx->old, ctx->level)) - kvm_call_hyp(__kvm_tlb_flush_vmid, mmu); + kvm_tlb_flush_vmid_range(mmu, ctx->addr, + kvm_granule_size(ctx->level)); else if (kvm_pte_valid(ctx->old)) kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu, ctx->addr, ctx->level); -- 2.41.0.640.ga95def55d0-goog