From patchwork Wed Jul 10 20:32:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Squyres X-Patchwork-Id: 2825906 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F594C0AB2 for ; Wed, 10 Jul 2013 20:32:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6A272018E for ; Wed, 10 Jul 2013 20:32:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 791522018C for ; Wed, 10 Jul 2013 20:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754854Ab3GJUcm (ORCPT ); Wed, 10 Jul 2013 16:32:42 -0400 Received: from mtv-iport-1.cisco.com ([173.36.130.12]:62808 "EHLO mtv-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754674Ab3GJUcl (ORCPT ); Wed, 10 Jul 2013 16:32:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=7810; q=dns/txt; s=iport; t=1373488361; x=1374697961; h=from:to:cc:subject:date:message-id; bh=rIjYot+B66hYaWhH12HY2SJA6y7/JMS2LUMVsvuuizM=; b=AT6wCJyOVxzgzuoAAzoLYuEIj284yTA5xG3oojxFe/lifobfREmgUvlS mIknKY1Iuai3mNqFLm+HnWx371RLUQvNpuduVCVUH2KgpdvfhH7xEES5d vg22IXQKzl240lnYJ5opFN1RzoyapEKae2TOW12E0BBvbk0F1yCZHCBf0 c=; X-IronPort-AV: E=Sophos;i="4.87,1038,1363132800"; d="scan'208";a="82630881" Received: from mtv-core-1.cisco.com ([171.68.58.6]) by mtv-iport-1.cisco.com with ESMTP; 10 Jul 2013 20:32:41 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by mtv-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id r6AKWerS002058; Wed, 10 Jul 2013 20:32:40 GMT Received: by cisco.com (Postfix, from userid 182726) id 59F1820F2003; Wed, 10 Jul 2013 13:32:40 -0700 (PDT) From: Jeff Squyres To: linux-rdma@vger.kernel.org Cc: Jeff Squyres Subject: [PATCH] libibverbs: Add the use of IBV_SEND_INLINE to example pingpong programs Date: Wed, 10 Jul 2013 13:32:39 -0700 Message-Id: <1373488359-11413-1-git-send-email-jsquyres@cisco.com> X-Mailer: git-send-email 1.8.2.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-14.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the send size is less than the cap.max_inline_data reported by the qp, use the IBV_SEND_INLINE flag. This now only shows the example of using ibv_query_qp(), it also reduces the latency time shown by the pingpong programs when the sends can be inlined. Signed-off-by: Jeff Squyres --- examples/rc_pingpong.c | 18 +++++++++++++----- examples/srq_pingpong.c | 19 +++++++++++++------ examples/uc_pingpong.c | 17 ++++++++++++----- examples/ud_pingpong.c | 18 +++++++++++++----- 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/examples/rc_pingpong.c b/examples/rc_pingpong.c index 15494a1..a8637a5 100644 --- a/examples/rc_pingpong.c +++ b/examples/rc_pingpong.c @@ -65,6 +65,7 @@ struct pingpong_context { struct ibv_qp *qp; void *buf; int size; + int send_flags; int rx_depth; int pending; struct ibv_port_attr portinfo; @@ -319,8 +320,9 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, if (!ctx) return NULL; - ctx->size = size; - ctx->rx_depth = rx_depth; + ctx->size = size; + ctx->send_flags = IBV_SEND_SIGNALED; + ctx->rx_depth = rx_depth; ctx->buf = memalign(page_size, size); if (!ctx->buf) { @@ -367,7 +369,8 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, } { - struct ibv_qp_init_attr attr = { + struct ibv_qp_attr attr; + struct ibv_qp_init_attr init_attr = { .send_cq = ctx->cq, .recv_cq = ctx->cq, .cap = { @@ -379,11 +382,16 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, .qp_type = IBV_QPT_RC }; - ctx->qp = ibv_create_qp(ctx->pd, &attr); + ctx->qp = ibv_create_qp(ctx->pd, &init_attr); if (!ctx->qp) { fprintf(stderr, "Couldn't create QP\n"); goto clean_cq; } + + ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); + if (init_attr.cap.max_inline_data >= size) { + ctx->send_flags |= IBV_SEND_INLINE; + } } { @@ -508,7 +516,7 @@ static int pp_post_send(struct pingpong_context *ctx) .sg_list = &list, .num_sge = 1, .opcode = IBV_WR_SEND, - .send_flags = IBV_SEND_SIGNALED, + .send_flags = ctx->send_flags, }; struct ibv_send_wr *bad_wr; diff --git a/examples/srq_pingpong.c b/examples/srq_pingpong.c index 6e00f8c..552a144 100644 --- a/examples/srq_pingpong.c +++ b/examples/srq_pingpong.c @@ -68,6 +68,7 @@ struct pingpong_context { struct ibv_qp *qp[MAX_QP]; void *buf; int size; + int send_flags; int num_qp; int rx_depth; int pending[MAX_QP]; @@ -350,9 +351,10 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, if (!ctx) return NULL; - ctx->size = size; - ctx->num_qp = num_qp; - ctx->rx_depth = rx_depth; + ctx->size = size; + ctx->send_flags = IBV_SEND_SIGNALED; + ctx->num_qp = num_qp; + ctx->rx_depth = rx_depth; ctx->buf = memalign(page_size, size); if (!ctx->buf) { @@ -413,7 +415,8 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, } for (i = 0; i < num_qp; ++i) { - struct ibv_qp_init_attr attr = { + struct ibv_qp_attr attr; + struct ibv_qp_init_attr init_attr = { .send_cq = ctx->cq, .recv_cq = ctx->cq, .srq = ctx->srq, @@ -424,11 +427,15 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, .qp_type = IBV_QPT_RC }; - ctx->qp[i] = ibv_create_qp(ctx->pd, &attr); + ctx->qp[i] = ibv_create_qp(ctx->pd, &init_attr); if (!ctx->qp[i]) { fprintf(stderr, "Couldn't create QP[%d]\n", i); goto clean_qps; } + ibv_query_qp(ctx->qp[i], &attr, IBV_QP_CAP, &init_attr); + if (init_attr.cap.max_inline_data >= size) { + ctx->send_flags |= IBV_SEND_INLINE; + } } for (i = 0; i < num_qp; ++i) { @@ -568,7 +575,7 @@ static int pp_post_send(struct pingpong_context *ctx, int qp_index) .sg_list = &list, .num_sge = 1, .opcode = IBV_WR_SEND, - .send_flags = IBV_SEND_SIGNALED, + .send_flags = ctx->send_flags, }; struct ibv_send_wr *bad_wr; diff --git a/examples/uc_pingpong.c b/examples/uc_pingpong.c index 52c6c28..58cc3cc 100644 --- a/examples/uc_pingpong.c +++ b/examples/uc_pingpong.c @@ -65,6 +65,7 @@ struct pingpong_context { struct ibv_qp *qp; void *buf; int size; + int send_flags; int rx_depth; int pending; struct ibv_port_attr portinfo; @@ -307,8 +308,9 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, if (!ctx) return NULL; - ctx->size = size; - ctx->rx_depth = rx_depth; + ctx->size = size; + ctx->send_flags = IBV_SEND_SIGNALED; + ctx->rx_depth = rx_depth; ctx->buf = memalign(page_size, size); if (!ctx->buf) { @@ -355,7 +357,8 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, } { - struct ibv_qp_init_attr attr = { + struct ibv_qp_attr attr; + struct ibv_qp_init_attr init_attr = { .send_cq = ctx->cq, .recv_cq = ctx->cq, .cap = { @@ -367,11 +370,15 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, .qp_type = IBV_QPT_UC }; - ctx->qp = ibv_create_qp(ctx->pd, &attr); + ctx->qp = ibv_create_qp(ctx->pd, &init_attr); if (!ctx->qp) { fprintf(stderr, "Couldn't create QP\n"); goto clean_cq; } + ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); + if (init_attr.cap.max_inline_data >= size) { + ctx->send_flags |= IBV_SEND_INLINE; + } } { @@ -496,7 +503,7 @@ static int pp_post_send(struct pingpong_context *ctx) .sg_list = &list, .num_sge = 1, .opcode = IBV_WR_SEND, - .send_flags = IBV_SEND_SIGNALED, + .send_flags = ctx->send_flags, }; struct ibv_send_wr *bad_wr; diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c index 21c551d..9102241 100644 --- a/examples/ud_pingpong.c +++ b/examples/ud_pingpong.c @@ -66,6 +66,7 @@ struct pingpong_context { struct ibv_ah *ah; void *buf; int size; + int send_flags; int rx_depth; int pending; struct ibv_port_attr portinfo; @@ -305,8 +306,9 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, if (!ctx) return NULL; - ctx->size = size; - ctx->rx_depth = rx_depth; + ctx->size = size; + ctx->send_flags = IBV_SEND_SIGNALED; + ctx->rx_depth = rx_depth; ctx->buf = memalign(page_size, size + 40); if (!ctx->buf) { @@ -368,7 +370,8 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, } { - struct ibv_qp_init_attr attr = { + struct ibv_qp_attr attr; + struct ibv_qp_init_attr init_attr = { .send_cq = ctx->cq, .recv_cq = ctx->cq, .cap = { @@ -380,11 +383,16 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, .qp_type = IBV_QPT_UD, }; - ctx->qp = ibv_create_qp(ctx->pd, &attr); + ctx->qp = ibv_create_qp(ctx->pd, &init_attr); if (!ctx->qp) { fprintf(stderr, "Couldn't create QP\n"); goto clean_cq; } + + ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); + if (init_attr.cap.max_inline_data >= size) { + ctx->send_flags |= IBV_SEND_INLINE; + } } { @@ -514,7 +522,7 @@ static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn) .sg_list = &list, .num_sge = 1, .opcode = IBV_WR_SEND, - .send_flags = IBV_SEND_SIGNALED, + .send_flags = ctx->send_flags, .wr = { .ud = { .ah = ctx->ah,