From: Simon Derr <simon.derr@bull.net>
To: netdev@vger.kernel.org
Cc: simon.derr@bull.net, ericvh@gmail.com
Subject: [PATCH 06/10] 9P/RDMA: Use a semaphore to protect the RQ
Date: Tue, 2 Jul 2013 15:11:20 +0200 [thread overview]
Message-ID: <1372770684-25573-7-git-send-email-simon.derr@bull.net> (raw)
In-Reply-To: <1372770684-25573-1-git-send-email-simon.derr@bull.net>
The current code keeps track of the number of buffers posted in the RQ,
and will prevent it from overflowing. But it does so by simply dropping
post requests (And leaking memory in the process).
When this happens there will actually be too few buffers posted, and
soon the 9P server will complain about 'RNR retry counter exceeded'
errors.
Instead, use a semaphore, and block until the RQ is ready for another
buffer to be posted.
Signed-off-by: Simon Derr <simon.derr@bull.net>
---
net/9p/trans_rdma.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 274a9c1..ad8dc33 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -73,7 +73,7 @@
* @sq_depth: The depth of the Send Queue
* @sq_sem: Semaphore for the SQ
* @rq_depth: The depth of the Receive Queue.
- * @rq_count: Count of requests in the Receive Queue.
+ * @rq_sem: Semaphore for the RQ
* @addr: The remote peer's address
* @req_lock: Protects the active request list
* @cm_done: Completion event for connection management tracking
@@ -98,7 +98,7 @@ struct p9_trans_rdma {
int sq_depth;
struct semaphore sq_sem;
int rq_depth;
- atomic_t rq_count;
+ struct semaphore rq_sem;
struct sockaddr_in addr;
spinlock_t req_lock;
@@ -341,8 +341,8 @@ static void cq_comp_handler(struct ib_cq *cq, void *cq_context)
switch (c->wc_op) {
case IB_WC_RECV:
- atomic_dec(&rdma->rq_count);
handle_recv(client, rdma, c, wc.status, wc.byte_len);
+ up(&rdma->rq_sem);
break;
case IB_WC_SEND:
@@ -441,12 +441,14 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
* outstanding request, so we must keep a count to avoid
* overflowing the RQ.
*/
- if (atomic_inc_return(&rdma->rq_count) <= rdma->rq_depth) {
- err = post_recv(client, rpl_context);
- if (err)
- goto err_free1;
- } else
- atomic_dec(&rdma->rq_count);
+ if (down_interruptible(&rdma->rq_sem))
+ goto error; /* FIXME : -EINTR instead */
+
+ err = post_recv(client, rpl_context);
+ if (err) {
+ p9_debug(P9_DEBUG_FCALL, "POST RECV failed\n");
+ goto err_free1;
+ }
/* remove posted receive buffer from request structure */
req->rc = NULL;
@@ -537,7 +539,7 @@ static struct p9_trans_rdma *alloc_rdma(struct p9_rdma_opts *opts)
spin_lock_init(&rdma->req_lock);
init_completion(&rdma->cm_done);
sema_init(&rdma->sq_sem, rdma->sq_depth);
- atomic_set(&rdma->rq_count, 0);
+ sema_init(&rdma->rq_sem, rdma->rq_depth);
return rdma;
}
--
1.7.2.2
next prev parent reply other threads:[~2013-07-02 13:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 13:11 [PATCH 00/10] Improve 9P/RDMA Simon Derr
2013-07-02 13:11 ` [PATCH 01/10] 9P: Fix fcall allocation for rdma Simon Derr
2013-07-02 13:11 ` [PATCH 02/10] 9P/RDMA: rdma_request() needs not allocate req->rc Simon Derr
2013-07-02 13:11 ` [PATCH 03/10] 9pnet: refactor struct p9_fcall alloc code Simon Derr
2013-07-02 16:40 ` Sergei Shtylyov
2013-07-02 13:11 ` [PATCH 04/10] 9P/RDMA: increase P9_RDMA_MAXSIZE to 1MB Simon Derr
2013-07-02 13:11 ` [PATCH 05/10] 9P/RDMA: Protect against duplicate replies Simon Derr
2013-07-02 13:11 ` Simon Derr [this message]
2013-07-02 13:11 ` [PATCH 07/10] 9P/RDMA: Do not free req->rc in error handling in rdma_request() Simon Derr
2013-07-02 13:11 ` [PATCH 08/10] 9P/RDMA: Improve error handling in rdma_request Simon Derr
2013-07-02 13:11 ` [PATCH 09/10] 9P/RDMA: count posted buffers without a pending request Simon Derr
2013-07-02 13:11 ` [PATCH 10/10] 9P: Add cancelled() to the transport functions Simon Derr
2013-07-02 16:49 ` Sergei Shtylyov
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=1372770684-25573-7-git-send-email-simon.derr@bull.net \
--to=simon.derr@bull.net \
--cc=ericvh@gmail.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).