From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Fam Zheng <famz@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
Juan Quintela <quintela@redhat.com>,
Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>,
Jeff Cody <jcody@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Max Reitz <mreitz@redhat.com>, Alberto Garcia <berto@igalia.com>,
"open list:Sheepdog" <sheepdog@lists.wpkg.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Liu Yuan <namei.unix@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 02/35] WIP: coroutine: manually tag the fast-paths
Date: Tue, 11 Jul 2017 11:41:45 -0400 (EDT) [thread overview]
Message-ID: <1177675548.49553273.1499787705474.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170711152356.GA31231@stefanha-x1.localdomain>
Hi
----- Original Message -----
> On Wed, Jul 05, 2017 at 12:03:13AM +0200, Marc-André Lureau wrote:
> > Some functions are both regular and coroutine. They may call coroutine
> > functions in some cases, if it is known to be running in a coroutine.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > block.c | 2 ++
> > block/block-backend.c | 2 ++
> > block/io.c | 16 +++++++++++++++-
> > block/sheepdog.c | 2 ++
> > block/throttle-groups.c | 10 ++++++++--
> > migration/rdma.c | 2 ++
> > 6 files changed, 31 insertions(+), 3 deletions(-)
> >
> > diff --git a/block.c b/block.c
> > index 694396281b..b08c006da4 100644
> > --- a/block.c
> > +++ b/block.c
> > @@ -443,7 +443,9 @@ int bdrv_create(BlockDriver *drv, const char* filename,
> >
> > if (qemu_in_coroutine()) {
> > /* Fast-path if already in coroutine context */
> > + co_role_acquire(_coroutine_fn);
> > bdrv_create_co_entry(&cco);
> > + co_role_release(_coroutine_fn);
> > } else {
> > co = qemu_coroutine_create(bdrv_create_co_entry, &cco);
> > qemu_coroutine_enter(co);
>
> I guess the clever analysis for clang would be to detect that if
> (qemu_in_coroutine()) means we have the _coroutine_fn role. It's
> similar to how Coverity sees an if (ptr) and knows whether the pointer
> is NULL/non-NULL in the branches.
>
> But this patch is okay too :-).
Right, I though about using try_acquire_capability, similarly needed for try_lock etc. However, I don't see how to automatically release the capability when going out of scope. Apparently there are some known limitations around these patterns. I would love to hear from compilers folks what they think about -Wthread-safety and if it can be added to gcc with various kind of improvements.
next prev parent reply other threads:[~2017-07-11 15:42 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-04 22:03 [Qemu-devel] [PATCH 00/35] RFC: coroutine annotations & clang check Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 01/35] WIP: coroutine: annotate coroutine with clang thread safety attributes Marc-André Lureau
2017-07-05 11:39 ` Paolo Bonzini
2017-07-05 14:11 ` Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 02/35] WIP: coroutine: manually tag the fast-paths Marc-André Lureau
2017-07-11 15:23 ` Stefan Hajnoczi
2017-07-11 15:41 ` Marc-André Lureau [this message]
2017-07-04 22:03 ` [Qemu-devel] [PATCH 03/35] test-coroutine: fix coroutine attribute Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 04/35] coroutine: remove coroutine_fn from qemu_coroutine_self() Marc-André Lureau
2017-07-05 10:56 ` Paolo Bonzini
2017-07-05 13:39 ` Marc-André Lureau
2017-07-05 13:43 ` Paolo Bonzini
2017-07-04 22:03 ` [Qemu-devel] [PATCH 05/35] coroutine: remove coroutine_fn from qemu_co_queue_run_restart() Marc-André Lureau
2017-07-11 15:26 ` Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 06/35] coroutine: mark CoRwLock coroutine_fn Marc-André Lureau
2017-07-11 15:26 ` Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 07/35] blockjob: mark coroutine_fn Marc-André Lureau
2017-07-11 15:27 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 08/35] block: all bdrv_aio callbacks are coroutine_fn Marc-André Lureau
2017-07-05 10:53 ` Paolo Bonzini
2017-07-05 14:21 ` Marc-André Lureau
2017-07-05 14:44 ` Paolo Bonzini
2017-07-05 16:06 ` Marc-André Lureau
2017-07-05 16:10 ` Paolo Bonzini
2017-07-05 16:40 ` Marc-André Lureau
2017-07-05 16:42 ` Paolo Bonzini
2017-07-04 22:03 ` [Qemu-devel] [PATCH 09/35] block: bdrv_create() and bdrv_debug_event() " Marc-André Lureau
2017-07-11 16:04 ` Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 10/35] vmdk: mark coroutine_fn Marc-André Lureau
2017-07-11 16:04 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 11/35] qcow2: " Marc-André Lureau
2017-07-11 16:04 ` Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 12/35] raw: " Marc-André Lureau
2017-07-11 16:06 ` Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 13/35] nbd: " Marc-André Lureau
2017-07-06 14:33 ` Eric Blake
2017-07-04 22:03 ` [Qemu-devel] [PATCH 14/35] migration: " Marc-André Lureau
2017-07-11 16:06 ` Stefan Hajnoczi
2017-07-18 16:04 ` Juan Quintela
2017-07-18 16:21 ` Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 15/35] backup: " Marc-André Lureau
2017-07-11 18:53 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-07-04 22:03 ` [Qemu-devel] [PATCH 16/35] crypto: " Marc-André Lureau
2017-07-18 19:27 ` Eric Blake
2017-07-04 22:03 ` [Qemu-devel] [PATCH 17/35] curl: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 18/35] gluster: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 19/35] nfs: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 20/35] quorum: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 21/35] rbd: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 22/35] sheepdog: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 23/35] ssh: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 24/35] null: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 25/35] mirror: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 26/35] iscsi: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 27/35] file-posix: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 28/35] 9p: " Marc-André Lureau
2017-07-05 9:45 ` Greg Kurz
2017-07-04 22:03 ` [Qemu-devel] [PATCH 29/35] block: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 30/35] block-backend: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 31/35] parallels: " Marc-André Lureau
2017-07-05 14:11 ` Denis V. Lunev
2017-07-04 22:03 ` [Qemu-devel] [PATCH 32/35] qed: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 33/35] vdi: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 34/35] vhdx: " Marc-André Lureau
2017-07-04 22:03 ` [Qemu-devel] [PATCH 35/35] vpc: " Marc-André Lureau
2017-07-05 5:25 ` [Qemu-devel] [PATCH 00/35] RFC: coroutine annotations & clang check Markus Armbruster
2017-07-05 9:34 ` Marc-André Lureau
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=1177675548.49553273.1499787705474.JavaMail.zimbra@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=berto@igalia.com \
--cc=dgilbert@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mitake.hitoshi@lab.ntt.co.jp \
--cc=mreitz@redhat.com \
--cc=namei.unix@gmail.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=sheepdog@lists.wpkg.org \
--cc=stefanha@gmail.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 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).