>3. If we have a ticket we grab a reference to the first BO on the LRU, drop the LRU lock and try to grab the reservation lock with the ticket. The BO on LRU is already locked by cs user, can it be dropped here by DC user? and then DC user grab its lock with ticket, how does CS grab it again? If you think waiting in ttm has this risk, how about just adding a wrapper for pin function as below? amdgpu_get_pin_bo_timeout() { do { amdgpo_bo_reserve(); r=amdgpu_bo_pin(); if(!r) break; amdgpu_bo_unreserve(); timeout--; } while(timeout>0); } -------- Original Message -------- Subject: Re: [PATCH] ttm: wait mem space if user allow while gpu busy From: Christian König To: "Zhou, David(ChunMing)" ,"Koenig, Christian" ,"Liang, Prike" ,dri-devel@xxxxxxxxxxxxxxxxxxxxx CC: Well that's not so easy of hand.
The basic problem here is that when you busy wait at this place you can easily run into situations where application A busy waits for B while B busy waits for A -> deadlock. So what we need here is the deadlock detection logic of the ww_mutex. To use this we at least need to do the following steps: 1. Reserve the BO in DC using a ww_mutex ticket (trivial). 2. If we then run into this EBUSY condition in TTM check if the BO we need memory for (or rather the ww_mutex of its reservation object) has a ticket assigned. 3. If we have a ticket we grab a reference to the first BO on the LRU, drop the LRU lock and try to grab the reservation lock with the ticket. 4. If getting the reservation lock with the ticket succeeded we check if the BO is still the first one on the LRU in question (the BO could have moved). 5. If the BO is still the first one on the LRU in question we try to evict it as we would evict any other BO. 6. If any of the "If's" above fail we just back off and return -EBUSY. Steps 2-5 are certainly not trivial, but doable as far as I can see. Have fun :) Christian. Am 23.04.19 um 15:19 schrieb Zhou, David(ChunMing):
|
_______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel