From: maobibo <maobibo@loongson.cn>
To: tangbin <tangbin@cmss.chinamobile.com>,
zhaotianrui@loongson.cn, chenhuacai@kernel.org,
kernel@xen0n.name
Cc: kvm@vger.kernel.org, loongarch@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] LoongArch: KVM: Remove redundant assignment in kvm_map_page_fast
Date: Fri, 26 Jul 2024 10:13:19 +0800 [thread overview]
Message-ID: <286be0a6-dac3-b2cd-e88a-e6feb5a240de@loongson.cn> (raw)
In-Reply-To: <20240713155937.45261-1-tangbin@cmss.chinamobile.com>
Hi Tangbin,
There is only return value with -EFAULT or 0 in function
kvm_map_page_fast(), if there is better error code or different error
for new code, the situation will be different :)
I would like to keep existing code unchanged, however thanks for your patch.
Regards
Bibo Mao
On 2024/7/13 下午11:59, tangbin wrote:
> In the function kvm_map_page_fast, the assignment of 'ret' is
> redundant, so remove it.
>
> Signed-off-by: tangbin <tangbin@cmss.chinamobile.com>
> ---
> arch/loongarch/kvm/mmu.c | 17 +++++------------
> 1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/arch/loongarch/kvm/mmu.c b/arch/loongarch/kvm/mmu.c
> index 2634a9e8d..d6c922a4a 100644
> --- a/arch/loongarch/kvm/mmu.c
> +++ b/arch/loongarch/kvm/mmu.c
> @@ -551,7 +551,6 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> */
> static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool write)
> {
> - int ret = 0;
> kvm_pfn_t pfn = 0;
> kvm_pte_t *ptep, changed, new;
> gfn_t gfn = gpa >> PAGE_SHIFT;
> @@ -563,20 +562,16 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
>
> /* Fast path - just check GPA page table for an existing entry */
> ptep = kvm_populate_gpa(kvm, NULL, gpa, 0);
> - if (!ptep || !kvm_pte_present(NULL, ptep)) {
> - ret = -EFAULT;
> + if (!ptep || !kvm_pte_present(NULL, ptep))
> goto out;
> - }
>
> /* Track access to pages marked old */
> new = kvm_pte_mkyoung(*ptep);
> /* call kvm_set_pfn_accessed() after unlock */
>
> if (write && !kvm_pte_dirty(new)) {
> - if (!kvm_pte_write(new)) {
> - ret = -EFAULT;
> + if (!kvm_pte_write(new))
> goto out;
> - }
>
> if (kvm_pte_huge(new)) {
> /*
> @@ -584,10 +579,8 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
> * enabled for HugePages
> */
> slot = gfn_to_memslot(kvm, gfn);
> - if (kvm_slot_dirty_track_enabled(slot)) {
> - ret = -EFAULT;
> + if (kvm_slot_dirty_track_enabled(slot))
> goto out;
> - }
> }
>
> /* Track dirtying of writeable pages */
> @@ -615,10 +608,10 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
> if (page)
> put_page(page);
> }
> - return ret;
> + return 0;
> out:
> spin_unlock(&kvm->mmu_lock);
> - return ret;
> + return -EFAULT;
> }
>
> static bool fault_supports_huge_mapping(struct kvm_memory_slot *memslot,
>
prev parent reply other threads:[~2024-07-26 2:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-13 15:59 tangbin
2024-07-26 2:13 ` maobibo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=286be0a6-dac3-b2cd-e88a-e6feb5a240de@loongson.cn \
--to=maobibo@loongson.cn \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=tangbin@cmss.chinamobile.com \
--cc=zhaotianrui@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®