lkml.org 
[lkml]   [2020]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][PATCH 6/9] irq_work: Provide irq_work_queue_remote_static()
Provide the same horrible semantics provided by
smp_call_function_single_async(), doing so allows skiping a bunch of
atomic ops.

API wise this is horrible crap as it relies on external serialization.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/irq_work.h | 1 +
kernel/irq_work.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)

--- a/include/linux/irq_work.h
+++ b/include/linux/irq_work.h
@@ -68,6 +68,7 @@ static inline bool irq_work_needs_cpu(vo

#ifdef CONFIG_SMP
extern int irq_work_queue_remote(int cpu, struct irq_work *work);
+extern int irq_work_queue_remote_static(int cpu, struct irq_work *work);
extern void irq_work_single(void *arg);
#endif

--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -63,6 +63,9 @@ void irq_work_single(void *arg)
work->func(work);
lockdep_irq_work_exit(flags);

+ if (!(flags & IRQ_WORK_BUSY))
+ return;
+
/*
* Clear the BUSY bit, if set, and return to the free state if no-one
* else claimed it meanwhile.
@@ -108,6 +111,22 @@ int irq_work_queue_remote(int cpu, struc

return 0;
}
+
+int irq_work_queue_remote_static(int cpu, struct irq_work *work)
+{
+ /*
+ * Ensures preemption is disabled in the caller.
+ */
+ WARN_ON_ONCE(cpu == smp_processor_id());
+
+ if (atomic_read(&work->node.a_flags) & IRQ_WORK_PENDING)
+ return -EBUSY;
+
+ atomic_set(&work->node.a_flags, IRQ_WORK_PENDING);
+ __smp_call_single_queue(cpu, &work->node.llist);
+
+ return 0;
+}

#endif /* CONFIG_SMP */


\
 
 \ /
  Last update: 2020-07-22 17:34    [W:0.280 / U:1.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site