From: Gustavo Padovan <gustavo@padovan.org>
To: "Christian König" <deathsimple@vodafone.de>
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] dma-buf/fence-array: hold fences reference when creating an array
Date: Thu, 20 Oct 2016 10:05:09 -0200 [thread overview]
Message-ID: <20161020120509.GA10198@joana> (raw)
In-Reply-To: <dae27699-75f5-7099-db9c-799e7ab7408d@vodafone.de>
2016-10-20 Christian König <deathsimple@vodafone.de>:
> Am 19.10.2016 um 20:35 schrieb Gustavo Padovan:
> > 2016-10-19 Christian König <deathsimple@vodafone.de>:
> >
> > > Am 19.10.2016 um 19:48 schrieb Gustavo Padovan:
> > > > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > > >
> > > > When creating fence arrays we were not holding references to the fences
> > > > in the array, however when destroy the array we were putting away a
> > > > reference to these fences.
> > > >
> > > > This patch hold the ref for all fences in the array when creating the
> > > > array.
> > > >
> > > > It then removes the code that was holding the fences on both amdgpu_vm and
> > > > sync_file. For sync_file, specially, we worked on small referencing
> > > > refactor for sync_file_merge().
> > > >
> > > > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > > I would prefer it to keep it like it is, cause this is a bit inconsistent.
> > >
> > > With this change the fence array takes the ownership of the array, but not
> > > of the fences inside it.
> > I was thinking more in to keep consistency between all fence users. Every
> > user should hold a ref to the fence assigned to it. That is what patch
> > 1 is doing for sync_file and think it is a good idea do the same here.
>
> This might make the code easier to follow, but isn't necessary a good idea.
>
> Usually with reference counted objects you increase the count every time the
> pointer to the object is assigned to a container. E.g. member of a larger
> structure or in this case an array of pointers.
>
> >
> > The array itself is not refcounted and the users calling
> > fence_array_create() doesn't store the allocated array anywhere. The
> > comment I errouneously removed already states that.
>
> And exactly that's the point here. The array is the container for the
> pointers referencing the objects, since you give the ownership of this
> container to the fence_array object it is now responsible for releasing that
> reference before it releases the array.
>
> This is good coding practice as far as I know.
Right, this makes sense. Let's keep this as is then.
Gustavo
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-10-20 12:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 17:48 [PATCH 1/2] dma-buf/sync_file: hold reference to fence when creating sync_file Gustavo Padovan
2016-10-19 17:48 ` [PATCH 2/2] dma-buf/fence-array: hold fences reference when creating an array Gustavo Padovan
2016-10-19 18:08 ` Christian König
2016-10-19 18:35 ` Gustavo Padovan
2016-10-20 7:18 ` Christian König
2016-10-20 12:05 ` Gustavo Padovan [this message]
2016-10-21 14:53 ` [PATCH 1/2] dma-buf/sync_file: hold reference to fence when creating sync_file Sean Paul
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=20161020120509.GA10198@joana \
--to=gustavo@padovan.org \
--cc=deathsimple@vodafone.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo.padovan@collabora.co.uk \
/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