Commit 471ba0e6 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Ingo Molnar

irq_work: Do not raise an IPI when queueing work on the local CPU

The QEMU PowerPC/PSeries machine model was not expecting a self-IPI,
and it may be a bit surprising thing to do, so have irq_work_queue_on
do local queueing when target is the current CPU.
Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Reported-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <clg@kaod.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190409093403.20994-1-npiggin@gmail.com
[ Simplified the preprocessor comments.
  Fixed unbalanced curly brackets pointed out by Thomas. ]
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 2d65c42b
...@@ -56,61 +56,70 @@ void __weak arch_irq_work_raise(void) ...@@ -56,61 +56,70 @@ void __weak arch_irq_work_raise(void)
*/ */
} }
/* /* Enqueue on current CPU, work must already be claimed and preempt disabled */
* Enqueue the irq_work @work on @cpu unless it's already pending static void __irq_work_queue_local(struct irq_work *work)
* somewhere.
*
* Can be re-enqueued while the callback is still in progress.
*/
bool irq_work_queue_on(struct irq_work *work, int cpu)
{ {
/* All work should have been flushed before going offline */ /* If the work is "lazy", handle it from next tick if any */
WARN_ON_ONCE(cpu_is_offline(cpu)); if (work->flags & IRQ_WORK_LAZY) {
if (llist_add(&work->llnode, this_cpu_ptr(&lazy_list)) &&
#ifdef CONFIG_SMP tick_nohz_tick_stopped())
arch_irq_work_raise();
/* Arch remote IPI send/receive backend aren't NMI safe */ } else {
WARN_ON_ONCE(in_nmi()); if (llist_add(&work->llnode, this_cpu_ptr(&raised_list)))
arch_irq_work_raise();
}
}
/* Enqueue the irq work @work on the current CPU */
bool irq_work_queue(struct irq_work *work)
{
/* Only queue if not already pending */ /* Only queue if not already pending */
if (!irq_work_claim(work)) if (!irq_work_claim(work))
return false; return false;
if (llist_add(&work->llnode, &per_cpu(raised_list, cpu))) /* Queue the entry and raise the IPI if needed. */
arch_send_call_function_single_ipi(cpu); preempt_disable();
__irq_work_queue_local(work);
#else /* #ifdef CONFIG_SMP */ preempt_enable();
irq_work_queue(work);
#endif /* #else #ifdef CONFIG_SMP */
return true; return true;
} }
EXPORT_SYMBOL_GPL(irq_work_queue);
/* Enqueue the irq work @work on the current CPU */ /*
bool irq_work_queue(struct irq_work *work) * Enqueue the irq_work @work on @cpu unless it's already pending
* somewhere.
*
* Can be re-enqueued while the callback is still in progress.
*/
bool irq_work_queue_on(struct irq_work *work, int cpu)
{ {
#ifndef CONFIG_SMP
return irq_work_queue(work);
#else /* CONFIG_SMP: */
/* All work should have been flushed before going offline */
WARN_ON_ONCE(cpu_is_offline(cpu));
/* Only queue if not already pending */ /* Only queue if not already pending */
if (!irq_work_claim(work)) if (!irq_work_claim(work))
return false; return false;
/* Queue the entry and raise the IPI if needed. */
preempt_disable(); preempt_disable();
if (cpu != smp_processor_id()) {
/* If the work is "lazy", handle it from next tick if any */ /* Arch remote IPI send/receive backend aren't NMI safe */
if (work->flags & IRQ_WORK_LAZY) { WARN_ON_ONCE(in_nmi());
if (llist_add(&work->llnode, this_cpu_ptr(&lazy_list)) && if (llist_add(&work->llnode, &per_cpu(raised_list, cpu)))
tick_nohz_tick_stopped()) arch_send_call_function_single_ipi(cpu);
arch_irq_work_raise();
} else { } else {
if (llist_add(&work->llnode, this_cpu_ptr(&raised_list))) __irq_work_queue_local(work);
arch_irq_work_raise();
} }
preempt_enable(); preempt_enable();
return true; return true;
#endif /* CONFIG_SMP */
} }
EXPORT_SYMBOL_GPL(irq_work_queue);
bool irq_work_needs_cpu(void) bool irq_work_needs_cpu(void)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment