Message ID | 20241010182427.1434605-66-seanjc@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 429FED24456 for <linux-arm-kernel@archiver.kernel.org>; Thu, 10 Oct 2024 21:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0kIT1cNFK/xt59MDB/Io88ATgyMybLemEwY+DfOgUM8=; b=1b4ZW8L7adH41/Gj+VMBO7RWPR S7ASJHfW760o6GsrH/bbseOOp0EgAXd9Bts651zLz+NPevjKTUNSdSz4MjFVJpPAeycpNzQCMcfdo yGApkXAwWvRqwPohzhNky/Q+PBbu2GwTKu5cWO7+oIqY/sxWw5nlmvY53HJB8AcW1XnGcXcqBEdoo dCLPH6rltRD+b4lLMVwO5ey1c2f0x/fyC7bQ7+GddHp/gGCdv5YIZxPqmVvyuCP8J8O2DCyZ01nmp t0fVTN+YB7dlykCucqOC6jce3lDHTFX3tXzgliBJcUQp/AhN20mf8qG4/tds0cccSmi8vLQpVCoPt wrMV8Itg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz0zW-0000000ESdC-05Ot; Thu, 10 Oct 2024 21:46:38 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxsU-0000000DrQL-3Loz for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:27:13 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-207510f3242so16008525ad.0 for <linux-arm-kernel@lists.infradead.org>; Thu, 10 Oct 2024 11:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728584829; x=1729189629; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=0kIT1cNFK/xt59MDB/Io88ATgyMybLemEwY+DfOgUM8=; b=ncGV/c+AluGiB5Wub5u8UvSkBS0krkBKkswJl6TMY+O1XuP40I467d8ozAcdtO7hSX bztAb+6FlXzcvwIsAQ6TTFHDKDi7VhRVvgGcklZgclHPJPmQIJUmDxuuKMxJyiWV4Us9 Ml94yw8Oe73armjC74hfiiSHJHgPJIO7CSlAJKylZc6klQTjK+b7jKsxlkI+sKtaU9qd cifr07vNF2dIWwlBAwdWJ4VSg4uRAO8nMuyrn3L4ExIpZkQBXLiKPMlqGK55FpGn/Tqj k6bkx9fc/VgXfATlBMbhoK+qvMiheT5pGQJ8Qkty2qp7noqUc5YtxHoCd3kwzYuiRXs3 y4BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728584829; x=1729189629; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0kIT1cNFK/xt59MDB/Io88ATgyMybLemEwY+DfOgUM8=; b=ZhZbXbQ+jHbfUKd0AU1nXQpvZcRb93fJZt8TevN9h43j+rG4igGIgxIDdap+IQssaw 2wyUg8SfyEbKyYs05/qhPxw+grR1oLjowgIBgadR3RDxCa27faw1xFZdfDBZF22O3130 sHgbwKYJM7HlUH9eTR2qqO0r7ZakB9G+Nf4ZY5U3ywVP/pnX4/uNNGSZO+0x81TJI7zi 6pj7H5I7G/vR/WYNLTh5ZMV+LwlS7M6CDr1TYYepbmhWGrUxoNFMIbfH8kbfIF6FeTY/ sr0nBHBW9pRc8FyxqEQNewu/OyC8CGKXlTTADKB/2xjD4ZDE5UofH+tnMHP1IlWffLa0 +0aA== X-Forwarded-Encrypted: i=1; AJvYcCWhEVfCktHyQJyeGUWy2oS1tIqGBMQzevrcwAr6XguqDIsuHsd1e0JzletfQrqOOA8k8uxgQvtpd+9hm5hevATt@lists.infradead.org X-Gm-Message-State: AOJu0Yy7j0omKGXONmHC4K3Ozjb5BzCNv4LQtgZn7Qh4SUcqjyUeMKY9 /JH9aA8oF0fLfJhWOqSmSfQaQ37qez2PT7KY7t3zfFKw6q2+EbqT7Wn2BSRZ1JFF1ZOvmTMCZ4b d9w== X-Google-Smtp-Source: AGHT+IEVjHGN/ZoxQo+Z413816spxD1Vig97FmVkGQ57WYZx6k/7CY2I8TFVs2SPVm+Oq4UkGx7TgXf3+Fw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a17:903:192:b0:20b:bd8d:427a with SMTP id d9443c01a7336-20c6377ab7bmr1062205ad.5.1728584829203; Thu, 10 Oct 2024 11:27:09 -0700 (PDT) Date: Thu, 10 Oct 2024 11:24:07 -0700 In-Reply-To: <20241010182427.1434605-1-seanjc@google.com> Mime-Version: 1.0 References: <20241010182427.1434605-1-seanjc@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241010182427.1434605-66-seanjc@google.com> Subject: [PATCH v13 65/85] KVM: LoongArch: Mark "struct page" pfns dirty only in "slow" page fault path From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, Tianrui Zhao <zhaotianrui@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Huacai Chen <chenhuacai@kernel.org>, Michael Ellerman <mpe@ellerman.id.au>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Sean Christopherson <seanjc@google.com> Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, " =?utf-8?q?Alex_Benn=C3=A9e?= " <alex.bennee@linaro.org>, Yan Zhao <yan.y.zhao@intel.com>, David Matlack <dmatlack@google.com>, David Stevens <stevensd@chromium.org>, Andrew Jones <ajones@ventanamicro.com> Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_112711_022484_1B4FFC21 X-CRM114-Status: GOOD ( 11.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Reply-To: Sean Christopherson <seanjc@google.com> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: Stop grabbing references to PFNMAP'd pages
|
expand
|
diff --git a/arch/loongarch/kvm/mmu.c b/arch/loongarch/kvm/mmu.c index 28681dfb4b85..cc2a5f289b14 100644 --- a/arch/loongarch/kvm/mmu.c +++ b/arch/loongarch/kvm/mmu.c @@ -608,13 +608,13 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ if (kvm_pte_young(changed)) kvm_set_pfn_accessed(pfn); - if (kvm_pte_dirty(changed)) { - mark_page_dirty(kvm, gfn); - kvm_set_pfn_dirty(pfn); - } if (page) put_page(page); } + + if (kvm_pte_dirty(changed)) + mark_page_dirty(kvm, gfn); + return ret; out: spin_unlock(&kvm->mmu_lock); @@ -915,12 +915,14 @@ static int kvm_map_page(struct kvm_vcpu *vcpu, unsigned long gpa, bool write) else ++kvm->stat.pages; kvm_set_pte(ptep, new_pte); - spin_unlock(&kvm->mmu_lock); - if (prot_bits & _PAGE_DIRTY) { - mark_page_dirty_in_slot(kvm, memslot, gfn); + if (writeable) kvm_set_pfn_dirty(pfn); - } + + spin_unlock(&kvm->mmu_lock); + + if (prot_bits & _PAGE_DIRTY) + mark_page_dirty_in_slot(kvm, memslot, gfn); kvm_release_pfn_clean(pfn); out: