All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: shankerd@codeaurora.org,
	xen-devel <xen-devel@lists.xensource.com>,
	Stefano Stabellini <sstabellini@kernel.org>
Cc: Philip Elcan <pelcan@codeaurora.org>,
	Vikram Sethi <vikrams@codeaurora.org>
Subject: Re: [PATCH V3 09/10] xen/arm: io: Use binary search for mmio handler lookup
Date: Tue, 28 Jun 2016 14:29:34 +0100	[thread overview]
Message-ID: <57727BBE.5090906@arm.com> (raw)
In-Reply-To: <5772797C.7040806@codeaurora.org>



On 28/06/16 14:19, Shanker Donthineni wrote:
> On 06/28/2016 05:49 AM, Julien Grall wrote:
>> On 27/06/16 21:33, Shanker Donthineni wrote:
>>> As the number of I/O handlers increase, the overhead associated with
>>> linear lookup also increases. The system might have maximum of 144
>>> (assuming CONFIG_NR_CPUS=128) mmio handlers. In worst case scenario,
>>> it would require 144 iterations for finding a matching handler. Now
>>> it is time for us to change from linear (complexity O(n)) to a binary
>>> search (complexity O(log n) for reducing mmio handler lookup overhead.
>>>
>>> Signed-off-by: Shanker Donthineni <shankerd@codeaurora.org>
>>> ---
>>> Changes since v2:
>>>    Converted mmio lookup code to a critical section.
>>>    Copied the function bsreach() from Linux kernel.
>>>
>>>   xen/arch/arm/io.c | 97
>> +++++++++++++++++++++++++++++++++++++++++++++++--------
>>>   1 file changed, 84 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
>>> index a5b2c2d..c31fdf3 100644
>>> --- a/xen/arch/arm/io.c
>>> +++ b/xen/arch/arm/io.c
>>> @@ -20,9 +20,50 @@
>>>   #include <xen/lib.h>
>>>   #include <xen/spinlock.h>
>>>   #include <xen/sched.h>
>>> +#include <xen/sort.h>
>>>   #include <asm/current.h>
>>>   #include <asm/mmio.h>
>>>
>>> +/*
>>> + * bsearch - binary search an array of elements
>>> + * @key: pointer to item being searched for
>>> + * @base: pointer to first element to search
>>> + * @num: number of elements
>>> + * @size: size of each element
>>> + * @cmp: pointer to comparison function
>>> + *
>>> + * This function does a binary search on the given array.  The
>>> + * contents of the array should already be in ascending sorted order
>>> + * under the provided comparison function.
>>> + *
>>> + * Note that the key need not have the same type as the elements in
>>> + * the array, e.g. key could be a string and the comparison function
>>> + * could compare the string with the struct's name field. However, if
>>> + * the key and elements in the array are of the same type, you can use
>>> + * the same comparison function for both sort() and bsearch().
>>> + */
>>> +static void *bsearch(const void *key, const void *base, size_t num,
>> size_t size,
>>> +                     int (*cmp)(const void *key, const void *elt))
>>
>> This function is not specific to I/O handlers. So this should be moved
>> to common code. Also please mention in the commit message where the
>> code came from.
>>
>
> Should I move to xen/arch/arm folder?

To xen/common/

[...]

>> Anyway, I would try to merge the two compare functions
>> (match_mmio_handler, cmp_mmio_handler) which have very similar behavior.
>>
>
> Yes, they are not exactly same. One compares only start address and
> other one compares the range.

I don't think this will be an issue to compare the range for both and it 
will avoid to duplicate the code.

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-06-28 13:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 20:33 [PATCH V3 01/10] arm/gic-v3: Use acpi_table_parse_madt() to parse MADT subtables Shanker Donthineni
2016-06-27 20:33 ` [PATCH V3 02/10] arm/gic-v3: Do early GICD ioremap and clean up Shanker Donthineni
2016-06-27 20:33 ` [PATCH V3 03/10] arm/gic-v3: Move GICR subtable parsing into a new function Shanker Donthineni
2016-06-28 10:36   ` Julien Grall
2016-06-27 20:33 ` [PATCH V3 04/10] arm/gic-v3: Parse per-cpu redistributor entry in GICC subtable Shanker Donthineni
2016-06-28 10:40   ` Julien Grall
2016-06-28 13:51     ` Shanker Donthineni
2016-06-28 14:33       ` Shanker Donthineni
2016-07-06 11:30         ` Julien Grall
2016-07-14 14:01   ` Julien Grall
2016-06-27 20:33 ` [PATCH V3 05/10] xen/arm: vgic: Use dynamic memory allocation for vgic_rdist_region Shanker Donthineni
2016-06-28 10:42   ` Julien Grall
2016-06-27 20:33 ` [PATCH v3 06/10] arm/gic-v3: Remove an unused macro MAX_RDIST_COUNT Shanker Donthineni
2016-06-27 20:33 ` [PATCH V3 07/10] arm: vgic: Split vgic_domain_init() functionality into two functions Shanker Donthineni
2016-06-28 10:44   ` Julien Grall
2016-06-27 20:33 ` [PATCH V3 08/10] arm/io: Use separate memory allocation for mmio handlers Shanker Donthineni
2016-06-27 20:33 ` [PATCH V3 09/10] xen/arm: io: Use binary search for mmio handler lookup Shanker Donthineni
2016-06-28 10:13   ` Julien Grall
2016-06-28 10:49   ` Julien Grall
2016-06-28 13:19     ` Shanker Donthineni
2016-06-28 13:29       ` Julien Grall [this message]
2016-06-27 20:33 ` [PATCH V3 10/10] arm/vgic: Change fixed number of mmio handlers to variable number Shanker Donthineni
2016-06-28 10:30 ` [PATCH V3 01/10] arm/gic-v3: Use acpi_table_parse_madt() to parse MADT subtables Julien Grall
2016-07-14 14:18 ` Stefano Stabellini
2016-07-14 15:30   ` Shanker Donthineni

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=57727BBE.5090906@arm.com \
    --to=julien.grall@arm.com \
    --cc=pelcan@codeaurora.org \
    --cc=shankerd@codeaurora.org \
    --cc=sstabellini@kernel.org \
    --cc=vikrams@codeaurora.org \
    --cc=xen-devel@lists.xensource.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.