From: Yinghai Lu <yinghai@kernel.org>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Jesse Brandeburg <jesse.brandeburg@intel.com>
Cc: linux-kernel@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 4/5] sparseirq: use radix_tree instead of ptrs array
Date: Fri, 08 Jan 2010 03:53:14 -0800 [thread overview]
Message-ID: <1262951595-1729-4-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1262951595-1729-1-git-send-email-yinghai@kernel.org>
use radix_tree irq_desc_tree instead of irq_desc_ptrs.
Signed-off-by: Yinghai Lu <yinghai@kernel.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);
+}
static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS_LEGACY-1] = {
@@ -159,9 +176,6 @@ int __init early_irq_init(void)
legacy_count = ARRAY_SIZE(irq_desc_legacy);
node = first_online_node;
- /* allocate irq_desc_ptrs array based on nr_irqs */
- irq_desc_ptrs = kcalloc(nr_irqs, sizeof(void *), GFP_NOWAIT);
-
/* allocate based on nr_cpu_ids */
kstat_irqs_legacy = kzalloc_node(NR_IRQS_LEGACY * nr_cpu_ids *
sizeof(int), GFP_NOWAIT, node);
@@ -175,29 +189,12 @@ int __init early_irq_init(void)
lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
alloc_desc_masks(&desc[i], node, true);
init_desc_masks(&desc[i]);
- irq_desc_ptrs[i] = desc + i;
+ set_irq_desc(i, &desc[i]);
}
- for (i = legacy_count; i < nr_irqs; i++)
- irq_desc_ptrs[i] = NULL;
-
return arch_early_irq_init();
}
-struct irq_desc *irq_to_desc(unsigned int irq)
-{
- if (irq_desc_ptrs && irq < nr_irqs)
- return irq_desc_ptrs[irq];
-
- return NULL;
-}
-
-void replace_irq_desc(unsigned int irq, struct irq_desc *desc)
-{
- if (irq_desc_ptrs && irq < nr_irqs)
- irq_desc_ptrs[irq] = desc;
-}
-
struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
{
struct irq_desc *desc;
@@ -209,14 +206,14 @@ struct irq_desc * __ref irq_to_desc_allo
return NULL;
}
- desc = irq_desc_ptrs[irq];
+ desc = irq_to_desc(irq);
if (desc)
return desc;
raw_spin_lock_irqsave(&sparse_irq_lock, flags);
/* We have to check it to avoid races with another CPU */
- desc = irq_desc_ptrs[irq];
+ desc = irq_to_desc(irq);
if (desc)
goto out_unlock;
@@ -229,7 +226,7 @@ struct irq_desc * __ref irq_to_desc_allo
}
init_one_irq_desc(irq, desc, node);
- irq_desc_ptrs[irq] = desc;
+ set_irq_desc(irq, desc);
out_unlock:
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
next prev parent reply other threads:[~2010-01-08 11:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-08 11:53 [PATCH 1/5] irq: remove not need bootmem code Yinghai Lu
2010-01-08 11:53 ` [PATCH 2/5] radix: move radix init early Yinghai Lu
2010-01-08 11:53 ` [PATCH 3/5] sparseirq: change irq_desc_ptrs to static Yinghai Lu
2010-01-08 11:53 ` Yinghai Lu [this message]
2010-01-08 12:14 ` [PATCH 4/5] sparseirq: use radix_tree instead of ptrs array Cyrill Gorcunov
2010-01-08 18:43 ` Eric W. Biederman
2010-01-08 11:53 ` [PATCH 5/5] x86: update nr_irqs according cpu num Yinghai Lu
2010-01-08 19:11 ` Eric W. Biederman
2010-01-08 19:21 ` H. Peter Anvin
2010-01-08 20:06 ` Yinghai Lu
2010-01-08 21:11 ` H. Peter Anvin
2010-01-08 20:10 ` Eric W. Biederman
2010-01-08 21:15 ` H. Peter Anvin
2010-01-08 19:49 ` Yinghai Lu
2010-01-08 20:20 ` Eric W. Biederman
2010-01-08 20:43 ` Yinghai Lu
2010-01-08 18:52 ` [PATCH 1/5] irq: remove not need bootmem code Eric W. Biederman
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=1262951595-1729-4-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=jesse.brandeburg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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