On 5/9/22 13:53, Daniel P. Berrangé wrote:
Apart from this, I also identified the following functions that
can be called both in coroutine context and outside:
snip

- qio_channel_readv_full_all_eof
- qio_channel_writev_full_all

I'm trying to understand what criteria makes those two functions
liable for the annotation, but not others in the I/O code ?

These two are _not_ annotated as coroutine_fn: this is a list of functions that can be called both in coroutine context and outside, while 'coroutine_fn' functions can be called only within coroutines.

The only 'coroutine_fn' function in the I/O code is qio_channel_yield.

What is the actual rule for when to apply 'coroutine_fn' annotation
to a function, and does it apply transitively to up and/or down the
call stack ?

The only rule is that callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". For example:

- qio_channel_readv_full_all_eof() calls qio_channel_yield() within such an "if", therefore it need not be coroutine_fn.

- qio_channel_yield() unconditionally calls qemu_coroutine_yield() which is coroutine_fn, and therefore must be coroutine_fn as well.

After this series, the only exception to the rule is that qemu_coroutine_self() is occasionally called from tracepoints.

Paolo

Reply via email to