Skip to content

Commit e64e7c7

Browse files
committed
xen/events: avoid using info_for_irq() in xen_send_IPI_one()
xen_send_IPI_one() is being used by cpuhp_report_idle_dead() after it calls rcu_report_dead(), meaning that any RCU usage by xen_send_IPI_one() is a bad idea. Unfortunately xen_send_IPI_one() is using notify_remote_via_irq() today, which is using irq_get_chip_data() via info_for_irq(). And irq_get_chip_data() in turn is using a maple-tree lookup requiring RCU. Avoid this problem by caching the ipi event channels in another percpu variable, allowing the use notify_remote_via_evtchn() in xen_send_IPI_one(). Fixes: 721255b ("genirq: Use a maple tree for interrupt descriptor management") Reported-by: David Woodhouse <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Tested-by: David Woodhouse <[email protected]> Acked-by: Stefano Stabellini <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent b85ea95 commit e64e7c7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/xen/events/events_base.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ static DEFINE_PER_CPU(int [NR_VIRQS], virq_to_irq) = {[0 ... NR_VIRQS-1] = -1};
164164

165165
/* IRQ <-> IPI mapping */
166166
static DEFINE_PER_CPU(int [XEN_NR_IPIS], ipi_to_irq) = {[0 ... XEN_NR_IPIS-1] = -1};
167+
/* Cache for IPI event channels - needed for hot cpu unplug (avoid RCU usage). */
168+
static DEFINE_PER_CPU(evtchn_port_t [XEN_NR_IPIS], ipi_to_evtchn) = {[0 ... XEN_NR_IPIS-1] = 0};
167169

168170
/* Event channel distribution data */
169171
static atomic_t channels_on_cpu[NR_CPUS];
@@ -366,6 +368,7 @@ static int xen_irq_info_ipi_setup(unsigned cpu,
366368
info->u.ipi = ipi;
367369

368370
per_cpu(ipi_to_irq, cpu)[ipi] = irq;
371+
per_cpu(ipi_to_evtchn, cpu)[ipi] = evtchn;
369372

370373
return xen_irq_info_common_setup(info, irq, IRQT_IPI, evtchn, 0);
371374
}
@@ -981,6 +984,7 @@ static void __unbind_from_irq(unsigned int irq)
981984
break;
982985
case IRQT_IPI:
983986
per_cpu(ipi_to_irq, cpu)[ipi_from_irq(irq)] = -1;
987+
per_cpu(ipi_to_evtchn, cpu)[ipi_from_irq(irq)] = 0;
984988
break;
985989
case IRQT_EVTCHN:
986990
dev = info->u.interdomain;
@@ -1632,7 +1636,7 @@ EXPORT_SYMBOL_GPL(evtchn_put);
16321636

16331637
void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector)
16341638
{
1635-
int irq;
1639+
evtchn_port_t evtchn;
16361640

16371641
#ifdef CONFIG_X86
16381642
if (unlikely(vector == XEN_NMI_VECTOR)) {
@@ -1643,9 +1647,9 @@ void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector)
16431647
return;
16441648
}
16451649
#endif
1646-
irq = per_cpu(ipi_to_irq, cpu)[vector];
1647-
BUG_ON(irq < 0);
1648-
notify_remote_via_irq(irq);
1650+
evtchn = per_cpu(ipi_to_evtchn, cpu)[vector];
1651+
BUG_ON(evtchn == 0);
1652+
notify_remote_via_evtchn(evtchn);
16491653
}
16501654

16511655
struct evtchn_loop_ctrl {

0 commit comments

Comments
 (0)