All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/6] throttle: Add throttle group infrastructure
Date: Wed, 25 Mar 2015 13:14:58 +0100	[thread overview]
Message-ID: <20150325121458.GA29748@igalia.com> (raw)
In-Reply-To: <20150325120130.GA22940@stefanha-thinkpad.redhat.com>


> > > > +typedef struct ThrottleGroup {
> > > > +    char *name; /* This is constant during the lifetime of the group */
> > > 
> > > Is this also protected by throttle_groups_lock?
> > > 
> > > I guess throttle_groups_lock must be held in order to read this
> > > field - otherwise there is a risk that the object is freed
> > > unless you have already incremented the refcount.
> > 
> > The creation and destruction of ThrottleGroup objects are
> > protected by throttle_groups_lock. That includes handling the
> > memory for that field and its contents.
> > 
> > Once the ThrottleGroup is created the 'name' field doesn't need
> > any additional locking since it remains constant during the
> > lifetime of the group.
> > 
> > The only way to read it from the outside is
> > throttle_group_get_name() and that's safe (until you release the
> > reference to the group, that is).
> 
> Right, the race condition is when the group is released.
> 
> Looking at this again, the assumption isn't that
> throttle_groups_lock is held.  The AioContext lock is held by
> throttle_group_get_name() users and that's why there is no race when
> releasing the reference.
> 
> If someone adds a throttle_group_get_name() caller in the future
> without holding AioContext, then we'd be in trouble.  That is why
> documenting the locking constraints is useful.

But that would only happen if you access bs->throttle_state without
holding bs's AioContext. I understand that it's implicit that you
should hold the context there.

Maybe I can update the throttle_group_* API to use BlockDriverState
in all cases instead of ThrottleState, it's probably more clear like
that.

Berto

  reply	other threads:[~2015-03-25 12:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 15:30 [Qemu-devel] [PATCH v3 0/6] Block Throttle Group Support Alberto Garcia
2015-03-10 15:30 ` [Qemu-devel] [PATCH 1/6] throttle: Extract timers from ThrottleState into a separate structure Alberto Garcia
2015-03-24 15:03   ` Stefan Hajnoczi
2015-03-10 15:30 ` [Qemu-devel] [PATCH 2/6] throttle: Add throttle group infrastructure Alberto Garcia
2015-03-24 15:03   ` Stefan Hajnoczi
2015-03-24 15:33     ` Alberto Garcia
2015-03-25 12:01       ` Stefan Hajnoczi
2015-03-25 12:14         ` Alberto Garcia [this message]
2015-03-10 15:30 ` [Qemu-devel] [PATCH 3/6] throttle: Add throttle group infrastructure tests Alberto Garcia
2015-03-24 15:15   ` Stefan Hajnoczi
2015-03-10 15:30 ` [Qemu-devel] [PATCH 4/6] throttle: Add throttle group support Alberto Garcia
2015-03-24 16:03   ` Stefan Hajnoczi
2015-03-24 16:31   ` Stefan Hajnoczi
2015-03-24 17:48     ` Alberto Garcia
2015-03-25 12:03       ` Stefan Hajnoczi
2015-03-10 15:30 ` [Qemu-devel] [PATCH 5/6] throttle: add the name of the ThrottleGroup to BlockDeviceInfo Alberto Garcia
2015-03-10 15:30 ` [Qemu-devel] [PATCH 6/6] throttle: Update throttle infrastructure copyright Alberto Garcia
2015-03-24 16:32 ` [Qemu-devel] [PATCH v3 0/6] Block Throttle Group Support 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=20150325121458.GA29748@igalia.com \
    --to=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.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 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.