This is a note to let you know that I've just added the patch titled ksmbd: smbd: create MR pool to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ksmbd-smbd-create-mr-pool.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From stable+bounces-7648-greg=kroah.com@xxxxxxxxxxxxxxx Mon Dec 18 16:39:20 2023 From: Namjae Jeon <linkinjeon@xxxxxxxxxx> Date: Tue, 19 Dec 2023 00:32:39 +0900 Subject: ksmbd: smbd: create MR pool To: gregkh@xxxxxxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx Cc: smfrench@xxxxxxxxx, Hyunchul Lee <hyc.lee@xxxxxxxxx>, Namjae Jeon <linkinjeon@xxxxxxxxxx>, Steve French <stfrench@xxxxxxxxxxxxx> Message-ID: <20231218153454.8090-20-linkinjeon@xxxxxxxxxx> From: Hyunchul Lee <hyc.lee@xxxxxxxxx> [ Upstream commit c9f189271cff85d5d735e25dfa4bc95952ec12d8 ] Create a memory region pool because rdma_rw_ctx_init() uses memory registration if memory registration yields better performance than using multiple SGE entries. Acked-by: Namjae Jeon <linkinjeon@xxxxxxxxxx> Signed-off-by: Hyunchul Lee <hyc.lee@xxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/ksmbd/transport_rdma.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) --- a/fs/ksmbd/transport_rdma.c +++ b/fs/ksmbd/transport_rdma.c @@ -434,6 +434,7 @@ static void free_transport(struct smb_di if (t->qp) { ib_drain_qp(t->qp); + ib_mr_pool_destroy(t->qp, &t->qp->rdma_mrs); ib_destroy_qp(t->qp); } @@ -1714,7 +1715,9 @@ static int smb_direct_init_params(struct cap->max_send_sge = SMB_DIRECT_MAX_SEND_SGES; cap->max_recv_sge = SMB_DIRECT_MAX_RECV_SGES; cap->max_inline_data = 0; - cap->max_rdma_ctxs = 0; + cap->max_rdma_ctxs = + rdma_rw_mr_factor(device, t->cm_id->port_num, max_pages) * + smb_direct_max_outstanding_rw_ops; return 0; } @@ -1796,6 +1799,7 @@ static int smb_direct_create_qpair(struc { int ret; struct ib_qp_init_attr qp_attr; + int pages_per_rw; t->pd = ib_alloc_pd(t->cm_id->device, 0); if (IS_ERR(t->pd)) { @@ -1843,6 +1847,23 @@ static int smb_direct_create_qpair(struc t->qp = t->cm_id->qp; t->cm_id->event_handler = smb_direct_cm_handler; + pages_per_rw = DIV_ROUND_UP(t->max_rdma_rw_size, PAGE_SIZE) + 1; + if (pages_per_rw > t->cm_id->device->attrs.max_sgl_rd) { + int pages_per_mr, mr_count; + + pages_per_mr = min_t(int, pages_per_rw, + t->cm_id->device->attrs.max_fast_reg_page_list_len); + mr_count = DIV_ROUND_UP(pages_per_rw, pages_per_mr) * + atomic_read(&t->rw_avail_ops); + ret = ib_mr_pool_init(t->qp, &t->qp->rdma_mrs, mr_count, + IB_MR_TYPE_MEM_REG, pages_per_mr, 0); + if (ret) { + pr_err("failed to init mr pool count %d pages %d\n", + mr_count, pages_per_mr); + goto err; + } + } + return 0; err: if (t->qp) { Patches currently in stable-queue which might be from kroah.com@xxxxxxxxxxxxxxx are queue-5.15/ksmbd-remove-unused-parameter-from-smb2_get_name.patch queue-5.15/ksmbd-smbd-handle-multiple-buffer-descriptors.patch queue-5.15/ksmbd-add-mnt_want_write-to-ksmbd-vfs-functions.patch queue-5.15/ksmbd-delete-an-invalid-argument-description-in-smb2_populate_readdir_entry.patch queue-5.15/ksmbd-remove-smb2_buf_length-in-smb2_transform_hdr.patch queue-5.15/ksmbd-fix-smb2_set_info_file-kernel-doc-comment.patch queue-5.15/ksmbd-remove-unused-fields-from-ksmbd_file-struct-definition.patch queue-5.15/ksmbd-set-445-port-to-smbdirect-port-by-default.patch queue-5.15/ksmbd-use-ksmbd_req_buf_next-in-ksmbd_verify_smb_message.patch queue-5.15/ksmbd-set-both-ipv4-and-ipv6-in-fsctl_query_network_interface_info.patch queue-5.15/ksmbd-reduce-descriptor-size-if-remaining-bytes-is-less-than-request-size.patch queue-5.15/ksmbd-fix-smb2_get_name-kernel-doc-comment.patch queue-5.15/ksmbd-register-ksmbd-ib-client-with-ib_register_client.patch queue-5.15/ksmbd-smbd-fix-missing-client-s-memory-region-invalidation.patch queue-5.15/ksmbd-fix-parameter-name-and-comment-mismatch.patch queue-5.15/ksmbd-smbd-call-rdma_accept-under-cm-handler.patch queue-5.15/ksmdb-use-cmd-helper-variable-in-smb2_get_ksmbd_tcon.patch queue-5.15/ksmbd-smbd-change-the-default-maximum-read-write-receive-size.patch queue-5.15/ksmbd-smbd-remove-useless-license-text-when-spdx-license-identifier-is-already-used.patch queue-5.15/ksmbd-check-the-validation-of-pdu_size-in-ksmbd_conn_handler_loop.patch queue-5.15/ksmbd-fix-buffer_check_err-kernel-doc-comment.patch queue-5.15/ksmbd-remove-redundant-flush_workqueue-calls.patch queue-5.15/ksmbd-smbd-create-mr-pool.patch queue-5.15/ksmbd-remove-smb2_buf_length-in-smb2_hdr.patch queue-5.15/ksmbd-remove-md4-leftovers.patch queue-5.15/ksmbd-add-smb-direct-shutdown.patch