On 3/30/22 12:53, Hanna Reitz wrote:
Seems a good compromise between drains and rwlock. What do you think?
Well, sounds complicated. So I’m asking myself whether this would be
noticeably better than just an RwLock for graph modifications, like the
global lock Vladimir has proposed.
A global lock would have to be taken by all iothreads on every I/O
operation, even a read-write lock would scale because it has a global
CoMutex inside and rdlock/unlock both take it. Even if the critical
section is small, the cacheline bumping would be pretty bad.
Perhaps we could reuse the code in cpus-common.c, which relies on a list
of possible readers and is quite cheap (two memory barriers basically)
for writers. Here we would have a list of AioContexts as the possible
readers.
The slow path uses a QemuMutex, a QemuCond for the readers and a
QemuCond for the writers. The reader QemuCond can be replaced by a
CoQueue, I think.
Paolo