From: Tom Tucker <tom@opengridcomputing.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 11/17] svcrdma: Use standard Linux lists for context cache
Date: Tue, 06 May 2008 19:49:14 -0500 [thread overview]
Message-ID: <C44666BA.4AFDE%tom@opengridcomputing.com> (raw)
In-Reply-To: <20080506213234.GO13484@fieldses.org>
On 5/6/08 4:32 PM, "J. Bruce Fields" <bfields@fieldses.org> wrote:
> On Fri, May 02, 2008 at 11:28:26AM -0500, Tom Tucker wrote:
>> Replace the one-off linked list implementation used to implement the
>> context cache with the standard Linux list_head lists. Add a cpmtext
>
> cmptext == context?
>
> Some spell checking might help those of us who are already a little lost
> in the alphabet soup here.
>
> Also, I assume that's referring to sc_ctxt_used. It's initialized,
> incremented, and decremented, but doesn't actually seem to be used
> anywhere yet?
There's a patch at the end that added a WARN_ON if it's not zero when the
transport is getting destroyed.
>
> --b.
>
>> counter to catch resource leaks.
>>
>> Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
>>
>> ---
>> include/linux/sunrpc/svc_rdma.h | 5 ++-
>> net/sunrpc/xprtrdma/svc_rdma_transport.c | 47
>> ++++++++++++++++-------------
>> 2 files changed, 29 insertions(+), 23 deletions(-)
>>
>> diff --git a/include/linux/sunrpc/svc_rdma.h
>> b/include/linux/sunrpc/svc_rdma.h
>> index c447c41..7014390 100644
>> --- a/include/linux/sunrpc/svc_rdma.h
>> +++ b/include/linux/sunrpc/svc_rdma.h
>> @@ -72,7 +72,7 @@ extern atomic_t rdma_stat_sq_prod;
>> */
>> struct svc_rdma_op_ctxt {
>> struct svc_rdma_op_ctxt *read_hdr;
>> - struct svc_rdma_op_ctxt *next;
>> + struct list_head free_list;
>> struct xdr_buf arg;
>> struct list_head dto_q;
>> enum ib_wr_opcode wr_op;
>> @@ -104,7 +104,8 @@ struct svcxprt_rdma {
>>
>> struct ib_pd *sc_pd;
>>
>> - struct svc_rdma_op_ctxt *sc_ctxt_head;
>> + atomic_t sc_ctxt_used;
>> + struct list_head sc_ctxt_free;
>> int sc_ctxt_cnt;
>> int sc_ctxt_bump;
>> int sc_ctxt_max;
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c
>> b/net/sunrpc/xprtrdma/svc_rdma_transport.c
>> index c852fd9..c842cc2 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
>> @@ -103,8 +103,8 @@ static int rdma_bump_context_cache(struct svcxprt_rdma
>> *xprt)
>> spin_lock_bh(&xprt->sc_ctxt_lock);
>> if (ctxt) {
>> at_least_one = 1;
>> - ctxt->next = xprt->sc_ctxt_head;
>> - xprt->sc_ctxt_head = ctxt;
>> + INIT_LIST_HEAD(&ctxt->free_list);
>> + list_add(&ctxt->free_list, &xprt->sc_ctxt_free);
>> } else {
>> /* kmalloc failed...give up for now */
>> xprt->sc_ctxt_cnt--;
>> @@ -123,7 +123,7 @@ struct svc_rdma_op_ctxt *svc_rdma_get_context(struct
>> svcxprt_rdma *xprt)
>>
>> while (1) {
>> spin_lock_bh(&xprt->sc_ctxt_lock);
>> - if (unlikely(xprt->sc_ctxt_head == NULL)) {
>> + if (unlikely(list_empty(&xprt->sc_ctxt_free))) {
>> /* Try to bump my cache. */
>> spin_unlock_bh(&xprt->sc_ctxt_lock);
>>
>> @@ -136,12 +136,15 @@ struct svc_rdma_op_ctxt *svc_rdma_get_context(struct
>> svcxprt_rdma *xprt)
>> schedule_timeout_uninterruptible(msecs_to_jiffies(500));
>> continue;
>> }
>> - ctxt = xprt->sc_ctxt_head;
>> - xprt->sc_ctxt_head = ctxt->next;
>> + ctxt = list_entry(xprt->sc_ctxt_free.next,
>> + struct svc_rdma_op_ctxt,
>> + free_list);
>> + list_del_init(&ctxt->free_list);
>> spin_unlock_bh(&xprt->sc_ctxt_lock);
>> ctxt->xprt = xprt;
>> INIT_LIST_HEAD(&ctxt->dto_q);
>> ctxt->count = 0;
>> + atomic_inc(&xprt->sc_ctxt_used);
>> break;
>> }
>> return ctxt;
>> @@ -163,10 +166,11 @@ void svc_rdma_put_context(struct svc_rdma_op_ctxt
>> *ctxt, int free_pages)
>> ctxt->sge[i].addr,
>> ctxt->sge[i].length,
>> ctxt->direction);
>> +
>> spin_lock_bh(&xprt->sc_ctxt_lock);
>> - ctxt->next = xprt->sc_ctxt_head;
>> - xprt->sc_ctxt_head = ctxt;
>> + list_add(&ctxt->free_list, &xprt->sc_ctxt_free);
>> spin_unlock_bh(&xprt->sc_ctxt_lock);
>> + atomic_dec(&xprt->sc_ctxt_used);
>> }
>>
>> /* ib_cq event handler */
>> @@ -409,28 +413,29 @@ static void create_context_cache(struct svcxprt_rdma
>> *xprt,
>> xprt->sc_ctxt_max = ctxt_max;
>> xprt->sc_ctxt_bump = ctxt_bump;
>> xprt->sc_ctxt_cnt = 0;
>> - xprt->sc_ctxt_head = NULL;
>> + atomic_set(&xprt->sc_ctxt_used, 0);
>> +
>> + INIT_LIST_HEAD(&xprt->sc_ctxt_free);
>> for (i = 0; i < ctxt_count; i++) {
>> ctxt = kmalloc(sizeof(*ctxt), GFP_KERNEL);
>> if (ctxt) {
>> - ctxt->next = xprt->sc_ctxt_head;
>> - xprt->sc_ctxt_head = ctxt;
>> + INIT_LIST_HEAD(&ctxt->free_list);
>> + list_add(&ctxt->free_list, &xprt->sc_ctxt_free);
>> xprt->sc_ctxt_cnt++;
>> }
>> }
>> }
>>
>> -static void destroy_context_cache(struct svc_rdma_op_ctxt *ctxt)
>> +static void destroy_context_cache(struct svcxprt_rdma *xprt)
>> {
>> - struct svc_rdma_op_ctxt *next;
>> - if (!ctxt)
>> - return;
>> -
>> - do {
>> - next = ctxt->next;
>> + while (!list_empty(&xprt->sc_ctxt_free)) {
>> + struct svc_rdma_op_ctxt *ctxt;
>> + ctxt = list_entry(xprt->sc_ctxt_free.next,
>> + struct svc_rdma_op_ctxt,
>> + free_list);
>> + list_del_init(&ctxt->free_list);
>> kfree(ctxt);
>> - ctxt = next;
>> - } while (next);
>> + }
>> }
>>
>> static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv,
>> @@ -467,7 +472,7 @@ static struct svcxprt_rdma *rdma_create_xprt(struct
>> svc_serv *serv,
>> reqs +
>> cma_xprt->sc_sq_depth +
>> RPCRDMA_MAX_THREADS + 1); /* max */
>> - if (!cma_xprt->sc_ctxt_head) {
>> + if (list_empty(&cma_xprt->sc_ctxt_free)) {
>> kfree(cma_xprt);
>> return NULL;
>> }
>> @@ -971,7 +976,7 @@ static void svc_rdma_free(struct svc_xprt *xprt)
>> if (rdma->sc_pd && !IS_ERR(rdma->sc_pd))
>> ib_dealloc_pd(rdma->sc_pd);
>>
>> - destroy_context_cache(rdma->sc_ctxt_head);
>> + destroy_context_cache(rdma);
>> kfree(rdma);
>> }
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-05-07 0:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1209745721600-git-send-email-tom@opengridcomputing.com>
2008-05-02 22:37 ` [PATCH 0/17] svcrdma: RDMA transport driver close path cleanup J. Bruce Fields
2008-05-02 23:05 ` Tom Tucker
[not found] ` <12097457211326-git-send-email-tom@opengridcomputing.com>
[not found] ` <1209745721248-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457213375-git-send-email-tom@opengridcomputing.com>
2008-05-05 19:31 ` [PATCH 1/17] svcrdma: Simplify receive buffer posting J. Bruce Fields
[not found] ` <12097457212336-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457212951-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457211122-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223433-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223971-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223635-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223351-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:06 ` [PATCH 2/17] svcrdma: Fix race with dto_tasklet in svc_rdma_send J. Bruce Fields
2008-05-06 2:26 ` Tom Tucker
2008-05-06 21:18 ` J. Bruce Fields
2008-05-07 0:45 ` Tom Tucker
[not found] ` <12097457221640-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:08 ` [PATCH 3/17] svcrdma: Fix return value " J. Bruce Fields
2008-05-06 2:03 ` Tom Tucker
2008-05-06 21:08 ` J. Bruce Fields
[not found] ` <120974572253-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223519-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223927-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457232986-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:41 ` [PATCH 7/17] svcrdma: Fix error handling during listening endpoint creation J. Bruce Fields
2008-05-06 14:48 ` Tom Tucker
2008-05-06 21:22 ` J. Bruce Fields
2008-05-07 0:48 ` Tom Tucker
2008-05-07 1:30 ` J. Bruce Fields
[not found] ` <12097457231736-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:52 ` [PATCH 8/17] svcrdma: Return error from rdma_read_xdr so caller knows to free context J. Bruce Fields
2008-05-06 2:05 ` Tom Tucker
2008-05-06 21:32 ` [PATCH 11/17] svcrdma: Use standard Linux lists for context cache J. Bruce Fields
2008-05-07 0:49 ` Tom Tucker [this message]
2008-05-06 21:46 ` [PATCH 0/17] svcrdma: RDMA transport driver close path cleanup J. Bruce Fields
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=C44666BA.4AFDE%tom@opengridcomputing.com \
--to=tom@opengridcomputing.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.