All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liam Ni <zhiguangni01@gmail.com>
To: seanjc@google.com, pbonzini@redhat.com, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	hpa@zytor.com
Cc: x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, zhiguangni01@gmail.com
Subject: [PATCH] KVM:make cpuid_entry2_find more efficient
Date: Tue,  9 Aug 2022 13:51:38 +0800	[thread overview]
Message-ID: <20220809055138.101470-1-zhiguangni01@gmail.com> (raw)

Compared with the way of obtaining the pointer by
fetching the value of the array and then fetching the pointer,
the way of obtaining the pointer by the pointer offset is more efficient.

Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
---
 arch/x86/kvm/cpuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index de6d44e07e34..3bf82a891564 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -75,7 +75,7 @@ static inline struct kvm_cpuid_entry2 *cpuid_entry2_find(
 	int i;
 
 	for (i = 0; i < nent; i++) {
-		e = &entries[i];
+		e = entries + i;
 
 		if (e->function == function &&
 		    (!(e->flags & KVM_CPUID_FLAG_SIGNIFCANT_INDEX) || e->index == index))
-- 
2.25.1


             reply	other threads:[~2022-08-09  5:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09  5:51 Liam Ni [this message]
2022-08-09  7:54 ` [PATCH] KVM:make cpuid_entry2_find more efficient Borislav Petkov

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=20220809055138.101470-1-zhiguangni01@gmail.com \
    --to=zhiguangni01@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.