Re: [PATCH V4 for-next 02/10] IB/core: Introduce Work Queue object and its verbs

Yishai Hadas
2016-05-31T16:22:52Z

On 5/30/2016 11:09 PM, Or Gerlitz wrote:
> On Mon, May 23, 2016 at 3:20 PM, Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:
>
>> +int ib_destroy_wq(struct ib_wq *wq)
>> +{
>> + int err;
>> + struct ib_cq *cq = wq->cq;
>> + struct ib_pd *pd = wq->pd;
>> +
>> + if (atomic_read(&wq->usecnt))
>> + return -EBUSY;
>> +
>> + err = wq->device->destroy_wq(wq);
>> + if (!err) {
>> + atomic_dec(&pd->usecnt);
>> + atomic_dec(&cq->usecnt);
>> + }
>> + return err;
>
> by the reverse unwinding principle
>
>> + atomic_inc(&pd->usecnt);
>> + atomic_inc(&wq_attr->cq->usecnt);
>
> -->
>
>> + atomic_dec(&cq->usecnt);
>> + atomic_dec(&pd->usecnt);

The PD and the CQ are two unrelated objects, we are not dealing with
locking order so the reverse principle is not required. Look also at
ib_create/destroy QP for PD/CQ usage, behavior is the same.