From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, jason@jlekstrand.net
Subject: Re: [PATCH 1/7] dma-buf: fix inconsistent debug print
Date: Wed, 2 Jun 2021 14:36:58 +0200 [thread overview]
Message-ID: <c40b4c90-b595-9be0-29db-01b7bb5d24a6@gmail.com> (raw)
In-Reply-To: <YLd6k+LIHLja07V9@phenom.ffwll.local>
Am 02.06.21 um 14:33 schrieb Daniel Vetter:
> On Wed, Jun 02, 2021 at 01:17:08PM +0200, Christian König wrote:
>> The code tries to acquire the rcu protected fence list, but then ignores
>> individual fences which have been modified while holding the rcu.
>>
>> Stop that madness and just note cleanly that the list was concurrently modified.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
> Yeah it's debugfs, it's better not to be fancy here and if you race you
> can just re-grab it all.
>
> What's worse, we do grab the dma_resv_lock, which means no one should be
> able to race with us. I think 100% right thing here is actually to drop
> the rcu_read_lock too, and switch over to rcu_dereference_protected().
>
> And also drop the seqcount check, that would be a bug. seqcount is only
> to get a consistent snapshot of all fences on the read (i.e. protected by
> rcu only) section. We hold the write lock with dma_resv_lock here.
Yes that what I had in mind as alternative as well.
Just wasn't 100% sure which way to go here.
Going to adjust that,
Christian.
>
> Cheers, Daniel
>
>> ---
>> drivers/dma-buf/dma-buf.c | 19 ++++++++-----------
>> 1 file changed, 8 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
>> index eadd1eaa2fb5..d3b4e370dbc1 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -1383,22 +1383,17 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
>> buf_obj->name ?: "");
>>
>> robj = buf_obj->resv;
>> - while (true) {
>> - seq = read_seqcount_begin(&robj->seq);
>> - rcu_read_lock();
>> - fobj = rcu_dereference(robj->fence);
>> - shared_count = fobj ? fobj->shared_count : 0;
>> - fence = rcu_dereference(robj->fence_excl);
>> - if (!read_seqcount_retry(&robj->seq, seq))
>> - break;
>> - rcu_read_unlock();
>> - }
>> -
>> + seq = read_seqcount_begin(&robj->seq);
>> + rcu_read_lock();
>> + fence = rcu_dereference(robj->fence_excl);
>> if (fence)
>> seq_printf(s, "\tExclusive fence: %s %s %ssignalled\n",
>> fence->ops->get_driver_name(fence),
>> fence->ops->get_timeline_name(fence),
>> dma_fence_is_signaled(fence) ? "" : "un");
>> +
>> + fobj = rcu_dereference(robj->fence);
>> + shared_count = fobj ? fobj->shared_count : 0;
>> for (i = 0; i < shared_count; i++) {
>> fence = rcu_dereference(fobj->shared[i]);
>> if (!dma_fence_get_rcu(fence))
>> @@ -1410,6 +1405,8 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
>> dma_fence_put(fence);
>> }
>> rcu_read_unlock();
>> + if (read_seqcount_retry(&robj->seq, seq))
>> + seq_printf(s, "\tFences concurrently modified\n");
>>
>> seq_puts(s, "\tAttached Devices:\n");
>> attach_count = 0;
>> --
>> 2.25.1
>>
next prev parent reply other threads:[~2021-06-02 12:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 11:17 [PATCH 1/7] dma-buf: fix inconsistent debug print Christian König
2021-06-02 11:17 ` [PATCH 2/7] dma-buf: add SPDX header and fix style in dma-resv.c Christian König
2021-06-02 12:34 ` Daniel Vetter
2021-06-02 12:47 ` Christian König
2021-06-02 12:55 ` Daniel Vetter
2021-06-02 11:17 ` [PATCH 3/7] dma-buf: cleanup dma-resv shared fence debugging a bit Christian König
2021-06-02 12:41 ` Daniel Vetter
2021-06-02 11:17 ` [PATCH 4/7] dma-buf: rename and cleanup dma_resv_get_excl Christian König
2021-06-02 12:43 ` Daniel Vetter
2021-06-02 20:04 ` Jason Ekstrand
2021-06-02 12:46 ` Daniel Vetter
2021-06-02 11:17 ` [PATCH 5/7] dma-buf: rename and cleanup dma_resv_get_list Christian König
2021-06-02 12:46 ` Daniel Vetter
2021-06-02 20:22 ` Jason Ekstrand
2021-06-06 8:53 ` Christian König
2021-06-07 19:42 ` Jason Ekstrand
2021-06-02 11:17 ` [PATCH 6/7] dma-buf: rename dma_resv_get_excl_rcu to _unlocked Christian König
2021-06-02 12:47 ` Daniel Vetter
2021-06-02 20:25 ` Jason Ekstrand
2021-06-02 11:17 ` [PATCH 7/7] dma-buf: drop the _rcu postfix on function names Christian König
2021-06-02 12:49 ` Daniel Vetter
2021-06-02 20:34 ` Jason Ekstrand
2021-06-06 9:08 ` Christian König
2021-06-02 12:33 ` [PATCH 1/7] dma-buf: fix inconsistent debug print Daniel Vetter
2021-06-02 12:36 ` Christian König [this message]
2021-06-02 12:50 ` Daniel Vetter
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=c40b4c90-b595-9be0-29db-01b7bb5d24a6@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jason@jlekstrand.net \
/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