All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guoqing Jiang <guoqing.jiang@linux.dev>
To: Leon Romanovsky <leon@kernel.org>, Li Zhijian <lizhijian@fujitsu.com>
Cc: haris.iqbal@ionos.com, jinpu.wang@ionos.com, jgg@ziepe.ca,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH for-next 2/3] RDMA/rtrs: Fix rxe_dealloc_pd warning
Date: Mon, 10 Apr 2023 21:10:19 +0800	[thread overview]
Message-ID: <0d9c57db-bca3-adb4-71fd-7362e4842917@linux.dev> (raw)
In-Reply-To: <20230410120809.GN182481@unreal>



On 4/10/23 20:08, Leon Romanovsky wrote:
> On Mon, Apr 10, 2023 at 06:43:03AM +0000, Li Zhijian wrote:
>> The warning occurs when destroying PD whose reference count is not zero.
>>
>> Precodition: clt_path->s.con_num is 2.
>> So 2 cm connection will be created as below:
>> CPU0                                              CPU1
>> init_conns {                              |
>>    create_cm() // a. con[0] created        |
>>                                            |  a'. rtrs_clt_rdma_cm_handler() {
>>                                            |    rtrs_rdma_addr_resolved()
>>                                            |      create_con_cq_qp(con); << con[0]
>>                                            |  }
>>                                            | in this moment, refcnt of PD was increased to 2+
>>                                            |
>>    create_cm() // b. cid = 1, failed       |
>>      destroy_con_cq_qp()                   |
>>        rtrs_ib_dev_put()                   |
>>          dev_free()                        |
>>            ib_dealloc_pd(dev->ib_pd) << PD |
>>             is destroyed, but refcnt is    |
>>             still greater than 0           |
>> }
>>
>> Simply, Here we can avoid this warning by introducing conn own flag to
>> track if its cleanup should drop the PD.
>>
>> -----------------------------------------------
>>   rnbd_client L597: Mapping device /dev/nvme0n1 on session client, (access_mode: rw, nr_poll_queues: 0)
>>   ------------[ cut here ]------------
>>   WARNING: CPU: 0 PID: 26407 at drivers/infiniband/sw/rxe/rxe_pool.c:256 __rxe_cleanup+0x13a/0x170 [rdma_rxe]
>>   Modules linked in: rpcrdma rdma_ucm ib_iser rnbd_client libiscsi rtrs_client scsi_transport_iscsi rtrs_core rdma_cm iw_cm ib_cm crc32_generic rdma_rxe udp_tunnel ib_uverbs ib_core kmem device_dax nd_pmem dax_pmem nd_
>> vme crc32c_intel fuse nvme_core nfit libnvdimm dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua dm_mirror dm_region_hash dm_log dm_mod
>>   CPU: 0 PID: 26407 Comm: rnbd-client.sh Kdump: loaded Not tainted 6.2.0-rc6-roce-flush+ #53
>>   Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
>>   RIP: 0010:__rxe_cleanup+0x13a/0x170 [rdma_rxe]
>>   Code: 45 84 e4 0f 84 5a ff ff ff 48 89 ef e8 5f 18 71 f9 84 c0 75 90 be c8 00 00 00 48 89 ef e8 be 89 1f fa 85 c0 0f 85 7b ff ff ff <0f> 0b 41 bc ea ff ff ff e9 71 ff ff ff e8 84 7f 1f fa e9 d0 fe ff
>>   RSP: 0018:ffffb09880b6f5f0 EFLAGS: 00010246
>>   RAX: 0000000000000000 RBX: ffff99401f15d6a8 RCX: 0000000000000000
>>   RDX: 0000000000000001 RSI: ffffffffbac8234b RDI: 00000000ffffffff
>>   RBP: ffff99401f15d6d0 R08: 0000000000000001 R09: 0000000000000001
>>   R10: 0000000000002d82 R11: 0000000000000000 R12: 0000000000000001
>>   R13: ffff994101eff208 R14: ffffb09880b6f6a0 R15: 00000000fffffe00
>>   FS:  00007fe113904740(0000) GS:ffff99413bc00000(0000) knlGS:0000000000000000
>>   CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>>   CR2: 00007ff6cde656c8 CR3: 000000001f108004 CR4: 00000000001706f0
>>   DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>>   DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>>   Call Trace:
>>    <TASK>
>>    rxe_dealloc_pd+0x16/0x20 [rdma_rxe]
>>    ib_dealloc_pd_user+0x4b/0x80 [ib_core]
>>    rtrs_ib_dev_put+0x79/0xd0 [rtrs_core]
>>    destroy_con_cq_qp+0x8a/0xa0 [rtrs_client]
>>    init_path+0x1e7/0x9a0 [rtrs_client]
>>    ? __pfx_autoremove_wake_function+0x10/0x10
>>    ? lock_is_held_type+0xd7/0x130
>>    ? rcu_read_lock_sched_held+0x43/0x80
>>    ? pcpu_alloc+0x3dd/0x7d0
>>    ? rtrs_clt_init_stats+0x18/0x40 [rtrs_client]
>>    rtrs_clt_open+0x24f/0x5a0 [rtrs_client]
>>    ? __pfx_rnbd_clt_link_ev+0x10/0x10 [rnbd_client]
>>    rnbd_clt_map_device+0x6a5/0xe10 [rnbd_client]
>>
>> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
>> ---
>>   drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++++
>>   drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 +
>>   2 files changed, 5 insertions(+)
>>
>> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
>> index c2065fc33a56..4c8f42e46e2f 100644
>> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
>> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
>> @@ -1664,6 +1664,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con)
>>   			return -ENOMEM;
>>   		}
>>   		clt_path->s.dev_ref = 1;
>> +		con->has_dev = true;
>>   		query_fast_reg_mode(clt_path);
>>   		wr_limit = clt_path->s.dev->ib_dev->attrs.max_qp_wr;
>>   		/*
>> @@ -1690,6 +1691,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con)
>>   		wr_limit = clt_path->s.dev->ib_dev->attrs.max_qp_wr;
>>   		/* Shared between connections */
>>   		clt_path->s.dev_ref++;
> Without looking in the code, I would expect dev_ref from the line above
> to perform PD protection.

Agreed.

Thanks,
Guoqing

  reply	other threads:[~2023-04-10 13:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10  6:43 [PATCH for-next 0/3] rtrs bugfix and cleanups Li Zhijian
2023-04-10  6:43 ` [PATCH for-next 1/3] RDMA/rtrs: Remove duplicate cq_num assignment Li Zhijian
2023-04-10 13:09   ` Guoqing Jiang
2023-04-19 10:37   ` Jinpu Wang
2023-04-10  6:43 ` [PATCH for-next 2/3] RDMA/rtrs: Fix rxe_dealloc_pd warning Li Zhijian
2023-04-10 12:08   ` Leon Romanovsky
2023-04-10 13:10     ` Guoqing Jiang [this message]
2023-04-11  2:43       ` Zhijian Li (Fujitsu)
2023-04-11 12:26         ` Leon Romanovsky
2023-04-12  1:15           ` Zhijian Li (Fujitsu)
2023-04-13  7:35             ` Guoqing Jiang
2023-04-13  8:12               ` Zhijian Li (Fujitsu)
2023-04-13 13:24                 ` Leon Romanovsky
2023-04-14 15:58                   ` Zhu Yanjun
2023-04-17  2:18                     ` Zhijian Li (Fujitsu)
2023-04-17 18:04                       ` Leon Romanovsky
2023-04-18  7:04                         ` Zhijian Li (Fujitsu)
2023-04-18  7:57                           ` Leon Romanovsky
2023-04-19  9:53                             ` Zhijian Li (Fujitsu)
2023-04-19 13:20                               ` Jinpu Wang
2023-04-20  2:00                                 ` Zhijian Li (Fujitsu)
2023-04-21  1:38                                   ` Zhijian Li (Fujitsu)
2023-04-21  6:49                                     ` Zhijian Li (Fujitsu)
2023-04-21  7:05                                     ` Jinpu Wang
2023-04-14  3:40                 ` Guoqing Jiang
2023-04-14  4:25                   ` Bob Pearson
2023-04-14  5:37                   ` Zhijian Li (Fujitsu)
2023-04-14  6:03                     ` Jinpu Wang
2023-04-14  6:47                       ` Zhijian Li (Fujitsu)
2023-04-14  6:04                     ` Guoqing Jiang
2023-04-14 10:09                       ` Zhijian Li (Fujitsu)
2023-04-17  3:08                         ` Guoqing Jiang
2023-04-18  6:47                           ` Zhijian Li (Fujitsu)
2023-04-10  6:43 ` [PATCH for-next 3/3] RDMA/rtrs: Avoid use-after-free in rtrs_clt_rdma_cm_handler Li Zhijian
2023-04-10 12:10   ` Leon Romanovsky
2023-04-10 13:13   ` Guoqing Jiang
2023-04-11  1:33     ` Zhijian Li (Fujitsu)
2023-04-12  1:15       ` Guoqing Jiang

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=0d9c57db-bca3-adb4-71fd-7362e4842917@linux.dev \
    --to=guoqing.jiang@linux.dev \
    --cc=haris.iqbal@ionos.com \
    --cc=jgg@ziepe.ca \
    --cc=jinpu.wang@ionos.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lizhijian@fujitsu.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.