From: Johan Hovold <johan+linaro@kernel.org> To: Marc Zyngier <maz@kernel.org>, Thomas Gleixner <tglx@linutronix.de> Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, Hsin-Yi Wang <hsinyi@chromium.org>, Mark-PK Tsai <mark-pk.tsai@mediatek.com> Subject: [PATCH v6 08/20] irqdomain: Drop revmap mutex Date: Mon, 13 Feb 2023 11:42:50 +0100 [thread overview] Message-ID: <20230213104302.17307-9-johan+linaro@kernel.org> (raw) In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> The revmap mutex is essentially only used to maintain the integrity of the radix tree during updates (lookups use RCU). As the global irq_domain_mutex is now held in all paths that update the revmap structures there is strictly no longer any need for the dedicated mutex, which can be removed. Drop the revmap mutex and add lockdep assertions to the revmap helpers to make sure that the global lock is always held when updating the revmap. Tested-by: Hsin-Yi Wang <hsinyi@chromium.org> Tested-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com> Signed-off-by: Johan Hovold <johan+linaro@kernel.org> --- include/linux/irqdomain.h | 2 -- kernel/irq/irqdomain.c | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index a372086750ca..16399de00b48 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -143,7 +143,6 @@ struct irq_domain_chip_generic; * Revmap data, used internally by the irq domain code: * @revmap_size: Size of the linear map table @revmap[] * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map - * @revmap_mutex: Lock for the revmap * @revmap: Linear table of irq_data pointers */ struct irq_domain { @@ -171,7 +170,6 @@ struct irq_domain { irq_hw_number_t hwirq_max; unsigned int revmap_size; struct radix_tree_root revmap_tree; - struct mutex revmap_mutex; struct irq_data __rcu *revmap[]; }; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 8e14805c5508..f2247186f71d 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -206,7 +206,6 @@ static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, /* Fill structure */ INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); - mutex_init(&domain->revmap_mutex); domain->ops = ops; domain->host_data = host_data; domain->hwirq_max = hwirq_max; @@ -526,30 +525,30 @@ static bool irq_domain_is_nomap(struct irq_domain *domain) static void irq_domain_clear_mapping(struct irq_domain *domain, irq_hw_number_t hwirq) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], NULL); else radix_tree_delete(&domain->revmap_tree, hwirq); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_set_mapping(struct irq_domain *domain, irq_hw_number_t hwirq, struct irq_data *irq_data) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], irq_data); else radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) @@ -1580,11 +1579,12 @@ static void irq_domain_fix_revmap(struct irq_data *d) { void __rcu **slot; + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(d->domain)) return; /* Fix up the revmap. */ - mutex_lock(&d->domain->revmap_mutex); if (d->hwirq < d->domain->revmap_size) { /* Not using radix tree */ rcu_assign_pointer(d->domain->revmap[d->hwirq], d); @@ -1593,7 +1593,6 @@ static void irq_domain_fix_revmap(struct irq_data *d) if (slot) radix_tree_replace_slot(&d->domain->revmap_tree, slot, d); } - mutex_unlock(&d->domain->revmap_mutex); } /** -- 2.39.1
WARNING: multiple messages have this Message-ID (diff)
From: Johan Hovold <johan+linaro@kernel.org> To: Marc Zyngier <maz@kernel.org>, Thomas Gleixner <tglx@linutronix.de> Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, Hsin-Yi Wang <hsinyi@chromium.org>, Mark-PK Tsai <mark-pk.tsai@mediatek.com> Subject: [PATCH v6 08/20] irqdomain: Drop revmap mutex Date: Mon, 13 Feb 2023 11:42:50 +0100 [thread overview] Message-ID: <20230213104302.17307-9-johan+linaro@kernel.org> (raw) In-Reply-To: <20230213104302.17307-1-johan+linaro@kernel.org> The revmap mutex is essentially only used to maintain the integrity of the radix tree during updates (lookups use RCU). As the global irq_domain_mutex is now held in all paths that update the revmap structures there is strictly no longer any need for the dedicated mutex, which can be removed. Drop the revmap mutex and add lockdep assertions to the revmap helpers to make sure that the global lock is always held when updating the revmap. Tested-by: Hsin-Yi Wang <hsinyi@chromium.org> Tested-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com> Signed-off-by: Johan Hovold <johan+linaro@kernel.org> --- include/linux/irqdomain.h | 2 -- kernel/irq/irqdomain.c | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index a372086750ca..16399de00b48 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -143,7 +143,6 @@ struct irq_domain_chip_generic; * Revmap data, used internally by the irq domain code: * @revmap_size: Size of the linear map table @revmap[] * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map - * @revmap_mutex: Lock for the revmap * @revmap: Linear table of irq_data pointers */ struct irq_domain { @@ -171,7 +170,6 @@ struct irq_domain { irq_hw_number_t hwirq_max; unsigned int revmap_size; struct radix_tree_root revmap_tree; - struct mutex revmap_mutex; struct irq_data __rcu *revmap[]; }; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 8e14805c5508..f2247186f71d 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -206,7 +206,6 @@ static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, /* Fill structure */ INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); - mutex_init(&domain->revmap_mutex); domain->ops = ops; domain->host_data = host_data; domain->hwirq_max = hwirq_max; @@ -526,30 +525,30 @@ static bool irq_domain_is_nomap(struct irq_domain *domain) static void irq_domain_clear_mapping(struct irq_domain *domain, irq_hw_number_t hwirq) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], NULL); else radix_tree_delete(&domain->revmap_tree, hwirq); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_set_mapping(struct irq_domain *domain, irq_hw_number_t hwirq, struct irq_data *irq_data) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], irq_data); else radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) @@ -1580,11 +1579,12 @@ static void irq_domain_fix_revmap(struct irq_data *d) { void __rcu **slot; + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(d->domain)) return; /* Fix up the revmap. */ - mutex_lock(&d->domain->revmap_mutex); if (d->hwirq < d->domain->revmap_size) { /* Not using radix tree */ rcu_assign_pointer(d->domain->revmap[d->hwirq], d); @@ -1593,7 +1593,6 @@ static void irq_domain_fix_revmap(struct irq_data *d) if (slot) radix_tree_replace_slot(&d->domain->revmap_tree, slot, d); } - mutex_unlock(&d->domain->revmap_mutex); } /** -- 2.39.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-02-13 10:43 UTC|newest] Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-13 10:42 [PATCH v6 00/20] irqdomain: fix mapping race and rework locking Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 10:42 ` [PATCH v6 01/20] irqdomain: Fix association race Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 02/20] irqdomain: Fix disassociation race Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 03/20] irqdomain: Drop bogus fwspec-mapping error handling Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 04/20] irqdomain: Look for existing mapping only once Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 05/20] irqdomain: Refactor __irq_domain_alloc_irqs() Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 06/20] irqdomain: Fix mapping-creation race Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-03-08 14:41 ` Cyril Brulebois 2023-03-08 14:41 ` Cyril Brulebois 2023-03-08 14:53 ` Marc Zyngier 2023-03-08 14:53 ` Marc Zyngier 2023-03-09 7:32 ` Johan Hovold 2023-03-09 7:32 ` Johan Hovold 2023-02-13 10:42 ` [PATCH v6 07/20] irqdomain: Fix domain registration race Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier 2023-02-13 10:42 ` Johan Hovold [this message] 2023-02-13 10:42 ` [PATCH v6 08/20] irqdomain: Drop revmap mutex Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 09/20] irqdomain: Drop dead domain-name assignment Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 10/20] irqdomain: Drop leftover brackets Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 11/20] irqdomain: Clean up irq_domain_push/pop_irq() Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 12/20] x86/ioapic: Use irq_domain_create_hierarchy() Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 13/20] x86/uv: " Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 14/20] irqchip/alpine-msi: Use irq_domain_add_hierarchy() Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 15/20] irqchip/gic-v2m: Use irq_domain_create_hierarchy() Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 16/20] irqchip/gic-v3-its: " Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:42 ` [PATCH v6 17/20] irqchip/gic-v3-mbi: " Johan Hovold 2023-02-13 10:42 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:43 ` [PATCH v6 18/20] irqchip/loongson-pch-msi: " Johan Hovold 2023-02-13 10:43 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:43 ` [PATCH v6 19/20] irqchip/mvebu-odmi: " Johan Hovold 2023-02-13 10:43 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-02-13 10:43 ` [PATCH v6 20/20] irqdomain: Switch to per-domain locking Johan Hovold 2023-02-13 10:43 ` Johan Hovold 2023-02-13 19:40 ` [irqchip: irq/irqchip-next] " irqchip-bot for Johan Hovold 2023-03-07 13:51 ` [PATCH v6 20/20] " David Woodhouse 2023-03-07 13:51 ` David Woodhouse 2023-03-07 14:06 ` Juergen Gross 2023-03-07 14:06 ` Juergen Gross 2023-03-07 14:18 ` David Woodhouse 2023-03-07 14:18 ` David Woodhouse
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=20230213104302.17307-9-johan+linaro@kernel.org \ --to=johan+linaro@kernel.org \ --cc=hsinyi@chromium.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mips@vger.kernel.org \ --cc=mark-pk.tsai@mediatek.com \ --cc=maz@kernel.org \ --cc=platform-driver-x86@vger.kernel.org \ --cc=tglx@linutronix.de \ --cc=x86@kernel.org \ /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: linkBe 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.