svcrdma: Replace GFP_KERNEL in a loop with GFP_NOFAIL
authorChuck Lever <chuck.lever@oracle.com>
Thu, 4 Jun 2015 15:21:20 +0000 (11:21 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Thu, 4 Jun 2015 20:56:00 +0000 (16:56 -0400)
At the 2015 LSF/MM, it was requested that memory allocation
call sites that request GFP_KERNEL allocations in a loop should be
annotated with __GFP_NOFAIL.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
include/linux/sunrpc/svc_rdma.h
net/sunrpc/xprtrdma/svc_rdma_sendto.c
net/sunrpc/xprtrdma/svc_rdma_transport.c

index c03ca0a1b743f0451dde2a7f33cc03aad5e0f98f..d26384b2212603a1a03428163778bba77d521c01 100644 (file)
@@ -211,7 +211,6 @@ extern int svc_rdma_sendto(struct svc_rqst *);
 extern int svc_rdma_send(struct svcxprt_rdma *, struct ib_send_wr *);
 extern void svc_rdma_send_error(struct svcxprt_rdma *, struct rpcrdma_msg *,
                                enum rpcrdma_errcode);
-struct page *svc_rdma_get_page(void);
 extern int svc_rdma_post_recv(struct svcxprt_rdma *);
 extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
 extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
index 109e9670be8c9e50f84889cf1baa99eb7ed1dafc..d25cd430f9ffbebc6fdb2a35e662a0ddf51c3cae 100644 (file)
@@ -517,7 +517,7 @@ int svc_rdma_sendto(struct svc_rqst *rqstp)
        inline_bytes = rqstp->rq_res.len;
 
        /* Create the RDMA response header */
-       res_page = svc_rdma_get_page();
+       res_page = alloc_page(GFP_KERNEL | __GFP_NOFAIL);
        rdma_resp = page_address(res_page);
        reply_ary = svc_rdma_get_reply_array(rdma_argp);
        if (reply_ary)
index be084938e3fff308be1a2a7919fa3d6abae8d245..1ed4740ff0b5971f56d6eebc4f47b73500cb48d3 100644 (file)
@@ -99,12 +99,8 @@ struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt)
 {
        struct svc_rdma_op_ctxt *ctxt;
 
-       while (1) {
-               ctxt = kmem_cache_alloc(svc_rdma_ctxt_cachep, GFP_KERNEL);
-               if (ctxt)
-                       break;
-               schedule_timeout_uninterruptible(msecs_to_jiffies(500));
-       }
+       ctxt = kmem_cache_alloc(svc_rdma_ctxt_cachep,
+                               GFP_KERNEL | __GFP_NOFAIL);
        ctxt->xprt = xprt;
        INIT_LIST_HEAD(&ctxt->dto_q);
        ctxt->count = 0;
@@ -156,12 +152,8 @@ void svc_rdma_put_context(struct svc_rdma_op_ctxt *ctxt, int free_pages)
 struct svc_rdma_req_map *svc_rdma_get_req_map(void)
 {
        struct svc_rdma_req_map *map;
-       while (1) {
-               map = kmem_cache_alloc(svc_rdma_map_cachep, GFP_KERNEL);
-               if (map)
-                       break;
-               schedule_timeout_uninterruptible(msecs_to_jiffies(500));
-       }
+       map = kmem_cache_alloc(svc_rdma_map_cachep,
+                              GFP_KERNEL | __GFP_NOFAIL);
        map->count = 0;
        return map;
 }
@@ -490,18 +482,6 @@ static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv,
        return cma_xprt;
 }
 
-struct page *svc_rdma_get_page(void)
-{
-       struct page *page;
-
-       while ((page = alloc_page(GFP_KERNEL)) == NULL) {
-               /* If we can't get memory, wait a bit and try again */
-               printk(KERN_INFO "svcrdma: out of memory...retrying in 1s\n");
-               schedule_timeout_uninterruptible(msecs_to_jiffies(1000));
-       }
-       return page;
-}
-
 int svc_rdma_post_recv(struct svcxprt_rdma *xprt)
 {
        struct ib_recv_wr recv_wr, *bad_recv_wr;
@@ -520,7 +500,7 @@ int svc_rdma_post_recv(struct svcxprt_rdma *xprt)
                        pr_err("svcrdma: Too many sges (%d)\n", sge_no);
                        goto err_put_ctxt;
                }
-               page = svc_rdma_get_page();
+               page = alloc_page(GFP_KERNEL | __GFP_NOFAIL);
                ctxt->pages[sge_no] = page;
                pa = ib_dma_map_page(xprt->sc_cm_id->device,
                                     page, 0, PAGE_SIZE,
@@ -1323,7 +1303,7 @@ void svc_rdma_send_error(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rmsgp,
        int length;
        int ret;
 
-       p = svc_rdma_get_page();
+       p = alloc_page(GFP_KERNEL | __GFP_NOFAIL);
        va = page_address(p);
 
        /* XDR encode error */
This page took 0.028097 seconds and 5 git commands to generate.