Re: [PATCH 5/9] IB/core: add a simple MR pool

Bart Van Assche
2016-02-29T22:36:53Z

On 02/29/2016 02:20 PM, Christoph Hellwig wrote:
> +struct ib_mr *ib_mr_pool_get(struct ib_qp *qp, struct list_head *list)
> +{
> + struct ib_mr *mr = NULL;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&qp->mr_lock, flags);
> + mr = list_first_entry_or_null(list, struct ib_mr, qp_entry);
> + if (mr)
> + qp->mrs_used++;
> + spin_unlock_irqrestore(&qp->mr_lock, flags);
> +
> + return mr;
> +}
> +EXPORT_SYMBOL(ib_mr_pool_get);
> +
> +void ib_mr_pool_put(struct ib_qp *qp, struct list_head *list, struct ib_mr *mr)
> +{
> + unsigned long flags;
> +
> + spin_lock_irqsave(&qp->mr_lock, flags);
> + list_add(&mr->qp_entry, list);
> + qp->mrs_used--;
> + spin_unlock_irqrestore(&qp->mr_lock, flags);
> +}
> +EXPORT_SYMBOL(ib_mr_pool_put);

Hi Christoph,

So ib_mr_pool_get() does not remove the returned element from the list
and ib_mr_pool_put() adds it to the list? Why this asymmetry?

Thanks,

Bart.