qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 00/26] block: fix coroutine_fn annotations


From: Paolo Bonzini
Subject: Re: [PATCH v2 00/26] block: fix coroutine_fn annotations
Date: Mon, 9 May 2022 15:30:31 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

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

[Prev in Thread] Current Thread [Next in Thread]