All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Subject: [PATCH 4/4] KVM: Reduce atomic operations on vcpu->requests
Date: Sun, 20 Jun 2010 19:21:58 +0300	[thread overview]
Message-ID: <1277050918-12744-5-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1277050918-12744-1-git-send-email-avi@redhat.com>

Usually the vcpu->requests bitmap is sparse, so a test_and_clear_bit() for
each request generates a large number of unneeded atomics if a bit is set.

Replace with a separate test/clear sequence.  This is safe since there is
no clear_bit() outside the vcpu thread.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 include/linux/kvm_host.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index e706c1e..e478f3f 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -642,7 +642,12 @@ static inline bool kvm_make_check_request(int req, struct kvm_vcpu *vcpu)
 
 static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu)
 {
-	return test_and_clear_bit(req, &vcpu->requests);
+	if (test_bit(req, &vcpu->requests)) {
+		clear_bit(req, &vcpu->requests);
+		return true;
+	} else {
+		return false;
+	}
 }
 
 #endif
-- 
1.7.1


  parent reply	other threads:[~2010-06-20 16:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-20 16:21 [PATCH 0/4] Preparation for PIC-APIC rewiring Avi Kivity
2010-06-20 16:21 ` [PATCH 1/4] KVM: i8259: reduce excessive abstraction for pic_irq_request() Avi Kivity
2010-06-20 16:21 ` [PATCH 2/4] KVM: i8259: simplify pic_irq_request() calling sequence Avi Kivity
2010-06-20 16:21 ` [PATCH 3/4] KVM: Add mini-API for vcpu->requests Avi Kivity
2010-06-20 16:21 ` Avi Kivity [this message]
2010-06-21 20:05 ` [PATCH 0/4] Preparation for PIC-APIC rewiring Marcelo Tosatti
2010-06-22  5:51   ` Gleb Natapov

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=1277050918-12744-5-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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.