On 4/13/22 18:29, Kevin Wolf wrote:
A reader does not have to be a coroutine. AIO_WAIT_WHILE is not
mandatory to allow it to finish, it helps to ensure progress in case
some reader is waiting for something, but other than that is not
necessary IMO.
When it's outside of a coroutine, how would you implement waiting for a
writer to finish if not with AIO_WAIT_WHILE()?


In the main thread a non-coroutine can always read the graph though, because the only writer can be the main thread.

If the critical sections are large enough, I don't think rdlock needs to be taken outside a coroutine in the iothread, e.g. in a bottom half.

No I think if we focus on small pieces of code we end up having a
million lock/unlock pairs.

Yes, I agree. On the other hand, if we're taking the locks in high-level
outer operations, avoiding to take the lock recursively might become
harder. I guess we'll see how it works out when we actually introduce
callers.

My "hope" is that taking the locks in blk_* functions covers most of the calls, and then only a few (dozens) direct uses of bdrv_* remain.

Unfortunately, adding assertions is not easy because "is there a reader" cannot be easily answered. But I think Emanuele has a debug mode that can enable the assertions at a performance cost.

Paolo

Reply via email to