qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/4] coroutine-lock: polymorphic CoQueue
@ 2018-01-16 14:23 Paolo Bonzini
  2018-01-16 14:23 ` [Qemu-devel] [PATCH 1/4] lockable: add QemuLockable Paolo Bonzini
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Paolo Bonzini @ 2018-01-16 14:23 UTC (permalink / raw)
  To: qemu-devel

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

v1->v2: fix typos and copyright year

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

^ permalink raw reply	[flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 0/4] coroutine-lock: polymorphic CoQueue
@ 2018-01-15 22:08 Paolo Bonzini
  2018-01-15 22:08 ` [Qemu-devel] [PATCH 3/4] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini
  0 siblings, 1 reply; 12+ messages in thread
From: Paolo Bonzini @ 2018-01-15 22:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: famz, stefanha, qemu-block

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-01-25 15:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16 14:23 [Qemu-devel] [PATCH v2 0/4] coroutine-lock: polymorphic CoQueue Paolo Bonzini
2018-01-16 14:23 ` [Qemu-devel] [PATCH 1/4] lockable: add QemuLockable Paolo Bonzini
2018-01-16 14:23 ` [Qemu-devel] [PATCH 2/4] coroutine-lock: convert CoQueue to use QemuLockable Paolo Bonzini
2018-01-16 14:23 ` [Qemu-devel] [PATCH 3/4] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini
2018-01-16 14:23 ` [Qemu-devel] [PATCH 4/4] curl: convert to CoQueue Paolo Bonzini
2018-01-17  6:04 ` [Qemu-devel] [PATCH v2 0/4] coroutine-lock: polymorphic CoQueue no-reply
2018-01-17  6:24   ` Fam Zheng
2018-01-24  3:58 ` Fam Zheng
2018-01-24  9:00   ` Paolo Bonzini
2018-01-25 15:05 ` Fam Zheng
2018-01-25 15:12   ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2018-01-15 22:08 [Qemu-devel] [PATCH " Paolo Bonzini
2018-01-15 22:08 ` [Qemu-devel] [PATCH 3/4] coroutine-lock: make qemu_co_enter_next thread-safe Paolo Bonzini

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).