[PATCH] drm/ttm: fix busy memory to fail other user v3
zhoucm1
zhoucm1 at amd.com
Fri Apr 26 09:15:04 UTC 2019
On 2019年04月26日 17:11, Koenig, Christian wrote:
> Am 26.04.19 um 11:07 schrieb zhoucm1:
>> [SNIP]
>>>> + spin_lock(&glob->lru_lock);
>>>> + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>>>> + if (list_empty(&man->lru[i]))
>>>> + continue;
>>>> + bo = list_first_entry(&man->lru[i],
>>>> + struct ttm_buffer_object,
>>>> + lru);
>>> You now need to check all BOs on the LRU, cause the first one where a
>>> trylock failed is not necessarily the first one on the list.
>> Sorry, I don't get your opinion on this, Could you detail a bit how to
>> do that?
>> I though after ww_mutex_lock, cs is done, then DC can pick up any of
>> them.
> The first_bo is not necessarily the first BO of the LRU, but the first
> BO which failed in the trylock.
>
>>>> +
>>>> + break;
>>>> + }
>>>> + /* verify if BO have been moved */
>>>> + if (first_bo != bo) {
> And in this case we would abort here without a good reason.
I got what you said now. I will change it soon.
-David
>
> Christian.
>
>>>> + spin_unlock(&glob->lru_lock);
>>>> + ww_mutex_unlock(&bo->resv->lock);
>>>> + return -EBUSY;
>>>> + }
>>>> + spin_unlock(&glob->lru_lock);
>>>> + /* ok, pick up first busy BO to wait to evict */
>>>> }
>>>> kref_get(&bo->list_kref);
>>>> @@ -1784,7 +1819,10 @@ int ttm_bo_swapout(struct ttm_bo_global
>>>> *glob, struct ttm_operation_ctx *ctx)
>>>> spin_lock(&glob->lru_lock);
>>>> for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>>>> list_for_each_entry(bo, &glob->swap_lru[i], swap) {
>>>> - if (ttm_bo_evict_swapout_allowable(bo, ctx, &locked)) {
>>>> + bool busy = false;
>>> Better make the parameter optional.
>> Will do.
>>
>> -David
>>> Christian.
>>>
>>>> +
>>>> + if (ttm_bo_evict_swapout_allowable(bo, ctx, &locked,
>>>> + &busy)) {
>>>> ret = 0;
>>>> break;
>>>> }
More information about the dri-devel
mailing list