All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: hreitz@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org,
	sguelton@redhat.com
Subject: [PATCH experiment 00/35] stackless coroutine backend
Date: Thu, 10 Mar 2022 13:43:38 +0100	[thread overview]
Message-ID: <20220310124413.1102441-1-pbonzini@redhat.com> (raw)

Here is an experiment with using stackless coroutines in QEMU.  It
only compiles enough code to run tests/unit/test-coroutine, but at
least it proves that it's possible to quickly test ideas in the
area of coroutine runtimes.  Another idea that could be toyed with
in a similar manner could be (whoa) C++ coroutines.

As expected, this also found some issues in existing code, so I
plan to submit patches 1-5 separately.

The new backend (which is the only one that works, due to the required
code changes) is in patch 7.  For the big description of what stackless
coroutines are, please refer to that patch.

Patches 8-11 do some initial conversions.  Patch 12 introduce some
preprocessor magic that greatly eases the rest of the work, and then
the tests are converted one at a time, until patch 27 where the only
ones missing are the CoRwlock tests.

Therefore, patches 28-33 convert CoRwlock and pathces 34-35 take care
of the corresponding tests, thus concluding the experiment.

Paolo

Paolo Bonzini (35):
  coroutine: add missing coroutine_fn annotations for CoRwlock functions
  coroutine: qemu_coroutine_get_aio_context is not a coroutine_fn
  coroutine: introduce QemuCoLockable
  coroutine: introduce coroutine_only_fn
  coroutine: small code cleanup in qemu_co_rwlock_wrlock
  disable some code
  coroutine: introduce the "stackless coroutine" backend
  /basic/lifecycle
  convert qemu-coroutine-sleep.c to stackless coroutines
  enable tail call optimization of qemu_co_mutex_lock
  convert CoMutex to stackless coroutines
  define magic macros for stackless coroutines
  /basic/yield
  /basic/nesting
  /basic/self
  /basic/entered
  /basic/in_coroutine
  /basic/order
  /perf/lifecycle
  /perf/nesting
  /perf/yield
  /perf/function-call
  /perf/cost
  /basic/no-dangling-access
  /locking/co-mutex
  convert qemu_co_mutex_lock_slowpath to magic macros
  /locking/co-mutex/lockable
  qemu_co_rwlock_maybe_wake_one
  qemu_co_rwlock_rdlock
  qemu_co_rwlock_unlock
  qemu_co_rwlock_downgrade
  qemu_co_rwlock_wrlock
  qemu_co_rwlock_upgrade
  /locking/co-rwlock/upgrade
  /locking/co-rwlock/downgrade

 configure                    |  44 +---
 include/qemu/co-lockable.h   | 110 +++++++++
 include/qemu/coroutine.h     |  99 ++++++--
 include/qemu/coroutine_int.h |   6 -
 include/qemu/lockable.h      |  13 +-
 include/qemu/typedefs.h      |   1 +
 tests/unit/meson.build       |   2 +-
 tests/unit/test-coroutine.c  | 425 +++++++++++++++++++++++++++++------
 util/coroutine-stackless.c   | 159 +++++++++++++
 util/meson.build             |  10 +-
 util/qemu-coroutine-lock.c   | 215 ++++++++++++++----
 util/qemu-coroutine-sleep.c  |  57 ++++-
 util/qemu-coroutine.c        |  18 +-
 13 files changed, 932 insertions(+), 227 deletions(-)
 create mode 100644 include/qemu/co-lockable.h
 create mode 100644 util/coroutine-stackless.c

-- 
2.35.1



             reply	other threads:[~2022-03-10 13:25 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 12:43 Paolo Bonzini [this message]
2022-03-10 12:43 ` [PATCH 01/35] coroutine: add missing coroutine_fn annotations for CoRwlock functions Paolo Bonzini
2022-03-10 12:43 ` [PATCH 02/35] coroutine: qemu_coroutine_get_aio_context is not a coroutine_fn Paolo Bonzini
2022-03-10 12:43 ` [PATCH 03/35] coroutine: introduce QemuCoLockable Paolo Bonzini
2022-03-10 12:43 ` [PATCH 04/35] coroutine: introduce coroutine_only_fn Paolo Bonzini
2022-03-10 12:43 ` [PATCH 05/35] coroutine: small code cleanup in qemu_co_rwlock_wrlock Paolo Bonzini
2022-03-10 14:10   ` Philippe Mathieu-Daudé
2022-03-10 12:43 ` [PATCH 06/35] disable some code Paolo Bonzini
2022-03-10 12:43 ` [PATCH 07/35] coroutine: introduce the "stackless coroutine" backend Paolo Bonzini
2022-03-10 12:43 ` [PATCH 08/35] /basic/lifecycle Paolo Bonzini
2022-03-10 12:43 ` [PATCH 09/35] convert qemu-coroutine-sleep.c to stackless coroutines Paolo Bonzini
2022-03-10 12:43 ` [PATCH 10/35] enable tail call optimization of qemu_co_mutex_lock Paolo Bonzini
2022-03-10 12:43 ` [PATCH 11/35] convert CoMutex to stackless coroutines Paolo Bonzini
2022-03-10 12:43 ` [PATCH 12/35] define magic macros for " Paolo Bonzini
2022-03-10 12:43 ` [PATCH 13/35] /basic/yield Paolo Bonzini
2022-03-10 12:43 ` [PATCH 14/35] /basic/nesting Paolo Bonzini
2022-03-10 12:43 ` [PATCH 15/35] /basic/self Paolo Bonzini
2022-03-10 12:43 ` [PATCH 16/35] /basic/entered Paolo Bonzini
2022-03-10 12:43 ` [PATCH 17/35] /basic/in_coroutine Paolo Bonzini
2022-03-10 12:43 ` [PATCH 18/35] /basic/order Paolo Bonzini
2022-03-10 12:43 ` [PATCH 19/35] /perf/lifecycle Paolo Bonzini
2022-03-10 12:43 ` [PATCH 20/35] /perf/nesting Paolo Bonzini
2022-03-10 12:43 ` [PATCH 21/35] /perf/yield Paolo Bonzini
2022-03-10 12:44 ` [PATCH 22/35] /perf/function-call Paolo Bonzini
2022-03-10 12:44 ` [PATCH 23/35] /perf/cost Paolo Bonzini
2022-03-10 12:44 ` [PATCH 24/35] /basic/no-dangling-access Paolo Bonzini
2022-03-10 12:44 ` [PATCH 25/35] /locking/co-mutex Paolo Bonzini
2022-03-10 12:44 ` [PATCH 26/35] convert qemu_co_mutex_lock_slowpath to magic macros Paolo Bonzini
2022-03-10 12:44 ` [PATCH 27/35] /locking/co-mutex/lockable Paolo Bonzini
2022-03-10 12:44 ` [PATCH 28/35] qemu_co_rwlock_maybe_wake_one Paolo Bonzini
2022-03-10 12:44 ` [PATCH 29/35] qemu_co_rwlock_rdlock Paolo Bonzini
2022-03-10 12:44 ` [PATCH 30/35] qemu_co_rwlock_unlock Paolo Bonzini
2022-03-10 12:44 ` [PATCH 31/35] qemu_co_rwlock_downgrade Paolo Bonzini
2022-03-10 12:44 ` [PATCH 32/35] qemu_co_rwlock_wrlock Paolo Bonzini
2022-03-10 12:44 ` [PATCH 33/35] qemu_co_rwlock_upgrade Paolo Bonzini
2022-03-10 12:44 ` [PATCH 34/35] /locking/co-rwlock/upgrade Paolo Bonzini
2022-03-10 12:44 ` [PATCH 35/35] /locking/co-rwlock/downgrade Paolo Bonzini
2022-03-10 17:42 ` [PATCH experiment 00/35] stackless coroutine backend Stefan Hajnoczi
2022-03-10 20:14   ` Paolo Bonzini
2022-03-11  9:27     ` Stefan Hajnoczi
2022-03-11 12:04       ` Paolo Bonzini
2022-03-11 12:17         ` Daniel P. Berrangé
2022-03-13 15:18           ` Paolo Bonzini
2022-03-14 13:43             ` Stefan Hajnoczi

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=20220310124413.1102441-1-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sguelton@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.