* [Qemu-devel] [PATCH] block/mirror: add missing coroutine_fn annotations
@ 2018-12-13 11:24 Stefan Hajnoczi
2018-12-13 12:02 ` Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2018-12-13 11:24 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Jeff Cody, qemu-block, Max Reitz, Stefan Hajnoczi,
John Snow
Marking a function coroutine_fn currently has no effect on the compiler,
but it documents that this function must be called from coroutine
context and it may yield. This is important information for the
programmer.
Also, if we ever transition to a stackless coroutine implementation,
then it's likely that the annotation will become mandatory so the
compiler can use the correct calling convention for coroutine functions.
Cc: Max Reitz <mreitz@redhat.com>
Cc: John Snow <jsnow@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/mirror.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 8f52c6215d..408c49248f 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -277,7 +277,8 @@ static int mirror_cow_align(MirrorBlockJob *s, int64_t *offset,
return ret;
}
-static inline void mirror_wait_for_any_operation(MirrorBlockJob *s, bool active)
+static inline void coroutine_fn
+mirror_wait_for_any_operation(MirrorBlockJob *s, bool active)
{
MirrorOp *op;
@@ -295,7 +296,8 @@ static inline void mirror_wait_for_any_operation(MirrorBlockJob *s, bool active)
abort();
}
-static inline void mirror_wait_for_free_in_flight_slot(MirrorBlockJob *s)
+static inline void coroutine_fn
+mirror_wait_for_free_in_flight_slot(MirrorBlockJob *s)
{
/* Only non-active operations use up in-flight slots */
mirror_wait_for_any_operation(s, false);
@@ -598,7 +600,7 @@ static void mirror_free_init(MirrorBlockJob *s)
* mirror_resume() because mirror_run() will begin iterating again
* when the job is resumed.
*/
-static void mirror_wait_for_all_io(MirrorBlockJob *s)
+static void coroutine_fn mirror_wait_for_all_io(MirrorBlockJob *s)
{
while (s->in_flight > 0) {
mirror_wait_for_free_in_flight_slot(s);
@@ -731,7 +733,7 @@ static void mirror_abort(Job *job)
assert(ret == 0);
}
-static void mirror_throttle(MirrorBlockJob *s)
+static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
{
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
@@ -1106,7 +1108,7 @@ static void mirror_complete(Job *job, Error **errp)
job_enter(job);
}
-static void mirror_pause(Job *job)
+static void coroutine_fn mirror_pause(Job *job)
{
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
@@ -1177,9 +1179,10 @@ static const BlockJobDriver commit_active_job_driver = {
.drain = mirror_drain,
};
-static void do_sync_target_write(MirrorBlockJob *job, MirrorMethod method,
- uint64_t offset, uint64_t bytes,
- QEMUIOVector *qiov, int flags)
+static void coroutine_fn
+do_sync_target_write(MirrorBlockJob *job, MirrorMethod method,
+ uint64_t offset, uint64_t bytes,
+ QEMUIOVector *qiov, int flags)
{
BdrvDirtyBitmapIter *iter;
QEMUIOVector target_qiov;
--
2.19.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] block/mirror: add missing coroutine_fn annotations
2018-12-13 11:24 [Qemu-devel] [PATCH] block/mirror: add missing coroutine_fn annotations Stefan Hajnoczi
@ 2018-12-13 12:02 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2018-12-13 12:02 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Jeff Cody, qemu-block, Max Reitz, John Snow
Am 13.12.2018 um 12:24 hat Stefan Hajnoczi geschrieben:
> Marking a function coroutine_fn currently has no effect on the compiler,
> but it documents that this function must be called from coroutine
> context and it may yield. This is important information for the
> programmer.
>
> Also, if we ever transition to a stackless coroutine implementation,
> then it's likely that the annotation will become mandatory so the
> compiler can use the correct calling convention for coroutine functions.
>
> Cc: Max Reitz <mreitz@redhat.com>
> Cc: John Snow <jsnow@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-13 12:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-13 11:24 [Qemu-devel] [PATCH] block/mirror: add missing coroutine_fn annotations Stefan Hajnoczi
2018-12-13 12:02 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).