public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: kvm@vger.kernel.org, Avi Kivity <avi@redhat.com>
Subject: Re: [PATCH] IO: Intelligent device lookup on bus
Date: Wed, 20 Jul 2011 16:41:49 -0300	[thread overview]
Message-ID: <20110720194149.GA21379@amt.cnet> (raw)
In-Reply-To: <1311163918-14334-1-git-send-email-levinsasha928@gmail.com>

On Wed, Jul 20, 2011 at 03:11:58PM +0300, Sasha Levin wrote:
> Currently the method of dealing with an IO operation on a bus (PIO/MMIO)
> is to call the read or write callback for each device registered
> on the bus until we find a device which handles it.
> 
> Since the number of devices on a bus can be significant due to ioeventfds
> and coalesced MMIO zones, this leads to a lot of overhead on each IO
> operation.
> 
> Instead of registering devices, we now register ranges which points to
> a device. Lookup is done using an efficient bsearch instead of a linear
> search.
> 
> This should speed up all IO operations generated by the guest.

Some numbers, please.

> +int kvm_io_bus_find_closest_dev_idx(struct kvm_io_bus *bus,
> +					gpa_t addr, int len)
> +{
> +	int start = 0, end = bus->dev_count - 1;
> +
> +	if (bus->dev_count == 0)
> +		return -1;
> +
> +	while (start <= end) {
> +		int mid = (start + end) / 2;
> +		struct kvm_io_range *range = &bus->range[mid];
> +
> +		if (addr > range->addr)
> +			start = mid + 1;
> +		else if (addr < range->addr)
> +			end = mid - 1;

If mid is zero, this assigns end = -1?


  parent reply	other threads:[~2011-07-20 19:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 12:11 [PATCH] IO: Intelligent device lookup on bus Sasha Levin
2011-07-20 12:43 ` Jan Kiszka
2011-07-21  8:43   ` Sasha Levin
2011-07-21  9:49     ` Avi Kivity
2011-07-20 19:41 ` Marcelo Tosatti [this message]
2011-07-20 21:22   ` Sasha Levin
2011-07-21 10:05     ` Avi Kivity

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=20110720194149.GA21379@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox