From patchwork Mon Feb 25 16:45:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10828905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F56317EF for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CA9E29014 for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 410442B811; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D645C29EE5 for ; Mon, 25 Feb 2019 16:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728563AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58457 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728564AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjtvm003064; Mon, 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjt39017012; Mon, 25 Feb 2019 18:45:55 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id x1PGjtaF017011; Mon, 25 Feb 2019 18:45:55 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, monis@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 1/3] verbs: Introduce implicit ODP support flag Date: Mon, 25 Feb 2019 18:45:26 +0200 Message-Id: <1551113128-16917-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> References: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Moni Shoua Implicit ODP is a special form of ODP where the entire process memory space is registered on demand. This may simplify an application's memory registration scheme. The kernel may or may not support implicit ODP memory registration and the application needs to query the device before using it. Running 'ibv_devinfo -v' will show this capability when it is supported. Relevant manual pages were updated accordingly. Signed-off-by: Moni Shoua Signed-off-by: Yishai Hadas --- libibverbs/examples/devinfo.c | 5 ++++- libibverbs/man/ibv_query_device_ex.3 | 1 + libibverbs/man/ibv_reg_mr.3 | 2 ++ libibverbs/verbs.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c index e928b05..07b4af5 100644 --- a/libibverbs/examples/devinfo.c +++ b/libibverbs/examples/devinfo.c @@ -314,13 +314,16 @@ static void print_odp_trans_caps(uint32_t trans) static void print_odp_caps(const struct ibv_device_attr_ex *device_attr) { - uint64_t unknown_general_caps = ~(IBV_ODP_SUPPORT); + uint64_t unknown_general_caps = ~(IBV_ODP_SUPPORT | + IBV_ODP_SUPPORT_IMPLICIT); const struct ibv_odp_caps *caps = &device_attr->odp_caps; /* general odp caps */ printf("\tgeneral_odp_caps:\n"); if (caps->general_caps & IBV_ODP_SUPPORT) printf("\t\t\t\t\tODP_SUPPORT\n"); + if (caps->general_caps & IBV_ODP_SUPPORT_IMPLICIT) + printf("\t\t\t\t\tODP_SUPPORT_IMPLICIT\n"); if (caps->general_caps & unknown_general_caps) printf("\t\t\t\t\tUnknown flags: 0x%" PRIX64 "\n", caps->general_caps & unknown_general_caps); diff --git a/libibverbs/man/ibv_query_device_ex.3 b/libibverbs/man/ibv_query_device_ex.3 index f99f818..b652884 100644 --- a/libibverbs/man/ibv_query_device_ex.3 +++ b/libibverbs/man/ibv_query_device_ex.3 @@ -52,6 +52,7 @@ struct ibv_odp_caps { enum ibv_odp_general_cap_bits { IBV_ODP_SUPPORT = 1 << 0, /* On demand paging is supported */ + IBV_ODP_SUPPORT_IMPLICIT = 1 << 1, /* Implicit on demand paging is supported */ }; enum ibv_odp_transport_cap_bits { diff --git a/libibverbs/man/ibv_reg_mr.3 b/libibverbs/man/ibv_reg_mr.3 index d9053b1..631e5fe 100644 --- a/libibverbs/man/ibv_reg_mr.3 +++ b/libibverbs/man/ibv_reg_mr.3 @@ -50,6 +50,8 @@ must be set too. .PP Local read access is always enabled for the MR. .PP +To create an implicit ODP MR, IBV_ACCESS_ON_DEMAND should be set, addr should be 0 and length should be SIZE_MAX. +.PP .B ibv_dereg_mr() deregisters the MR .I mr\fR. diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 9561e39..243cd8c 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -218,6 +218,7 @@ struct ibv_odp_caps { enum ibv_odp_general_caps { IBV_ODP_SUPPORT = 1 << 0, + IBV_ODP_SUPPORT_IMPLICIT = 1 << 1, }; struct ibv_tso_caps { From patchwork Mon Feb 25 16:45:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10828903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 379A61575 for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 256B329014 for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17F7B2B811; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5AD829014 for ; Mon, 25 Feb 2019 16:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728406AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58467 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728563AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjtau003067; Mon, 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjtYW017016; Mon, 25 Feb 2019 18:45:55 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id x1PGjtk8017015; Mon, 25 Feb 2019 18:45:55 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, monis@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 2/3] verbs: Fix implicit ODP MR support for 32 bit systems Date: Mon, 25 Feb 2019 18:45:27 +0200 Message-Id: <1551113128-16917-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> References: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Moni Shoua One of the conditions to recognize an implicit ODP MR in kernel is having length of UINT64_MAX. Since the type of the parameter 'length' in ibv_reg_mr() is size_t which is 32 bit long, it is impossible for an application that runs on a 32 bit system to pass this value to the library. To solve this, let ibv_cmd_reg_mr() replace SIZE_MAX with UINT64_MAX when building the command to the kernel. On 64 bit systems this has no effect. On 32 bit systems set a value that the kernel understands as a request for implicit ODP MR. Signed-off-by: Moni Shoua Signed-off-by: Yishai Hadas --- libibverbs/cmd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index ec551e2..7bcaeea 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -336,6 +336,16 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, cmd->start = (uintptr_t) addr; cmd->length = length; + /* On demand access and entire address space means implicit. + * In that case set the value in the command to what kernel expects. + */ + if (access & IBV_ACCESS_ON_DEMAND) { + if (length == SIZE_MAX && addr) + return EINVAL; + if (length == SIZE_MAX) + cmd->length = UINT64_MAX; + } + cmd->hca_va = hca_va; cmd->pd_handle = pd->handle; cmd->access_flags = access; From patchwork Mon Feb 25 16:45:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10828907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAB0A180E for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA02E29014 for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE2752B815; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B34229014 for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58468 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728071AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjtgi003072; Mon, 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjtHg017020; Mon, 25 Feb 2019 18:45:55 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id x1PGjt7n017019; Mon, 25 Feb 2019 18:45:55 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, monis@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 3/3] verbs: Add option to register implicit ODP MR in rc_pingpong Date: Mon, 25 Feb 2019 18:45:28 +0200 Message-Id: <1551113128-16917-4-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> References: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Moni Shoua Implicit ODP MR covers the entire memory space of a process. Add an option (-O) to let test use this type of MR. Signed-off-by: Moni Shoua Reviewed-by: Guy Levi Signed-off-by: Yishai Hadas --- libibverbs/examples/rc_pingpong.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c index 8b2253d..e0f2b70 100644 --- a/libibverbs/examples/rc_pingpong.c +++ b/libibverbs/examples/rc_pingpong.c @@ -57,6 +57,7 @@ enum { static int page_size; static int use_odp; +static int implicit_odp; static int prefetch_mr; static int use_ts; static int validate_buf; @@ -388,6 +389,11 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, fprintf(stderr, "The device isn't ODP capable or does not support RC send and receive with ODP\n"); goto clean_pd; } + if (implicit_odp && + !(attrx.odp_caps.general_caps & IBV_ODP_SUPPORT_IMPLICIT)) { + fprintf(stderr, "The device doesn't support implicit ODP\n"); + goto clean_pd; + } access_flags |= IBV_ACCESS_ON_DEMAND; } @@ -423,8 +429,13 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, } } - ctx->mr = use_dm ? ibv_reg_dm_mr(ctx->pd, ctx->dm, 0, size, access_flags) : - ibv_reg_mr(ctx->pd, ctx->buf, size, access_flags); + if (implicit_odp) { + ctx->mr = ibv_reg_mr(ctx->pd, NULL, SIZE_MAX, access_flags); + } else { + ctx->mr = use_dm ? ibv_reg_dm_mr(ctx->pd, ctx->dm, 0, + size, access_flags) : + ibv_reg_mr(ctx->pd, ctx->buf, size, access_flags); + } if (!ctx->mr) { fprintf(stderr, "Couldn't register MR\n"); @@ -734,6 +745,7 @@ static void usage(const char *argv0) printf(" -e, --events sleep on CQ events (default poll)\n"); printf(" -g, --gid-idx= local port gid index\n"); printf(" -o, --odp use on demand paging\n"); + printf(" -O, --iodp use implicit on demand paging\n"); printf(" -P, --prefetch prefetch an ODP MR\n"); printf(" -t, --ts get CQE with timestamp\n"); printf(" -c, --chk validate received buffer\n"); @@ -782,6 +794,7 @@ int main(int argc, char *argv[]) { .name = "events", .has_arg = 0, .val = 'e' }, { .name = "gid-idx", .has_arg = 1, .val = 'g' }, { .name = "odp", .has_arg = 0, .val = 'o' }, + { .name = "iodp", .has_arg = 0, .val = 'O' }, { .name = "prefetch", .has_arg = 0, .val = 'P' }, { .name = "ts", .has_arg = 0, .val = 't' }, { .name = "chk", .has_arg = 0, .val = 'c' }, @@ -789,7 +802,7 @@ int main(int argc, char *argv[]) {} }; - c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:oPtcj", + c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:oOPtcj", long_options, NULL); if (c == -1) @@ -854,6 +867,10 @@ int main(int argc, char *argv[]) case 'P': prefetch_mr = 1; break; + case 'O': + use_odp = 1; + implicit_odp = 1; + break; case 't': use_ts = 1; break;