[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m1k4vsphcm.fsf@fess.ebiederm.org>
Date: Fri, 08 Jan 2010 10:43:53 -0800
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Cyrill Gorcunov <gorcunov@...il.com>
Cc: Yinghai Lu <yinghai@...nel.org>, Ingo Molnar <mingo@...e.hu>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Jesse Brandeburg <jesse.brandeburg@...el.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/5] sparseirq: use radix_tree instead of ptrs array
Cyrill Gorcunov <gorcunov@...il.com> writes:
> On Fri, Jan 08, 2010 at 03:53:14AM -0800, Yinghai Lu wrote:
>> use radix_tree irq_desc_tree instead of irq_desc_ptrs.
>>
>> Signed-off-by: Yinghai Lu <yinghai@...nel.org>
>>
>> ---
>> kernel/irq/handle.c | 47 ++++++++++++++++++++++-------------------------
>> 1 file changed, 22 insertions(+), 25 deletions(-)
>>
>> Index: linux-2.6/kernel/irq/handle.c
>> ===================================================================
>> --- linux-2.6.orig/kernel/irq/handle.c
>> +++ linux-2.6/kernel/irq/handle.c
>> @@ -19,6 +19,7 @@
>> #include <linux/kernel_stat.h>
>> #include <linux/rculist.h>
>> #include <linux/hash.h>
>> +#include <linux/radix-tree.h>
>> #include <trace/events/irq.h>
>>
>> #include "internals.h"
>> @@ -127,7 +128,23 @@ static void init_one_irq_desc(int irq, s
>> */
>> DEFINE_RAW_SPINLOCK(sparse_irq_lock);
>>
>> -static struct irq_desc **irq_desc_ptrs __read_mostly;
>> +static RADIX_TREE(irq_desc_tree, GFP_KERNEL);
>> +
>> +static void set_irq_desc(unsigned int irq, struct irq_desc *desc)
>> +{
>> + radix_tree_insert(&irq_desc_tree, irq, desc);
>> +}
>> +
>> +struct irq_desc *irq_to_desc(unsigned int irq)
>> +{
>> + return radix_tree_lookup(&irq_desc_tree, irq);
>> +}
>> +
>> +void replace_irq_desc(unsigned int irq, struct irq_desc *desc)
>> +{
>> + radix_tree_delete(&irq_desc_tree, irq);
>> + radix_tree_insert(&irq_desc_tree, irq, desc);
>> +}
>>
> ...
>
> Hi Yinghai,
>
> should not we printk\warn if radix_tree_insert() is get failed?
> This is hardly (if ever) happen on machines with small number
> of interrupts allocated but anyway.
>
> Or I miss something?
It looks to me like we can use radix_tree_lookup_slot and
radix_tree_replace_slot here. Since we don't have to allocate
memory radix_tree_replace_slot can not fail. Using a case
that can never fail seems better than worry about a case that
can rarely fail.
Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists