Message ID | 20240726235234.228822-70-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 BB5E0C3DA4A for <linux-arm-kernel@archiver.kernel.org>; Sat, 27 Jul 2024 00:29:17 +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=xPTfQtMbnGzpFXQRYDpT9MKKQAxP5DVy80mpAp/3DnI=; b=yDCQC6UhrMyjMFI1jj94ZHvsi5 52JCOuVuV/6BX6ItYJYwolb8sZlLQN2N7n3SHpjB4mIwDhSGl0b5IeuWvbnAF95qZGZGLLJM+GpJc xQ0/raXQ0wRI/aE/wrD0Ev6ZagGjw4mwniwznzJpfBRaZTuiEqjdVzavBKzvTLHQw+wbC9lhyM3Fp qKmXuJ2wgpZNQsaXLVp5819jNyQh5+nFogIYx+u7fzyQwq1kT+80rcDvNeKuEap8s82fDNlxG5M7p ApVcd/PFHQFsu9/PI1Uy+IUoq1vqHWbi6pKqFqrtILpDSOzT4nkjj9c6Ckgorx6tlWKz7HaNRNv6O oAtJCJpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXVJ4-00000005iGX-1dds; Sat, 27 Jul 2024 00:29:06 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUm7-00000005R5Z-0Z0u for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 23:55:08 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e035f7b5976so760599276.0 for <linux-arm-kernel@lists.infradead.org>; Fri, 26 Jul 2024 16:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722038102; x=1722642902; 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=xPTfQtMbnGzpFXQRYDpT9MKKQAxP5DVy80mpAp/3DnI=; b=c2EmoLdn6qWUnwkOI6Es5Bckdmi+xotmqTg2HTzLZNNNX8PcxIrfx3F3x3Gg2ZMiMg mhj5TJzavZrgCw7PYLzcxEl83nISxS5/HJfs9HRJck6YuxX2YgvNczqNrU1gLvQbGEHh HQHxrzXAfGeo84l/fs0VIAl4E+qbKlrHHj3s6vnooQ+9m/TKG7aieSPgRSsP5m4ZLdtI fD04ZHLyN8HK8R3tu9EYmBj+mIgxQ5dmpnQ+jAALXe96+m9nNUfD1+zgyx91K5BQd0pU z2ZrtNQP7fxu8DWnlG4RvMXgBtgMN0xzUn9bkjJW9/079rCv1BT4EP5tZArWL+Mbwhf+ GcLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722038102; x=1722642902; 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=xPTfQtMbnGzpFXQRYDpT9MKKQAxP5DVy80mpAp/3DnI=; b=thWELODmYdg1xcECphe2YcWZpsJOqP4gF1moP0lHEXjcfbg0xNee3kqsPUM5Nh7Row Qi6GIt/gZCsezqriJK7ETrp6VVYK3l8r9JyLoxpCZy/su8eAGphzBZgsaRqqjFkKe23z 8rm5e7T8P5OCPnFLA/uhadYM7MkINOfSI+muXXrr2AxGkAl7zA5E/fjvDMPkxzLz1U5S a8XWWjOtnZZTjNX05jfJdeJVA3etpNuPQSU2ULMSe/VUPhv6LMf3N2PVauhhanF3YsT9 VggE8vQrXqy/OLnQwtfynnOR8zswQQOPBxj3UA/ZdFXx4JEC+l9CgPCmLplVJ39AxVTI GRZg== X-Forwarded-Encrypted: i=1; AJvYcCVljHg1xXwpei60feXdqubW9zIttlZksrTCk5Sn+no0GUbQfFh89kznJomEM9PiUzgTWVUNxuvpGNVUf+lejd+fch+CxhJnSe7c/lRoIyjG8/v0XlU= X-Gm-Message-State: AOJu0Yydh3IjD0OxWenjJYUmcXjtJbSw5r6+dzcyGrUSQ0Tr4/azDg79 chcvtKXgckJtuhKEI9w5cOWdWo/3hxOToauWbLkpRxbALKhIGDDJlz1mAqpDYGwLhCuTIDqcFR6 YTw== X-Google-Smtp-Source: AGHT+IEEWasWSJ9byHCocPT0rn5wdP9A8yl8cF0t65kc5fqEIfuaFnuVC5T09t/hlGHF+EVf0JUp5RZPIP4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:c0a:b0:e05:a890:5aaa with SMTP id 3f1490d57ef6-e0b555474d7mr20378276.1.1722038101719; Fri, 26 Jul 2024 16:55:01 -0700 (PDT) Date: Fri, 26 Jul 2024 16:52:18 -0700 In-Reply-To: <20240726235234.228822-1-seanjc@google.com> Mime-Version: 1.0 References: <20240726235234.228822-1-seanjc@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240726235234.228822-70-seanjc@google.com> Subject: [PATCH v12 69/84] KVM: MIPS: Mark "struct page" pfns accessed 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, David Matlack <dmatlack@google.com>, David Stevens <stevensd@chromium.org> Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_165503_637203_C8F948D8 X-CRM114-Status: GOOD ( 13.73 ) 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/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c index 4da9ce4eb54d..f1e4b618ec6d 100644 --- a/arch/mips/kvm/mmu.c +++ b/arch/mips/kvm/mmu.c @@ -484,8 +484,6 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, struct kvm *kvm = vcpu->kvm; gfn_t gfn = gpa >> PAGE_SHIFT; pte_t *ptep; - kvm_pfn_t pfn = 0; /* silence bogus GCC warning */ - bool pfn_valid = false; int ret = 0; spin_lock(&kvm->mmu_lock); @@ -498,12 +496,9 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, } /* Track access to pages marked old */ - if (!pte_young(*ptep)) { + if (!pte_young(*ptep)) set_pte(ptep, pte_mkyoung(*ptep)); - pfn = pte_pfn(*ptep); - pfn_valid = true; - /* call kvm_set_pfn_accessed() after unlock */ - } + if (write_fault && !pte_dirty(*ptep)) { if (!pte_write(*ptep)) { ret = -EFAULT; @@ -512,7 +507,6 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, /* Track dirtying of writeable pages */ set_pte(ptep, pte_mkdirty(*ptep)); - pfn = pte_pfn(*ptep); mark_page_dirty(kvm, gfn); } @@ -523,8 +517,6 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, out: spin_unlock(&kvm->mmu_lock); - if (pfn_valid) - kvm_set_pfn_accessed(pfn); return ret; }
Mark pages accessed only in the slow page fault path in order to remove an unnecessary user of kvm_pfn_to_refcounted_page(). Marking pages accessed in the primary MMU during KVM page fault handling isn't harmful, but it's largely pointless and likely a waste of a cycles since the primary MMU will call into KVM via mmu_notifiers when aging pages. I.e. KVM participates in a "pull" model, so there's no need to also "push" updates. Signed-off-by: Sean Christopherson <seanjc@google.com> --- arch/mips/kvm/mmu.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)