@@ -12,6 +12,7 @@
#include <linux/export.h>
#include <linux/interrupt.h>
#include <linux/kernel_stat.h>
+#include <linux/mutex.h>
#include <linux/radix-tree.h>
#include <linux/bitmap.h>
#include <linux/irqdomain.h>
@@ -312,21 +313,32 @@ static void irq_sysfs_add(int irq, struct irq_desc *desc) {}
#endif /* CONFIG_SYSFS */
static RADIX_TREE(irq_desc_tree, GFP_KERNEL);
+static DEFINE_MUTEX(irq_desc_tree_mutex);
static void irq_insert_desc(unsigned int irq, struct irq_desc *desc)
{
+ mutex_lock(&irq_desc_tree_mutex);
radix_tree_insert(&irq_desc_tree, irq, desc);
+ mutex_unlock(&irq_desc_tree_mutex);
}
struct irq_desc *irq_to_desc(unsigned int irq)
{
- return radix_tree_lookup(&irq_desc_tree, irq);
+ struct irq_desc *desc;
+
+ rcu_read_lock();
+ desc = radix_tree_lookup(&irq_desc_tree, irq);
+ rcu_read_unlock();
+
+ return desc;
}
EXPORT_SYMBOL(irq_to_desc);
static void delete_irq_desc(unsigned int irq)
{
+ mutex_lock(&irq_desc_tree_mutex);
radix_tree_delete(&irq_desc_tree, irq);
+ mutex_unlock(&irq_desc_tree_mutex);
}
#ifdef CONFIG_SMP
Add a mutex to prevent concurrency on the updater side of the irq_desc radix tree. Add rcu_read_lock/unlock to the reader side so that lifetimes of leaf pointers of the radix tree are correctly managed. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> --- kernel/irq/irqdesc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.7.4