From patchwork Thu Jul 18 22:35:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colton Lewis X-Patchwork-Id: 13736771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 744BFC3DA49 for ; Thu, 18 Jul 2024 22:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:Mime-Version:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=t17NNug3pGXskbylK7023fOephyseDv5XvuuntGRCyI=; b=BTDajR95HKfcTvsqLfgCxDFvVa NMz3mnpdYidd5bN4iYSKgsEX55whmAgs4hjnbmjM8bXfgUvx1D99snxlyTDU8GemoIi1KALJh5fUw /r+yX4VktCIN5i2L1u11USzq/iCTpmMboj7b74eLjH5zarO7aK/OveKUWdNqq2I/EVzL8DC5L/oax IHS5el7CuGkCYxJ7vKcpAlixhKJxLHIrr/DqRgsYZDPoLOGG/TgqKvXnRB0HqeyJ62isxIbzibaly RzauFikrpxsrRu7dfLk+Kn0iUfoGFqMwY5/1Mmn0N6XUvAObNOXzN6YlWkNyDrZs1OqXUrMR2OIU+ X7DahaUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUZj4-00000000sSH-1VEY; Thu, 18 Jul 2024 22:35:50 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUZig-00000000sK8-0ZHI for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 22:35:29 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-65ef46e8451so36833057b3.0 for ; Thu, 18 Jul 2024 15:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721342124; x=1721946924; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=t17NNug3pGXskbylK7023fOephyseDv5XvuuntGRCyI=; b=dgpPgQmHsxxyoy3wZ5kZ1TMeqB8TkkTO3LhuueuVfoIgmb3gpzz6jwG9f2RdbYNBWU UvkTCNfL5PedV3yjeqQYCVRCoaLM9+suMCknoL2OQ56XBx8HYmQE7ScxWW1bSZF4p6k3 ctUMNtJlXzvlh9ZERyiW2FOla8Nydseu3n54FevkeFZnAMirO0aHJqLmUxqHvPlH1KY7 t39b1XYOU46rKUFuwJp5mLESlbFvFJdDHgqI/aLWzzKNUvJOiNNXMKpnOt+0d6EfEw6r YZSQ7WJiBuMd+Uyuqw6QTX4Axbo8pjxJmpCSoFBc7kLrlUpXnja2YojaW6qUJuiGLk2a mk7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721342124; x=1721946924; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=t17NNug3pGXskbylK7023fOephyseDv5XvuuntGRCyI=; b=GljCzkXvxZDNcHxleWrvBpwST+XU1gn2X52s0ceGcPEYc5KH7S3Drs/I84fgh1pT+H 0WIr2+4wOHUo7y98eZ/Y5ULL5lB138aTDL2paF8vhqUTIoPGY9af311Mu1XvyyO/FIwL sPVRhtlvk14Zrf+M1Tv6+UsVTxzwlPmdKRja6SMvhMXYq3gWnVqU3mVjwLPzVMkLwpxk fLo7HqFMc0AfOK7VR/L8WAHMVzMmYYObuMrAthMq+rTpz5GOSMlDwMi4Qwm8T5+nZ2PG rVtnJRfUN4DI7RLwY1/qvsuyZIdIXmPW4PX07ilmlW5Y7BG3vTncwB7T+eiNEYObVYDs g34w== X-Forwarded-Encrypted: i=1; AJvYcCUDDX4JDNeVEXNsmFik4+eqLfamAxggAaxf9iyTf7551tRdNwTE2E7MkvDKSJ0ihy1P4sbYvicD+reStGMF6yO0tz2G+G6Ux+rdTDHcGUZT8jzjFUc= X-Gm-Message-State: AOJu0YxWDZnwAYPamdIkkaQweHFOpp6SGNKQccJsEIT6p0/DbWz0LnDn ioRN6sVYPwK90EPvVIjGGLif/TU3OXUkjj0QSJ0YmEzf5WLtCdXk68nzdo+euCK4ZxKghoACLBD 5m8cJNcbYYeweLZ3pZt8luQ== X-Google-Smtp-Source: AGHT+IFAzxmz+xd5k+TsYOLSlTiwpUEcd3PMTkPrko0oISXqajR79Y7rD10ay46njNzlCvfw2OfNGwggk1RAW9y4Sw== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:14ce]) (user=coltonlewis job=sendgmr) by 2002:a05:690c:f94:b0:627:a961:caee with SMTP id 00721157ae682-66603127fa6mr1628197b3.4.1721342124251; Thu, 18 Jul 2024 15:35:24 -0700 (PDT) Date: Thu, 18 Jul 2024 22:35:19 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Message-ID: <20240718223519.1673835-1-coltonlewis@google.com> Subject: [PATCH] KVM: arm64: Move data barrier to end of split walk From: Colton Lewis To: kvm@vger.kernel.org Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Colton Lewis X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240718_153526_238884_3663F7CD X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Moving the data barrier from stage2_split_walker to after the walk is finished in kvm_pgtable_stage2_split results in a roughly 70% reduction in Clear Dirty Log Time in dirty_log_perf_test (modified to use eager page splitting) when using huge pages. This gain holds steady through a range of vcpus used (tested 1-64) and memory used (tested 1-64GB). This is safe to do because nothing else is using the page tables while they are still being mapped and this is how other page table walkers already function. None of them have a data barrier in the walker itself. Signed-off-by: Colton Lewis --- arch/arm64/kvm/hyp/pgtable.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 9e2bbee77491..9788af2ca8c0 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -1547,7 +1547,6 @@ static int stage2_split_walker(const struct kvm_pgtable_visit_ctx *ctx, */ new = kvm_init_table_pte(childp, mm_ops); stage2_make_pte(ctx, new); - dsb(ishst); return 0; } @@ -1559,8 +1558,11 @@ int kvm_pgtable_stage2_split(struct kvm_pgtable *pgt, u64 addr, u64 size, .flags = KVM_PGTABLE_WALK_LEAF, .arg = mc, }; + int ret; - return kvm_pgtable_walk(pgt, addr, size, &walker); + ret = kvm_pgtable_walk(pgt, addr, size, &walker); + dsb(ishst); + return ret; } int __kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm_s2_mmu *mmu,