From patchwork Tue Jun 25 20:57:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 11016399 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 B58B276 for ; Tue, 25 Jun 2019 20:58:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5894205FD for ; Tue, 25 Jun 2019 20:58:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 991B028498; Tue, 25 Jun 2019 20:58:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 C6ED2205FD for ; Tue, 25 Jun 2019 20:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726412AbfFYU6B (ORCPT ); Tue, 25 Jun 2019 16:58:01 -0400 Received: from mail-eopbgr130058.outbound.protection.outlook.com ([40.107.13.58]:59766 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726434AbfFYU6A (ORCPT ); Tue, 25 Jun 2019 16:58:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6o/7Kj6+YJJBtOijfWbHvD/64KFDUh1594KHoNYwtpM=; b=YQdQD5Y7d8chyHpFFzfRXsMx4+9RSL3q2ZUiSo7LRaV6X6PPNVrlf++mpri9oVZ7qWGEzWYP/iRhoj06zCoqVdcJAAklNTBeP/x1RSN+6wXpYJay2UQQn7t4PFfJ64VkdV388BXLm//5VNqVLFwSJTKl0lKgTWvmieWC3SXQrwY= Received: from DB6PR0501MB2759.eurprd05.prod.outlook.com (10.172.227.7) by DB6PR0501MB2663.eurprd05.prod.outlook.com (10.172.225.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Tue, 25 Jun 2019 20:57:54 +0000 Received: from DB6PR0501MB2759.eurprd05.prod.outlook.com ([fe80::a901:6951:59de:3278]) by DB6PR0501MB2759.eurprd05.prod.outlook.com ([fe80::a901:6951:59de:3278%2]) with mapi id 15.20.2008.014; Tue, 25 Jun 2019 20:57:54 +0000 From: Saeed Mahameed To: "David S. Miller" , Doug Ledford , Jason Gunthorpe CC: Leon Romanovsky , Or Gerlitz , Sagi Grimberg , Tal Gilboa , "netdev@vger.kernel.org" , "linux-rdma@vger.kernel.org" , Yamin Friedman , Max Gurtovoy , Saeed Mahameed Subject: [for-next V2 10/10] RDMA/core: Provide RDMA DIM support for ULPs Thread-Topic: [for-next V2 10/10] RDMA/core: Provide RDMA DIM support for ULPs Thread-Index: AQHVK5ioV7jWhjhFdkWcYTZnrJFAAw== Date: Tue, 25 Jun 2019 20:57:54 +0000 Message-ID: <20190625205701.17849-11-saeedm@mellanox.com> References: <20190625205701.17849-1-saeedm@mellanox.com> In-Reply-To: <20190625205701.17849-1-saeedm@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.21.0 x-originating-ip: [209.116.155.178] x-clientproxiedby: BYAPR03CA0025.namprd03.prod.outlook.com (2603:10b6:a02:a8::38) To DB6PR0501MB2759.eurprd05.prod.outlook.com (2603:10a6:4:84::7) authentication-results: spf=none (sender IP is ) smtp.mailfrom=saeedm@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a3e11a0a-c2a2-41bb-c128-08d6f9afcb0b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:DB6PR0501MB2663; x-ms-traffictypediagnostic: DB6PR0501MB2663: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:439; x-forefront-prvs: 0079056367 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(396003)(366004)(136003)(346002)(376002)(51234002)(199004)(189003)(66446008)(14454004)(66476007)(73956011)(64756008)(36756003)(66946007)(71200400001)(1076003)(66556008)(52116002)(76176011)(14444005)(256004)(99286004)(6486002)(476003)(386003)(26005)(8676002)(446003)(102836004)(478600001)(2616005)(6506007)(8936002)(6116002)(3846002)(186003)(5660300002)(81166006)(6636002)(86362001)(81156014)(6436002)(110136005)(66066001)(486006)(50226002)(316002)(2906002)(4326008)(53936002)(25786009)(305945005)(68736007)(107886003)(7736002)(71190400001)(54906003)(11346002)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0501MB2663;H:DB6PR0501MB2759.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: fjg1CQe/GI2OebsU8DppFI4OjZTVKqfT09FivOUodOph1kwdl5qdqtkj1BnHVvorkZzeGXyMxPX36wVJYj1hLeCNK0SElhhtaNVqU9AN8eNprI8P3smY5Fo3JJuvWY2Z7abSGbM3O+lILa0WjZLDGLKuo9M8sS6p8PCsZ8AS6yb/YebdCAThsxUUaYrxYXqkPbL/0rwt9I2/COm1InEqS2uTQW1GyVC2sewYVahxnraSxpNP5rF/w2J13dGvU3rWbf9iFdAzzImGieiBBEEA+P1n7LlnTpOwyJUhcI+WPl4E2vh6SHbSlXdDhbf+7C6FMbpuv/cvqHujIJYBPG7IhO5elaUc343wjkoz+cnbKVpKPcXCKWCYVrAtjtlz77NxTId+TVgDgggjWy7EEdKf2XBHK6NOO3uVHPuRr1S6tz4= MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3e11a0a-c2a2-41bb-c128-08d6f9afcb0b X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2019 20:57:54.3824 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: saeedm@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2663 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: Yamin Friedman Added the interface in the infiniband driver that applies the rdma_dim adaptive moderation. There is now a special function for allocating an ib_cq that uses rdma_dim. Performance improvement (ConnectX-5 100GbE, x86) running FIO benchmark over NVMf between two equal end-hosts with 56 cores across a Mellanox switch using null_blk device: READS without DIM: blk size | BW | IOPS | 99th percentile latency | 99.99th latency 512B | 3.8GiB/s | 7.7M | 1401 usec | 2442 usec 4k | 7.0GiB/s | 1.8M | 4817 usec | 6587 usec 64k | 10.7GiB/s| 175k | 9896 usec | 10028 usec IO WRITES without DIM: blk size | BW | IOPS | 99th percentile latency | 99.99th latency 512B | 3.6GiB/s | 7.5M | 1434 usec | 2474 usec 4k | 6.3GiB/s | 1.6M | 938 usec | 1221 usec 64k | 10.7GiB/s| 175k | 8979 usec | 12780 usec IO READS with DIM: blk size | BW | IOPS | 99th percentile latency | 99.99th latency 512B | 4GiB/s | 8.2M | 816 usec | 889 usec 4k | 10.1GiB/s| 2.65M| 3359 usec | 5080 usec 64k | 10.7GiB/s| 175k | 9896 usec | 10028 usec IO WRITES with DIM: blk size | BW | IOPS | 99th percentile latency | 99.99th latency 512B | 3.9GiB/s | 8.1M | 799 usec | 922 usec 4k | 9.6GiB/s | 2.5M | 717 usec | 1004 usec 64k | 10.7GiB/s| 176k | 8586 usec | 12256 usec The rdma_dim algorithm was designed to measure the effectiveness of moderation on the flow in a general way and thus should be appropriate for all RDMA storage protocols. rdma_dim is configured to be the default option based on performance improvement seen after extensive tests. Signed-off-by: Yamin Friedman Reviewed-by: Max Gurtovoy Reviewed-by: Leon Romanovsky Signed-off-by: Saeed Mahameed --- drivers/infiniband/core/cq.c | 71 ++++++++++++++++++++++++++++++- drivers/infiniband/hw/mlx5/main.c | 2 + 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c index a4c81992267c..d8a8c466d897 100644 --- a/drivers/infiniband/core/cq.c +++ b/drivers/infiniband/core/cq.c @@ -26,6 +26,40 @@ #define IB_POLL_FLAGS \ (IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS) +static void ib_cq_rdma_dim_work(struct work_struct *w) +{ + struct dim *dim = container_of(w, struct dim, work); + struct ib_cq *cq = (struct ib_cq *)dim->dim_owner; + + u16 usec = rdma_dim_prof[dim->profile_ix].usec; + u16 comps = rdma_dim_prof[dim->profile_ix].comps; + + dim->state = DIM_START_MEASURE; + + cq->device->ops.modify_cq(cq, comps, usec); +} + +static void rdma_dim_init(struct ib_cq *cq) +{ + struct dim *dim; + + if (!cq->device->ops.modify_cq || !cq->device->use_cq_dim || + cq->poll_ctx == IB_POLL_DIRECT) + return; + + dim = kzalloc(sizeof(struct dim), GFP_KERNEL); + if (!dim) + return; + + dim->state = DIM_START_MEASURE; + dim->tune_state = DIM_GOING_RIGHT; + dim->profile_ix = RDMA_DIM_START_PROFILE; + dim->dim_owner = cq; + cq->dim = dim; + + INIT_WORK(&dim->work, ib_cq_rdma_dim_work); +} + static int __ib_process_cq(struct ib_cq *cq, int budget, struct ib_wc *wcs, int batch) { @@ -98,6 +132,24 @@ static int ib_poll_handler(struct irq_poll *iop, int budget) return completed; } +static int ib_poll_dim_handler(struct irq_poll *iop, int budget) +{ + struct ib_cq *cq = container_of(iop, struct ib_cq, iop); + struct dim *dim = cq->dim; + int completed; + + completed = __ib_process_cq(cq, budget, cq->wc, IB_POLL_BATCH); + if (completed < budget) { + irq_poll_complete(&cq->iop); + if (ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) + irq_poll_sched(&cq->iop); + } + + rdma_dim(dim, completed); + + return completed; +} + static void ib_cq_completion_softirq(struct ib_cq *cq, void *private) { irq_poll_sched(&cq->iop); @@ -105,14 +157,18 @@ static void ib_cq_completion_softirq(struct ib_cq *cq, void *private) static void ib_cq_poll_work(struct work_struct *work) { - struct ib_cq *cq = container_of(work, struct ib_cq, work); + struct ib_cq *cq = container_of(work, struct ib_cq, + work); int completed; completed = __ib_process_cq(cq, IB_POLL_BUDGET_WORKQUEUE, cq->wc, IB_POLL_BATCH); + if (completed >= IB_POLL_BUDGET_WORKQUEUE || ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) queue_work(cq->comp_wq, &cq->work); + else if (cq->dim) + rdma_dim(cq->dim, completed); } static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private) @@ -166,6 +222,8 @@ struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private, rdma_restrack_set_task(&cq->res, caller); rdma_restrack_kadd(&cq->res); + rdma_dim_init(cq); + switch (cq->poll_ctx) { case IB_POLL_DIRECT: cq->comp_handler = ib_cq_completion_direct; @@ -173,7 +231,13 @@ struct ib_cq *__ib_alloc_cq_user(struct ib_device *dev, void *private, case IB_POLL_SOFTIRQ: cq->comp_handler = ib_cq_completion_softirq; - irq_poll_init(&cq->iop, IB_POLL_BUDGET_IRQ, ib_poll_handler); + if (cq->dim) { + irq_poll_init(&cq->iop, IB_POLL_BUDGET_IRQ, + ib_poll_dim_handler); + } else + irq_poll_init(&cq->iop, IB_POLL_BUDGET_IRQ, + ib_poll_handler); + ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); break; case IB_POLL_WORKQUEUE: @@ -226,6 +290,9 @@ void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata) WARN_ON_ONCE(1); } + if (cq->dim) + cancel_work_sync(&cq->dim->work); + kfree(cq->dim); kfree(cq->wc); rdma_restrack_del(&cq->res); ret = cq->device->ops.destroy_cq(cq, udata); diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index abac70ad5c7c..b1b45dbe24a5 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -6305,6 +6305,8 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev) MLX5_CAP_GEN(dev->mdev, disable_local_lb_mc))) mutex_init(&dev->lb.mutex); + dev->ib_dev.use_cq_dim = true; + return 0; }