dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: Jerome Glisse <j.glisse@gmail.com>
Cc: thellstrom@vmware.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/6] drm/ttm: use ttm_bo_reserve_slowpath_nolru in ttm_eu_reserve_buffers
Date: Thu, 06 Dec 2012 11:52:20 +0100	[thread overview]
Message-ID: <50C078E4.2090903@canonical.com> (raw)
In-Reply-To: <CAH3drwZHcRZjSrotF9ZD8AWUxxrSWa+64A2nKuO8CCRvcsOFxw@mail.gmail.com>

Op 06-12-12 02:36, Jerome Glisse schreef:
> On Fri, Nov 30, 2012 at 7:12 AM, Maarten Lankhorst
> <m.b.lankhorst@gmail.com> wrote:
>> This requires re-use of the seqno, which increases fairness slightly.
>> Instead of spinning with a new seqno every time we keep the current one,
>> but still drop all other reservations we hold. Only when we succeed,
>> we try to get back our other reservations again.
>>
>> This should increase fairness slightly as well.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
>> ---
>>  drivers/gpu/drm/ttm/ttm_execbuf_util.c | 14 ++++++++++++--
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
>> index c7d3236..c02b2b6 100644
>> --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c
>> +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
>> @@ -129,13 +129,17 @@ int ttm_eu_reserve_buffers(struct list_head *list)
>>         entry = list_first_entry(list, struct ttm_validate_buffer, head);
>>         glob = entry->bo->glob;
>>
>> -retry:
>>         spin_lock(&glob->lru_lock);
>>         val_seq = entry->bo->bdev->val_seq++;
>>
>> +retry:
> After more thinking while i was going over patches to send comment i
> think this one is bad, really bad. So here is bad case i see, we have
> a list of 2 bo A & B. We succeed reserving A we set seq_valid to true
> and val_seq to our val_seq. We fail on B, we go slow path and
> unreserve A. Some other CPU reserve A but before it write either
> seq_valid or val_seq we wakeup reserve B and retry to reserve A in
> reserve_nolru we see A as reserved we enter the while loop see
> seq_valid set and test val_seq against our same old val_seq we got ==
> and return -EDEADLCK which is definitly not what we want to do. If we
> inc val seq on retry we will never have this case. So what exactly not
> incrementing it gave us ?
Hm, that would indeed be a valid problem.

Annoyingly, I can't do the conversion to mutexes until the end of the patchset.
I solved this in the ticket mutexes by making the seqno an atomic, which is unset before unlocking.
But doing this with the current ttm code would force extra wake_up_all's inside the reserve path,
since we lack the slowpath handling mutexes have.

Nouveau would run into the same problems already with patch 1, so perhaps we could disable
the -EDEADLK handling and sleep in that case for now? Afaict, it's a driver error if -EDEADLK
occurs.

If performance is unimportant unset seq_valid before unreserving,
and add a smp_wmb between seqno and seqno_valid assignments.
wake_up_all() would be called unconditionally during reservation then, but that call is expensive..

> I think the read and write memory barrier i was talking in patch 1
> should avoid any such things to happen but i need to sleep on that to
> make nightmare about all things that can go wrong.
No it wouldn't help, still a race immediately after the xchg call. :-(

~Maarten

  reply	other threads:[~2012-12-06 10:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30 12:11 [PATCH 0/6] drm/ttm: lru lock atomicity removal Maarten Lankhorst
2012-11-30 12:12 ` [PATCH 1/6] drm/ttm: remove lru_lock around ttm_bo_reserve Maarten Lankhorst
2012-11-30 12:12   ` [PATCH 2/6] drm/ttm: cleanup ttm_eu_reserve_buffers handling Maarten Lankhorst
2012-11-30 12:12   ` [PATCH 3/6] drm/ttm: add ttm_bo_reserve_slowpath Maarten Lankhorst
2012-11-30 12:12   ` [PATCH 4/6] drm/ttm: use ttm_bo_reserve_slowpath_nolru in ttm_eu_reserve_buffers Maarten Lankhorst
2012-12-06  1:36     ` Jerome Glisse
2012-12-06 10:52       ` Maarten Lankhorst [this message]
2012-12-06 15:38         ` Jerome Glisse
2012-11-30 12:12   ` [PATCH 5/6] drm/nouveau: use ttm_bo_reserve_slowpath in validate_init Maarten Lankhorst
2012-11-30 12:13   ` [PATCH 6/6] drm/ttm: unexport ttm_bo_wait_unreserved Maarten Lankhorst
2012-12-06  1:19   ` [PATCH 1/6] drm/ttm: remove lru_lock around ttm_bo_reserve Jerome Glisse
2012-12-06  9:55     ` Maarten Lankhorst
2012-11-30 15:59 ` [PATCH 0/6] drm/ttm: lru lock atomicity removal Thomas Hellstrom
2012-12-06  1:15 ` Jerome Glisse
2012-12-06  1:38   ` Jerome Glisse

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=50C078E4.2090903@canonical.com \
    --to=maarten.lankhorst@canonical.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=j.glisse@gmail.com \
    --cc=thellstrom@vmware.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