From: "Christian König" <deathsimple@vodafone.de>
To: Jerome Glisse <j.glisse@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 14/20] drm/radeon: multiple ring allocator v2
Date: Tue, 08 May 2012 12:23:09 +0200 [thread overview]
Message-ID: <4FA8F40D.5080400@vodafone.de> (raw)
In-Reply-To: <CAH3drwZRzL8m64FNQxGAgzxttpetbrYyQy03UEtqMU6QzFKP_A@mail.gmail.com>
On 07.05.2012 23:28, Jerome Glisse wrote:
> On Mon, May 7, 2012 at 4:38 PM, Christian König<deathsimple@vodafone.de> wrote:
>> On 07.05.2012 20:52, Jerome Glisse wrote:
>>> On Mon, May 7, 2012 at 1:59 PM, Jerome Glisse<j.glisse@gmail.com> wrote:
>>>>> On 07.05.2012 17:23, Jerome Glisse wrote:
>>>>>> Your patch here can enter in infinite loop and never return holding
>>>>>> the lock. See below.
>>>>>>
>>>>>> [SNIP]
>>>>>>
>>>>>>> + } while (radeon_sa_bo_next_hole(sa_manager, fences));
>>>>>> Here you can infinite loop, in the case there is a bunch of hole in
>>>>>> the allocator but none of them allow to full fill the allocation.
>>>>>> radeon_sa_bo_next_hole will keep returning true looping over and over
>>>>>> on all the all. That's why i only restrict my patch to 2 hole skeeping
>>>>>> and then fails the allocation or try to wait. I believe sadly we need
>>>>>> an heuristic and 2 hole skeeping at most sounded like a good one.
>>>>> Nope, that can't be an infinite loop, cause radeon_sa_bo_next_hole in
>>>>> conjunction with radeon_sa_bo_try_free are eating up the opportunities
>>>>> for
>>>>> holes.
>>>>>
>>>>> Look again, it probably will never loop more than RADEON_NUM_RINGS + 1,
>>>>> with
>>>>> the exception for allocating in a complete scattered buffer, and even
>>>>> then
>>>>> it will never loop more often than halve the number of current
>>>>> allocations
>>>>> (and that is really really unlikely).
>>>>>
>>>>> Cheers,
>>>>> Christian.
>>>> I looked again and yes it can loop infinitly, think of hole you can
>>>> never free ie radeon_sa_bo_try_free can't free anything. This
>>>> situation can happen if you have several thread allocating sa bo at
>>>> the same time while none of them are yet done with there sa_bo (ie
>>>> none have call sa_bo_free yet). I updated a v3 that track oldest and
>>>> fix all things you were pointing out above.
>> No that isn't a problem, radeon_sa_bo_next_hole takes the firsts entries of
>> the flist, so it only considers holes that have a signaled fence and so can
>> be freed.
>>
>> Having multiple threads allocate objects that can't be freed yet will just
>> result in empty flists, and so radeon_sa_bo_next_hole will return false,
>> resulting in calling radeon_fence_wait_any with an empty fence list, which
>> in turn will result in an ENOENT and abortion of allocation (ok maybe we
>> should catch that and return -ENOMEM instead).
>>
>> So even the corner cases should now be handled fine.
> No, there is still infinite loop possible with gpu lockup, i am
> against the while (next_hole) using for on 2 iteration looks a lot
> better and it avoids sa allocator possibly looping too much (because
> it can loop a lot more than RADEON_NUM_RINGS, the maximum number of
> loop is sa_manager->size/4).
I'm still pretty sure that there isn't the possibility for an infinite
loop, so please explain further where exactly the problem is.
radeon_sa_bo_next_hole will return true as long as it can find AND
remove an allocation with an already signaled fence, and since nobody
else can add allocations while we are in the loop we sooner or later run
out of allocations and so the loop ends.
Also what the loop does is just cleaning up all the already signaled
allocations, and it doesn't matter if there is one allocation or a
million, we need to clean them up anyway. So aborting the loop and
trying to wait for anything to be signaled makes no sense at all, and
aborting the whole allocation at this point makes even less sense, cause
that only delays the work that needs to be done anyway (freeing the
allocations) to a later call to radeon_sa_bo_new.
What could make sense is limiting how often we are waiting for some
fences, since while waiting we release the lock and then other processes
can jump in and grab what we wanted to have by waiting for something to
happen.
Cheers,
Christian.
next prev parent reply other threads:[~2012-05-08 10:23 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-07 11:42 SA and other Patches Christian König
2012-05-07 11:42 ` [PATCH 01/20] drm/radeon: fix possible lack of synchronization btw ttm and other ring Christian König
2012-05-07 11:42 ` [PATCH 02/20] drm/radeon: clarify and extend wb setup on APUs and NI+ asics Christian König
2012-05-07 11:42 ` [PATCH 03/20] drm/radeon: replace the per ring mutex with a global one Christian König
2012-05-07 11:42 ` [PATCH 04/20] drm/radeon: convert fence to uint64_t v4 Christian König
2012-05-07 14:39 ` Jerome Glisse
2012-05-07 15:04 ` Christian König
2012-05-07 15:27 ` Jerome Glisse
2012-05-07 11:42 ` [PATCH 05/20] drm/radeon: rework fence handling, drop fence list v5 Christian König
2012-05-07 11:42 ` [PATCH 06/20] drm/radeon: rework locking ring emission mutex in fence deadlock detection Christian König
2012-05-07 11:42 ` [PATCH 07/20] drm/radeon: use inline functions to calc sa_bo addr Christian König
2012-05-07 11:42 ` [PATCH 08/20] drm/radeon: add proper locking to the SA v3 Christian König
2012-05-07 11:42 ` [PATCH 09/20] drm/radeon: add sub allocator debugfs file Christian König
2012-05-07 11:42 ` [PATCH 10/20] drm/radeon: keep start and end offset in the SA Christian König
2012-05-07 11:42 ` [PATCH 11/20] drm/radeon: make sa bo a stand alone object Christian König
2012-05-07 11:42 ` [PATCH 12/20] drm/radeon: define new SA interface v3 Christian König
2012-05-07 11:42 ` [PATCH 13/20] drm/radeon: use one wait queue for all rings add fence_wait_any v2 Christian König
2012-05-07 11:42 ` [PATCH 14/20] drm/radeon: multiple ring allocator v2 Christian König
2012-05-07 15:23 ` Jerome Glisse
2012-05-07 16:45 ` Christian König
[not found] ` <CAH3drwb=qkpeLrSL9dejg0WEt_bCk98TkR0vtggpn3_maN6gZg@mail.gmail.com>
2012-05-07 17:59 ` Fwd: " Jerome Glisse
2012-05-07 18:52 ` Jerome Glisse
2012-05-07 20:38 ` Christian König
2012-05-07 21:28 ` Jerome Glisse
2012-05-08 10:23 ` Christian König [this message]
2012-05-08 14:55 ` Jerome Glisse
2012-05-09 9:53 ` Christian König
2012-05-07 11:42 ` [PATCH 15/20] drm/radeon: simplify semaphore handling v2 Christian König
2012-05-07 11:42 ` [PATCH 16/20] drm/radeon: rip out the ib pool Christian König
2012-05-07 11:42 ` [PATCH 17/20] drm/radeon: immediately free ttm-move semaphore Christian König
2012-05-07 11:42 ` [PATCH 18/20] drm/radeon: move the semaphore from the fence into the ib Christian König
2012-05-07 11:42 ` [PATCH 19/20] drm/radeon: remove r600 blit mutex v2 Christian König
2012-05-07 11:42 ` [PATCH 20/20] drm/radeon: make the ib an inline object Christian König
2012-05-07 14:34 ` SA and other Patches Jerome Glisse
2012-05-07 15:30 ` 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=4FA8F40D.5080400@vodafone.de \
--to=deathsimple@vodafone.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=j.glisse@gmail.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.