All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yanjun Zhu <yanjun.zhu@linux.dev>
To: Jason Gunthorpe <jgg@ziepe.ca>, Yanjun Zhu <yanjun.zhu@linux.dev>
Cc: leon@kernel.org, linux-rdma@vger.kernel.org,
	Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCHv3 1/1] RDMA/rxe: Fix a dead lock problem
Date: Thu, 14 Apr 2022 23:13:57 +0800	[thread overview]
Message-ID: <75363d6a-99f2-f61a-0f41-87e641746efa@linux.dev> (raw)
In-Reply-To: <20220414135255.GK64706@ziepe.ca>

在 2022/4/14 21:52, Jason Gunthorpe 写道:
> On Thu, Apr 14, 2022 at 09:01:29PM +0800, Yanjun Zhu wrote:
> 
>>>> Still no, this does almost every allocation - only AH with the
>>>> non-blocking flag set should use this path.
> 
>> To the function ib_send_cm_req, the call chain is as below.
>>
>> ib_send_cm_req --> cm_alloc_priv_msg --> cm_alloc_msg --> rdma_create_ah -->
>> _rdma_create_ah --> rxe_create_ah --> rxe_av_chk_attr -->__rxe_add_to_pool
>>
>> As such, xa_lock_irqsave/irqrestore is selected.
> 
> As I keep saying, only the rxe_create_ah() with the non-blocking flag
> set should use the GFP_ATOMIC. All other paths must use GFP_KERNEL.
> 

Got it. The GFP_ATOMIC/GFP_KERNEL are used in different paths.
rxe_create_ah will use GFP_ATOMIC and others will use GFP_KERNEL.
So the codes should be as below:

-int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem)
+int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem 
*elem, gfp_t gfp)
  {
         int err;
+       unsigned long flags;

         if (WARN_ON(pool->flags & RXE_POOL_ALLOC))
                 return -EINVAL;
@@ -168,10 +170,17 @@ int __rxe_add_to_pool(struct rxe_pool *pool, 
struct rxe_pool_elem *elem)
         elem->obj = (u8 *)elem - pool->elem_offset;
         kref_init(&elem->ref_cnt);

-       xa_lock_irq(&pool->xa);
-       err = __xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit,
-                               &pool->next, GFP_ATOMIC);
-       xa_unlock_irq(&pool->xa);
+       if (gfp == GFP_ATOMIC) { /* for rxe_create_ah */
+               xa_lock_irqsave(&pool->xa, flags);
+               err = __xa_alloc_cyclic(&pool->xa, &elem->index, elem, 
pool->limit,
+                                       &pool->next, GFP_ATOMIC);
+               xa_unlock_irqrestore(&pool->xa, flags);
+       } else if (gfp == GFP_KERNEL) {
+               xa_lock_irq(&pool->xa);
+               err = __xa_alloc_cyclic(&pool->xa, &elem->index, elem, 
pool->limit,
+                                       &pool->next, GFP_KERNEL);
+               xa_unlock_irq(&pool->xa);
+       }
         if (err)
                 goto err_cnt;

Please commnet.

Zhu Yanjun

> Jason


  reply	other threads:[~2022-04-14 16:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  7:42 [PATCHv3 1/1] RDMA/rxe: Fix a dead lock problem yanjun.zhu
2022-04-13  0:45 ` Jason Gunthorpe
2022-04-13 14:50   ` Yanjun Zhu
2022-04-14 13:01     ` Yanjun Zhu
2022-04-14 13:52       ` Jason Gunthorpe
2022-04-14 15:13         ` Yanjun Zhu [this message]
2022-04-14 16:12           ` Leon Romanovsky
2022-04-15  2:35             ` Yanjun Zhu
2022-04-14 16:18           ` Jason Gunthorpe
2022-04-15  2:36             ` Yanjun Zhu

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=75363d6a-99f2-f61a-0f41-87e641746efa@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=yi.zhang@redhat.com \
    /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.