Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp804795rdg; Thu, 10 Aug 2023 23:19:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpTkLf9UHpIcT/3OPR5N/8OlsW9Y470Mx+uAc+COspg9a67Pm9exL0z+xJkWDUeckOryiQ X-Received: by 2002:a17:90a:b898:b0:268:81c6:a01f with SMTP id o24-20020a17090ab89800b0026881c6a01fmr461662pjr.26.1691734788247; Thu, 10 Aug 2023 23:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691734788; cv=none; d=google.com; s=arc-20160816; b=xFihReW+nChPCakRn0shppxDllzUeLy4rtaS7an4gYEL926PhQM2fPTvd4gmSNPzxe c2uIw3thqmqFCoeAJLr/6xEEvFDYVBP8ksUnkxIv06yqAQrX991JcFa49PBXGETUlmH7 d7QBnNJNnmIpHqYa5qkLu3wsx7rdtB86YwMy9M5SfcWjCY9yPXuzwiriPqd6qbD0M/Q2 3bJlVFEd9hYdyGaKheigx8ZWpqFHBwbq00xKKJqyPdF0PjIOxR+mhvK1OIzCcUbnB9s2 3gYgUHLZsX4Nv8gTSbcgF7puGBNAUueoZJ0N8rO6OT0Yt+n2ZJe3m8lNy89VlCYyUyA8 7BEg== 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=usbWjVCS/TG9JcNKYmsTu8VDFOb8WjSWwzAOtvwSXGcC4E74RcGSKY5cev5kMaqnsO MjE7GiTxR8ntETzZf4Iy2HDKE+Dnz0GJLP67UtDUYYLcdpZUZ3ICZSL0NVimJSmTTlRr rUMZMFDW8HX70LgZoEqIHaUy7sIqSxtejJZwm6pnkub119TxaUsaSW3c4kZUfr426iFA zlhOES9LfETBCAFWjt9Dtb3qCqd4PweJisbYKZPor3NpmE7b2/+cWmFZXnwu2iBCIUFt Kjykaqj7AGEx0RfH//dC/BgmGUeQdpvqwGMHiqDtjnW52PNK7coZonHFTTqlxS/pv30K Z7dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=lHqWfp61; 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 me18-20020a17090b17d200b00267bb4cfaa7si5286834pjb.88.2023.08.10.23.19.36; Thu, 10 Aug 2023 23:19:48 -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=lHqWfp61; 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 S230324AbjHKEwn (ORCPT + 99 others); Fri, 11 Aug 2023 00:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjHKEwV (ORCPT ); Fri, 11 Aug 2023 00:52:21 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7A330DD for ; Thu, 10 Aug 2023 21:51:49 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d62a7776f69so1628238276.3 for ; Thu, 10 Aug 2023 21:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691729509; x=1692334309; 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=lHqWfp61VXzWhun3liSCo1CSCBHiEyU47FTCxsnQq8PbPrZVJoSsWVZ4fEX98C2DkW 5tek7XQP9mJy7NeheveiRehPOgCFv2062IYZFMuFBJd/9R8dr0dmve4e4xKZzUd6v89o VeSHW0hjn2DbsqdsgVscCVTcn0H4yM4N/0YEqjJ196nf8SdcTQtyOZZaVghqfh6h34Re E0oHw2Y6uHdjAkl15YMtMg9Z6P8rco3KWSpUtvl1TY8Fm49+r+1TuIERD17QjTEoKmLD O3fI87xp18xcDlB5HLBTUsrTm5rIbVZpwNSq52s4Abs8Cp3fKn2aFj26qWXruJf9eih2 dIFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691729509; x=1692334309; 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=fVus8S56IlUn0ZfivYB5zR5wNmuboqvW3Qfq8siTkGjVkMLqSwpAjgoGm3GDAwUhE2 WolIGGJonzEEAJVFY1y4ToARvqO+T+JhDx2JxnlUv/qvmib/CjGd7LR04zOpwanHoGQt LgxxcJ/K8fXrLTITH2m+Hu59kjmRzBZAZ6polvmcuizw8u7g3P2orkdj+Vb5ELxNxm1N vVuG9uUj087Qs2rDS6yOvO/LSaa008e+NrF97KNcKpp5uw3gc51s/mXLoXM4nKHFa1Au BiIG6BsKEarDbThz84AhwzKK++5uiIIa8xrboO3wDcV2l38xagPxqCnZRSu8nXzcdDDj uhog== X-Gm-Message-State: AOJu0YxRHkVboeamajmBQ/8xWDWRsMuyPd9idb4oGBmyBPcdcQATiJDJ rPGTT2ZzJPmWS7sZmF8grx2HEh+GM34A X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a25:d814:0:b0:d48:c04:f256 with SMTP id p20-20020a25d814000000b00d480c04f256mr8024ybg.11.1691729509090; Thu, 10 Aug 2023 21:51:49 -0700 (PDT) Date: Fri, 11 Aug 2023 04:51:26 +0000 In-Reply-To: <20230811045127.3308641-1-rananta@google.com> Mime-Version: 1.0 References: <20230811045127.3308641-1-rananta@google.com> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230811045127.3308641-14-rananta@google.com> Subject: [PATCH v9 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