From patchwork Thu Jun 8 22:05:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Tse Shao X-Patchwork-Id: 13272952 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 5A3D4C7EE29 for ; Thu, 8 Jun 2023 22:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8QkU3P3KIZnF84bVZfN4bBteYxtAs8tm9DS5X9fciuk=; b=XmTexv71tFQlTimoJ4OOcRfx7x /zgoyk7WsJt2BB9KqXg5rlfUwyOkJRCIS7zmWHRp4i36aOhoprefx6ixVPH9unmBDH3a24UgenKNm cCRA0B6HPwl1y4k6A143YXorwQkcPlpHaiQsmWT/FvSiMyarQYcl4cXELmefKOfsxE83p5DXdVLMy ZdbHHUoJP/LkJSoRXRimILD1wOBrkeaRIKXyhD/s5IbTjNSr6nVRgAkGpdItyIVH4mePLjEfcZmbw RqsEF2drUCyrihif+S3NkKQPLJJVFDFrePUfCIoJgX6ZcWZs5GkTHe0Xw3irYbZH+03yUFK3jBwD2 FQprg88w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7NmF-00AkyM-2u; Thu, 08 Jun 2023 22:06:43 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7NmC-00Akwe-1P for linux-arm-kernel@lists.infradead.org; Thu, 08 Jun 2023 22:06:41 +0000 Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-2566b668cc5so90243a91.0 for ; Thu, 08 Jun 2023 15:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686261998; x=1688853998; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RLQAgYf8iBGNcj/RlWRJvdUP+LxzH+dVMP3y494+MG8=; b=72g9XyvqNGl3FxCZJSPlIuUxU5j0nK1HOJfxv5zdttIag4OsGbA87NgmE6evU200aS 4DeqlItOIFsRMQ0edVVbXcJf6DzFv2YfutUisx2LuTPTVA7nkNWNd5uyttawNDTMrcGh wy65xqip1IhcVJ1CnkO3owJTaAfIhnrbD/WmfkrkSvNHld5eVlw3JgQjF0dtForqQaft bf5ROB4NASeWT8BrFaGbfxa5tS47+fie27CsKyFSPuMmPmwHfqEU/oAUA0hQT83Mec+T ojDgJK5GXHFV3Wjt7xLmT9aSemT69PEeoJdWthHnRlCut4YNMpKcxaM3Zu2FsJzZT0ix A6Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686261998; x=1688853998; 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=RLQAgYf8iBGNcj/RlWRJvdUP+LxzH+dVMP3y494+MG8=; b=PId7TSY0Nbo6uu61Ln1XpxsN712dfx5rf0rWM8kXbSABoj0TyLNLZy3zdOZC4wpE4Q yDPL1IIQCvVJcbqApLXWBzZjhKwePANqm7I4EC+Ezfw7nyQxn2PO5whSd5SoQMPBSVeX JPufcPNHQJYQN2/TQmiI6sf1hsymZohf0nSKXRpp8y+EIgav3pIyLlEGBA0jIOkI8yaR aBjY5ajKgZkxzKikD6jIc+Bvg282ZXEMDxpnfWzdVJSpVCeuYnUJYbTu1DwuT0cTLV1o N+6++rpHyl6KQjRcMnezbiPws1FAih4OnIc6gO3kOyVGIpSj02zaHkZ4M5DzURA+EeSQ 6KeA== X-Gm-Message-State: AC+VfDyhcLrLxjAMXKsKcUiw0hBVlC3HkXa4TaoToqqYQhNdewgTYWdi V0VHOvnlqqHe3WgWeZrhXKUhJKxygjU= X-Google-Smtp-Source: ACHHUZ4BB7wc/3PLgyJlfh6FiXwuAOEqUsspFVK4qOkYedUMSsY2SeUi7aLElhIVZxfm8OeC1VsqR/loduM= X-Received: from colette.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:5cff]) (user=ctshao job=sendgmr) by 2002:a17:90a:7886:b0:253:4800:438b with SMTP id x6-20020a17090a788600b002534800438bmr786194pjk.2.1686261997920; Thu, 08 Jun 2023 15:06:37 -0700 (PDT) Date: Thu, 8 Jun 2023 15:05:41 -0700 In-Reply-To: <20230608220558.39094-1-ctshao@google.com> Mime-Version: 1.0 References: <20230608220558.39094-1-ctshao@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230608220558.39094-4-ctshao@google.com> Subject: [PATCH v1 3/3] KVM: arm64: Using rcu_read_lock() for kvm_pgtable_stage2_mkyoung() From: Chun-Tse Shao To: linux-kernel@vger.kernel.org, yuzhao@google.com, oliver.upton@linux.dev Cc: Chun-Tse Shao , Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Ben Gardon , Gavin Shan , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230608_150640_495749_9485A891 X-CRM114-Status: GOOD ( 10.93 ) 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 Access bit is RCU safe and can be set without taking kvm->mmu_lock(). Replacing existing kvm->mmu_lock() with rcu_read_lock() for better performance. Original disussion can be found in: https://lore.kernel.org/kvmarm/CAOUHufZrfnfcbrqSzmHkejR5MA2gmGKZ3LMRhbLHV+1427z=Tw@mail.gmail.com/ Suggested-by: Yu Zhao Signed-off-by: Chun-Tse Shao --- arch/arm64/kvm/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 3b9d4d24c361..0f7ea66fb894 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1437,10 +1437,10 @@ static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) trace_kvm_access_fault(fault_ipa); - read_lock(&vcpu->kvm->mmu_lock); + rcu_read_lock(); mmu = vcpu->arch.hw_mmu; pte = kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa); - read_unlock(&vcpu->kvm->mmu_lock); + rcu_read_unlock(); if (kvm_pte_valid(pte)) kvm_set_pfn_accessed(kvm_pte_to_pfn(pte));