From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: famz@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH 0/4] coroutine-lock: polymorphic CoQueue
Date: Mon, 15 Jan 2018 23:08:18 +0100 [thread overview]
Message-ID: <20180115220822.10156-1-pbonzini@redhat.com> (raw)
There are cases in which a queued coroutine must be restarted from
non-coroutine context (with qemu_co_enter_next). In this cases,
qemu_co_enter_next also needs to be thread-safe, but it cannot use a
CoMutex and so cannot qemu_co_queue_wait. This happens in curl (which
right now is rolling its own list of Coroutines) and will happen in
Fam's NVMe driver as well.
This series extracts the idea of a polymorphic lockable object
from my "scoped lock guard" proposal, and applies it to CoQueue.
The implementation of QemuLockable is similar to C11 _Generic, but
redone using the preprocessor and GCC builtins for compatibility.
In general, while a bit on the esoteric side, the functionality used
to emulate _Generic is fairly old in GCC, and the builtins are already
used by include/qemu/atomic.h; the series was tested with Fedora 27 (boot
Damn Small Linux via http) and CentOS 6 (compiled only).
Paolo
Paolo Bonzini (4):
lockable: add QemuLockable
coroutine-lock: convert CoQueue to use QemuLockable
coroutine-lock: make qemu_co_enter_next thread-safe
curl: convert to CoQueue
block/curl.c | 20 +++---------
fsdev/qemu-fsdev-throttle.c | 4 +--
include/qemu/compiler.h | 40 ++++++++++++++++++++++++
include/qemu/coroutine.h | 25 ++++++++++-----
include/qemu/lockable.h | 75 +++++++++++++++++++++++++++++++++++++++++++++
include/qemu/thread.h | 5 ++-
include/qemu/typedefs.h | 4 +++
util/qemu-coroutine-lock.c | 22 ++++++++-----
8 files changed, 159 insertions(+), 36 deletions(-)
create mode 100644 include/qemu/lockable.h
--
2.14.3
next reply other threads:[~2018-01-15 22:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 22:08 Paolo Bonzini [this message]
2018-01-15 22:08 ` [Qemu-devel] [PATCH 1/4] lockable: add QemuLockable Paolo Bonzini
2018-01-16 3:01 ` Fam Zheng
2018-01-15 22:08 ` [Qemu-devel] [PATCH 2/4] coroutine-lock: convert CoQueue to use QemuLockable Paolo Bonzini
2018-01-15 22:08 ` [Qemu-devel] [PATCH 3/4] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini
2018-01-15 22:08 ` [Qemu-devel] [PATCH 4/4] curl: convert to CoQueue Paolo Bonzini
2018-01-16 3:13 ` [Qemu-devel] [PATCH 0/4] coroutine-lock: polymorphic CoQueue Fam Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180115220822.10156-1-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).