qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: pbonzini@redhat.com, berrange@redhat.com, qemu-devel@nongnu.org,
	quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/3] rcu: Add automatically released rcu_read_lock variant
Date: Wed, 11 Sep 2019 19:52:31 +0100	[thread overview]
Message-ID: <20190911185231.GO2894@work-vm> (raw)
In-Reply-To: <1a03f787-5cf8-6b8e-7489-3f90c3311032@redhat.com>

* Eric Blake (eblake@redhat.com) wrote:
> On 9/11/19 11:42 AM, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > 
> > RCU_READ_LOCK_AUTO takes the rcu_read_lock  and then uses glib's
> > g_auto infrastrcture (and thus whatever the compilers hooks are) to
> > release it on all exits of the block.
> > 
> > Note this macro has a variable declaration in, and hence is not in
> > a while loop.
> > 
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > ---
> >  include/qemu/rcu.h | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
> > index 22876d1428..6a25b27d28 100644
> > --- a/include/qemu/rcu.h
> > +++ b/include/qemu/rcu.h
> > @@ -154,6 +154,18 @@ extern void call_rcu1(struct rcu_head *head, RCUCBFunc *func);
> >        }),                                                                \
> >        (RCUCBFunc *)g_free);
> >  
> > +typedef char rcu_read_auto_t;
> 
> Declaring new types ending in _t collides with the namespace reserved by
> POSIX.  While I don't think it will bite us, it's still worth
> considering if a different name is better.

Thanks, I've renamed it to 'RCUReadAuto' which is closer to what we
normally use for typedef's (albeit normally of structs)

Dave

> > +static inline void rcu_read_auto_unlock(rcu_read_auto_t *r)
> > +{
> > +  rcu_read_unlock();
> > +}
> > +
> > +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(rcu_read_auto_t, rcu_read_auto_unlock)
> > +
> > +#define RCU_READ_LOCK_AUTO g_auto(rcu_read_auto_t) \
> > +    _rcu_read_auto = 'x'; \
> 
> I'm a bit lost at where _rcu_read_auto is declared.  (I could understand
> if an earlier macro had created that typedef via concatenating _ with
> rcu_read_auto_t, but making the preprocessor drop _t is not possible. Is
> this a typo, and if so, why did the compiler not complain?)
> 
> > +    rcu_read_lock();
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > 
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3226
> Virtualization:  qemu.org | libvirt.org
> 



--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


  parent reply	other threads:[~2019-09-11 18:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 16:41 [Qemu-devel] [PATCH 0/3] Automatic RCU read unlock Dr. David Alan Gilbert (git)
2019-09-11 16:42 ` [Qemu-devel] [PATCH 1/3] rcu: Add automatically released rcu_read_lock variant Dr. David Alan Gilbert (git)
2019-09-11 16:56   ` Daniel P. Berrangé
2019-09-11 17:04     ` Dr. David Alan Gilbert
2019-09-11 17:09       ` Daniel P. Berrangé
2019-09-11 17:10         ` Dr. David Alan Gilbert
2019-09-11 17:16           ` Daniel P. Berrangé
2019-09-11 17:18             ` Dr. David Alan Gilbert
2019-09-11 17:56     ` Eric Blake
2019-09-11 18:49       ` Dr. David Alan Gilbert
2019-09-11 17:40   ` Eric Blake
2019-09-11 17:49     ` Eric Blake
2019-09-11 18:27       ` Dr. David Alan Gilbert
2019-09-11 18:52     ` Dr. David Alan Gilbert [this message]
2019-09-11 16:42 ` [Qemu-devel] [PATCH 2/3] migration: Use automatic rcu_read unlock in ram.c Dr. David Alan Gilbert (git)
2019-09-11 16:59   ` Daniel P. Berrangé
2019-09-11 17:25     ` Dr. David Alan Gilbert
2019-09-11 16:42 ` [Qemu-devel] [PATCH 3/3] migration: Use automatic rcu_read unlock in rdma.c Dr. David Alan Gilbert (git)
2019-09-11 16:58 ` [Qemu-devel] [PATCH 0/3] Automatic RCU read unlock Daniel P. Berrangé
2019-09-11 17:13   ` Dr. David Alan Gilbert
2019-09-11 20:30 ` no-reply

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=20190911185231.GO2894@work-vm \
    --to=dgilbert@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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).