From: Peter Zijlstra <peterz@infradead.org>
To: mingo@kernel.org, torvalds@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, will@kernel.org,
paulmck@kernel.org, hch@lst.de, axboe@kernel.dk,
chris@chris-wilson.co.uk, davem@davemloft.net, kuba@kernel.org,
fweisbec@gmail.com, oleg@redhat.com, vincent.guittot@linaro.org,
peterz@infradead.org
Subject: [RFC][PATCH v2 06/10] irq_work: Provide irq_work_queue_remote_static()
Date: Tue, 18 Aug 2020 12:51:08 +0200 [thread overview]
Message-ID: <20200818112418.328209144@infradead.org> (raw)
In-Reply-To: 20200818105102.926463950@infradead.org
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 | 3 ++-
kernel/irq_work.c | 21 ++++++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
--- a/include/linux/irq_work.h
+++ b/include/linux/irq_work.h
@@ -19,7 +19,7 @@ struct irq_work {
};
#define __IRQ_WORK_INIT(_func, _flags) (struct irq_work){ \
- .node = { .u_flags = (_flags), }, \
+ .node = { .u_flags = CSD_TYPE_IRQ_WORK | (_flags), }, \
.func = (_func), \
}
@@ -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
@@ -29,7 +29,7 @@ static bool irq_work_claim(struct irq_wo
{
int oflags;
- oflags = atomic_fetch_or(IRQ_WORK_CLAIMED | CSD_TYPE_IRQ_WORK, &work->node.a_flags);
+ oflags = atomic_fetch_or(IRQ_WORK_CLAIMED, &work->node.a_flags);
/*
* If the work is already pending, no need to raise the IPI.
* The pairing smp_mb() in irq_work_single() makes sure
@@ -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 (work->node.u_flags & IRQ_WORK_PENDING)
+ return -EBUSY;
+
+ work->node.u_flags |= IRQ_WORK_PENDING;
+ __smp_call_single_queue(cpu, &work->node.llist);
+
+ return 0;
+}
#endif /* CONFIG_SMP */
next prev parent reply other threads:[~2020-08-18 11:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 10:51 [PATCH v2 00/10] smp: irq_work / smp_call_function rework Peter Zijlstra
2020-08-18 10:51 ` [PATCH v2 01/10] irq_work: Cleanup Peter Zijlstra
2020-08-18 10:51 ` [PATCH v2 02/10] smp: Cleanup smp_call_function*() Peter Zijlstra
2020-08-18 10:51 ` [PATCH v2 03/10] irq_work: Optimize irq_work_single() Peter Zijlstra
2020-08-18 10:51 ` [PATCH v2 04/10] irq_work: Unconditionally build on SMP Peter Zijlstra
2020-08-18 10:51 ` [PATCH v2 05/10] irq_work: Provide irq_work_queue_remote() Peter Zijlstra
2020-08-18 10:51 ` Peter Zijlstra [this message]
2020-08-18 10:51 ` [RFC][PATCH v2 07/10] sched/fair: Exclude the current CPU from find_new_ilb() Peter Zijlstra
2020-08-18 10:51 ` [RFC][PATCH v2 08/10] smp,irq_work: Use the new irq_work API Peter Zijlstra
2020-08-18 16:25 ` Christoph Hellwig
2020-08-19 7:22 ` peterz
2020-08-19 18:50 ` Linus Torvalds
2020-08-19 19:41 ` peterz
2020-08-19 22:04 ` Linus Torvalds
2020-08-20 13:08 ` peterz
2020-08-20 6:20 ` Christoph Hellwig
2020-08-20 6:19 ` Christoph Hellwig
2020-08-20 13:40 ` peterz
2020-09-09 8:03 ` Christoph Hellwig
2020-08-18 10:51 ` [RFC][PATCH v2 09/10] smp: Make smp_call_function_single_async() safer Peter Zijlstra
2020-08-18 10:51 ` [RFC][PATCH v2 10/10] irq_work: Add a few comments Peter Zijlstra
2020-08-18 15:52 ` Randy Dunlap
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=20200818112418.328209144@infradead.org \
--to=peterz@infradead.org \
--cc=axboe@kernel.dk \
--cc=chris@chris-wilson.co.uk \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=hch@lst.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=vincent.guittot@linaro.org \
--cc=will@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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox