From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH for-2.5 3/4] vhost: switch region lookup from linear to bsearch
Date: Tue, 28 Jul 2015 16:52:52 +0200 [thread overview]
Message-ID: <1438095173-7417-4-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1438095173-7417-1-git-send-email-imammedo@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
hw/virtio/vhost.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 8bef43e..5b8598b 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -420,13 +420,11 @@ static struct vhost_memory_region *vhost_dev_find_reg(struct vhost_dev *dev,
uint64_t start_addr,
uint64_t size)
{
- int i, n = dev->mem->nregions;
- for (i = 0; i < n; ++i) {
- struct vhost_memory_region *reg = dev->mem->regions + i;
- if (ranges_overlap(reg->guest_phys_addr, reg->memory_size,
- start_addr, size)) {
- return reg;
- }
+ int i = memory_range_bsearch(dev, start_addr), n = dev->mem->nregions;
+ struct vhost_memory_region *reg = dev->mem->regions + i;
+ if (i < n && ranges_overlap(reg->guest_phys_addr, reg->memory_size,
+ start_addr, size)) {
+ return reg;
}
return NULL;
}
--
1.8.3.1
next prev parent reply other threads:[~2015-07-28 14:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 14:52 [Qemu-devel] [PATCH for-2.5 0/4] vhost: cleanups and switching to sorted memory map Igor Mammedov
2015-07-28 14:52 ` [Qemu-devel] [PATCH for-2.5 1/4] vhost: codding style fix tab indents Igor Mammedov
2015-07-28 16:12 ` Peter Maydell
2015-07-28 14:52 ` [Qemu-devel] [PATCH for-2.5 2/4] vhost: simplify/speedify vhost_dev_assign_memory() Igor Mammedov
2015-07-28 14:52 ` Igor Mammedov [this message]
2015-07-28 14:52 ` [Qemu-devel] [PATCH for-2.5 4/4] vhost: simplify/speedify vhost_dev_unassign_memory() Igor Mammedov
2015-08-12 7:33 ` [Qemu-devel] [PATCH for-2.5 0/4] vhost: cleanups and switching to sorted memory map Michael S. Tsirkin
2015-08-31 12:35 ` Igor Mammedov
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=1438095173-7417-4-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).