dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Hellstrom <thomas@shipmail.org>
Cc: Dave Airlie <airlied@redhat.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: Replace kref with a simple atomic reference count
Date: Sun, 28 Nov 2010 14:35:26 +0100	[thread overview]
Message-ID: <20101128133525.GA3710@viiv.ffwll.ch> (raw)
In-Reply-To: <4CF24BDB.2000204@shipmail.org>

On Sun, Nov 28, 2010 at 01:32:27PM +0100, Thomas Hellstrom wrote:
> This is racy, in that the kref_get() can hit a zero refcount. I
> think an ideal thing here would be to add a kref_get_unless_zero()
> for this situation, that returns an error if the refcount was indeed
> zero. I don't think that would violate the kref idea, since we still
> never increase the refcount of a zeroed object, and the user needs
> to provide the necessary synchronization to make sure the object
> isn't gone while still the refcount is zero.

I've got curious rechecked the code and it all looks sane. The trick is
that all the userspace-visible names hold a ref to the underlying gem
object (including the flink name). If all userspace handles are destroyed
(save the flink name) the flink name gets destroyed, too (see
obj->handle_count). All this is independently protected with spinlocks
and it happens _before_ dropping the ref to the underlying bo (and taking
any necessary locks to do so). I don't see any races nor locking problems,
there.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

  reply	other threads:[~2010-11-28 13:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-25 21:40 [PATCH] drm: Replace kref with a simple atomic reference count Chris Wilson
2010-11-25 22:38 ` Dave Airlie
2010-11-25 22:44   ` Chris Wilson
2010-11-25 23:13     ` Alan Cox
2010-11-28 12:32   ` Thomas Hellstrom
2010-11-28 13:35     ` Daniel Vetter [this message]
2010-11-28 14:19       ` Thomas Hellstrom
2010-11-28 15:13         ` Daniel Vetter
2010-11-28 17:20           ` Thomas Hellstrom

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=20101128133525.GA3710@viiv.ffwll.ch \
    --to=daniel@ffwll.ch \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=thomas@shipmail.org \
    /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