From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Christoph Hellwig <hch@lst.de>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Cc: "swise@opengridcomputing.com" <swise@opengridcomputing.com>,
"sagig@mellanox.com" <sagig@mellanox.com>,
"target-devel@vger.kernel.org" <target-devel@vger.kernel.org>
Subject: Re: [PATCH 5/9] IB/core: add a simple MR pool
Date: Tue, 1 Mar 2016 11:12:09 -0800 [thread overview]
Message-ID: <56D5E989.9010006@sandisk.com> (raw)
In-Reply-To: <1456784410-20166-6-git-send-email-hch@lst.de>
On 02/29/2016 02:20 PM, Christoph Hellwig wrote:
> +int ib_mr_pool_init(struct ib_qp *qp, struct list_head *list, int nr,
> + enum ib_mr_type type, u32 max_num_sg)
> +{
> + struct ib_mr *mr;
> + unsigned long flags;
> + int ret, i;
> +
> + for (i = 0; i < nr; i++) {
> + mr = ib_alloc_mr(qp->pd, type, max_num_sg);
> + if (IS_ERR(mr)) {
> + ret = PTR_ERR(mr);
> + goto out;
> + }
> +
> + spin_lock_irqsave(&qp->mr_lock, flags);
> + list_add_tail(&mr->qp_entry, list);
> + spin_unlock_irqrestore(&qp->mr_lock, flags);
> + }
> +
> + return 0;
> +out:
> + ib_mr_pool_destroy(qp, list);
> + return ret;
> +}
> +EXPORT_SYMBOL(ib_mr_pool_init);
> +
> +void ib_mr_pool_destroy(struct ib_qp *qp, struct list_head *list)
> +{
> + struct ib_mr *mr;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&qp->mr_lock, flags);
> + while (!list_empty(list)) {
> + mr = list_first_entry(list, struct ib_mr, qp_entry);
> + list_del(&mr->qp_entry);
> +
> + spin_unlock_irqrestore(&qp->mr_lock, flags);
> + ib_dereg_mr(mr);
> + spin_lock_irqsave(&qp->mr_lock, flags);
> + }
> + spin_unlock_irqrestore(&qp->mr_lock, flags);
> +}
> +EXPORT_SYMBOL(ib_mr_pool_destroy);
Hello Christoph,
A second question about this patch: why do we need locking in
ib_mr_pool_init() and ib_mr_pool_destroy()? Calling ib_mr_pool_get() or
ib_mr_pool_put() while one of these two functions is in progress is a
bug (race condition). Can the locking be left out from these two functions?
Bart.
next prev parent reply other threads:[~2016-03-01 19:12 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-29 22:20 generic RDMA READ/WRITE API V2 Christoph Hellwig
[not found] ` <1456784410-20166-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2016-02-29 22:20 ` [PATCH 1/9] IB/cma: pass the port number to ib_create_qp Christoph Hellwig
2016-02-29 22:20 ` [PATCH 2/9] IB/core: allow passing mapping an offset into the SG in ib_map_mr_sg Christoph Hellwig
2016-02-29 23:13 ` Bart Van Assche
2016-03-01 6:50 ` Christoph Hellwig
2016-02-29 22:20 ` [PATCH 4/9] IB/core: refactor ib_create_qp Christoph Hellwig
2016-02-29 22:20 ` [PATCH 3/9] IB/core: add a helper to check for READ WITH INVALIDATE support Christoph Hellwig
2016-03-01 9:02 ` Sagi Grimberg
2016-03-01 9:14 ` Christoph Hellwig
[not found] ` <56D55ABA.6070007-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-03-01 15:45 ` Steve Wise
2016-03-03 13:10 ` 'Christoph Hellwig'
2016-03-03 15:31 ` Steve Wise
2016-03-03 17:53 ` Jason Gunthorpe
[not found] ` <20160303175301.GD15387-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-03-03 17:56 ` 'Christoph Hellwig'
2016-02-29 22:20 ` [PATCH 5/9] IB/core: add a simple MR pool Christoph Hellwig
2016-02-29 22:36 ` Bart Van Assche
2016-03-01 6:48 ` Christoph Hellwig
2016-03-01 19:12 ` Bart Van Assche [this message]
[not found] ` <56D5E989.9010006-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-03-02 9:14 ` Christoph Hellwig
2016-02-29 22:20 ` [PATCH 6/9] IB/core: add a need_inval flag to struct ib_mr Christoph Hellwig
2016-02-29 22:40 ` Bart Van Assche
[not found] ` <56D4C8EC.8020805-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-03-01 7:09 ` Christoph Hellwig
2016-02-29 22:20 ` [PATCH 7/9] IB/core: generic RDMA READ/WRITE API Christoph Hellwig
[not found] ` <1456784410-20166-8-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2016-02-29 22:28 ` Steve Wise
[not found] ` <56D4C615.5010202-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2016-03-01 7:21 ` Christoph Hellwig
2016-03-01 9:00 ` Sagi Grimberg
[not found] ` <56D55A1B.6030902-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-03-01 9:13 ` Christoph Hellwig
[not found] ` <20160301091338.GA2208-jcswGhMUV9g@public.gmane.org>
2016-03-01 9:19 ` Sagi Grimberg
[not found] ` <56D55EB3.2050707-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-03-01 15:47 ` Steve Wise
2016-03-01 15:44 ` Steve Wise
2016-02-29 23:12 ` Bart Van Assche
2016-03-01 6:50 ` Christoph Hellwig
2016-03-03 10:53 ` Sagi Grimberg
2016-03-03 12:02 ` Christoph Hellwig
[not found] ` <20160303120209.GC20543-jcswGhMUV9g@public.gmane.org>
2016-03-03 12:08 ` Sagi Grimberg
2016-03-03 12:22 ` Christoph Hellwig
2016-03-03 12:54 ` Sagi Grimberg
[not found] ` <56D8293C.1050306-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-03-03 15:29 ` Steve Wise
2016-03-03 18:05 ` 'Christoph Hellwig'
2016-02-29 22:20 ` [PATCH 8/9] target: enhance and export target_alloc_sgl/target_free_sgl Christoph Hellwig
2016-02-29 22:20 ` [PATCH 9/9] IB/srpt: convert to the generic RDMA READ/WRITE API Christoph Hellwig
2016-03-01 21:38 ` Bart Van Assche
2016-03-02 9:14 ` Christoph Hellwig
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=56D5E989.9010006@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=hch@lst.de \
--cc=linux-rdma@vger.kernel.org \
--cc=sagig@mellanox.com \
--cc=swise@opengridcomputing.com \
--cc=target-devel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox