Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7564308rwd; Tue, 6 Jun 2023 12:41:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7txBnI4cv8qC8i07yDMOPWqtawmXkdc3GLH3LN0Csh1F7TlPmZASizHdqPkMz9+i3tdqZJ X-Received: by 2002:ac8:58c1:0:b0:3f6:a19b:fcb4 with SMTP id u1-20020ac858c1000000b003f6a19bfcb4mr763533qta.47.1686080495141; Tue, 06 Jun 2023 12:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686080495; cv=none; d=google.com; s=arc-20160816; b=SZySPwmBwyXbdwy1kbpUDaoJsi/Z8SEAfIIWoZ0HUKX1n+OJoyjV16/y60EJ+X7f8L esrykd1EQI9q3khLKAGTBlAAGdaltJD+nc1udRGd5bSvGQ4y2pHjnt82vVjlfq7GXcEX 7f2RHHztZmVXQguD+YESuxOhwdABu8I5oqF3/zHXOsgAarUZ+jcNCznMU/ERyOPH7LM9 vjdJsNRcFJzawgfd4gsTwd5wBVb/yloRN0AUIIuZedvZsKi8TIbh5+gE7Z4905ql3oZ5 jT0DVtbdeEPJm8ZvvPsAuam21ASqoKAMMGfrXfKwmhO1B8mR/H/csQtmRsfLQGPy/WVa ipPg== 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=mSh72g4ZHJDv4/8vl2ojF6XiepiDvTufhm8MWFlXvRw=; b=QJc6s+y/1Opo3Z41tcoKMgzZCQSUftaGxly8gNnN8jA9oz1yRhVGue6Z9FfOHgKUJH l0aSu6ZtkA/mljUDUR3fTryicxdR+FXQ//NzwXJR6HFq1J/5TNacB78VnvyKFPhRrqg+ j7Zxg+s8WuZnq32YnfZC2FirqT48kE9M/ei9J9p/g2c2et1yatzJc8XgZ5ArLctqf27/ gGGQHDln00GPugRTzhuVJnhF8pqf7SSSS8wsHdLe1RA0MKSNFTvRaLBOeQPnWx0sTVkn g/R/0kXOa7nzjD/ncqtXepyT+gaTsIZCHhUvP73NN6OCFw+9ftPgmem97ROmqZM4phWG Lr2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DgqodgA0; 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 fw3-20020a17090b128300b002568322e3d0si7807055pjb.34.2023.06.06.12.41.22; Tue, 06 Jun 2023 12:41:35 -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=DgqodgA0; 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 S239381AbjFFT3j (ORCPT + 99 others); Tue, 6 Jun 2023 15:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239301AbjFFT3P (ORCPT ); Tue, 6 Jun 2023 15:29:15 -0400 Received: from mail-io1-xd49.google.com (mail-io1-xd49.google.com [IPv6:2607:f8b0:4864:20::d49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2279E1725 for ; Tue, 6 Jun 2023 12:29:09 -0700 (PDT) Received: by mail-io1-xd49.google.com with SMTP id ca18e2360f4ac-7776dd75224so447284739f.2 for ; Tue, 06 Jun 2023 12:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686079748; x=1688671748; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mSh72g4ZHJDv4/8vl2ojF6XiepiDvTufhm8MWFlXvRw=; b=DgqodgA0VlUZWQrMG4GP7C/weUqyJOTcJeeBU+QJtyx73nrL97iFH09J3NN1a3ZqZp HnGGp8mag6nk53M7ixB65x5AD6Ms56KjI1ef3YbrAECkzd/sBiP49ZaRawRDGSG6W/48 zpTIZ9xiNUakwan9Sah7O3FQZq8hbYO+vJYMpPhkX+vPtaFLwYWWIJatBbkiuWPko3KK xLOP8K2IyKlFQWL5H/yaFnL404Xk/QQOl56Czr3QPqSe5ks+kz2URjUEHgddpbJaiPlb GYXlIgD7DvVtN5XvZx5Rt/1wo3vRwOLcLfUaazlKhmWPNVBuGWB5FFLS01Y/RwmF7Ac/ NxtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686079748; x=1688671748; 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=mSh72g4ZHJDv4/8vl2ojF6XiepiDvTufhm8MWFlXvRw=; b=HafdSrKXtQSLI1zfx747b+4e9zTR1ydSlI4OLnKB37zNvQdDR65DSGaQJ6o73Cp66g K6vRPFBfPv0vejRaDy8memIosDKGvTQSZtVo6hLkxh4wM/L9RHx1MM5zKwYS6kpbQYNM A1O4I6Xu8im2z8C4KoS495nRuIh4dGytEOykSezfP0L4TOe6ssjgwHBBzlMYAM5T+p4w 2vANEdtTVVNWqIJIjzPYcwKkOzgG27GiXlaqwONQDxYbMV8BuciBs1y+s+ggrPKINuoF F3QZq0PyCcVoJj+/5vBbF0YsBu3UWcVpYGiKezM6e4PPLhlV+SkpjC2xDvDTR+20730N hbhw== X-Gm-Message-State: AC+VfDwbu37/NembPd6uORV7LmH12m+3H40ZU+ZwY/oId50zDOkbmCfO tqmpb88wllIvLvmp77eNl6qfpBe6JKQb X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a02:85e6:0:b0:416:7e77:bb5f with SMTP id d93-20020a0285e6000000b004167e77bb5fmr1392579jai.0.1686079748520; Tue, 06 Jun 2023 12:29:08 -0700 (PDT) Date: Tue, 6 Jun 2023 19:28:57 +0000 In-Reply-To: <20230606192858.3600174-1-rananta@google.com> Mime-Version: 1.0 References: <20230606192858.3600174-1-rananta@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230606192858.3600174-7-rananta@google.com> Subject: [PATCH v5 6/7] 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 , Jing Zhang , Colton Lewis , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 --- 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 df8ac14d9d3d4..50ef7623c54db 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -766,7 +766,8 @@ static bool stage2_try_break_pte(const struct kvm_pgtable_visit_ctx *ctx, * 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.rc0.172.g3f132b7071-goog