From patchwork Sun Jan 14 15:07:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 10162661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81D2760216 for ; Sun, 14 Jan 2018 15:08:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65CAA28A6B for ; Sun, 14 Jan 2018 15:08:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A1A728A6F; Sun, 14 Jan 2018 15:08:10 +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=-6.9 required=2.0 tests=BAYES_00, 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 E8FF428A68 for ; Sun, 14 Jan 2018 15:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751586AbeANPHy (ORCPT ); Sun, 14 Jan 2018 10:07:54 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:33314 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751215AbeANPHy (ORCPT ); Sun, 14 Jan 2018 10:07:54 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from maxg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 14 Jan 2018 17:07:50 +0200 Received: from r-vnc08.mtr.labs.mlnx (r-vnc08.mtr.labs.mlnx [10.208.0.121]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w0EF7oJa020492; Sun, 14 Jan 2018 17:07:50 +0200 From: Max Gurtovoy To: jgg@mellanox.com, linux-rdma@vger.kernel.org, dledford@redhat.com, sagi@grimberg.me Cc: Max Gurtovoy Subject: [PATCH 2/3] IB/core: allocate wc array statically Date: Sun, 14 Jan 2018 17:07:49 +0200 Message-Id: <1515942470-11461-2-git-send-email-maxg@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1515942470-11461-1-git-send-email-maxg@mellanox.com> References: <1515942470-11461-1-git-send-email-maxg@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 The poll batch is small and known at pre-proccessing time. No need to allocate it dynamically. Signed-off-by: Max Gurtovoy --- drivers/infiniband/core/cq.c | 12 +----------- include/rdma/ib_verbs.h | 5 ++++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c index f2ae75f..637c999 100644 --- a/drivers/infiniband/core/cq.c +++ b/drivers/infiniband/core/cq.c @@ -15,9 +15,6 @@ #include #include -/* # of WCs to poll for with a single call to ib_poll_cq */ -#define IB_POLL_BATCH 16 - /* # of WCs to iterate over before yielding */ #define IB_POLL_BUDGET_IRQ 256 #define IB_POLL_BUDGET_WORKQUEUE 65536 @@ -150,10 +147,6 @@ struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private, cq->poll_ctx = poll_ctx; atomic_set(&cq->usecnt, 0); - cq->wc = kmalloc_array(IB_POLL_BATCH, sizeof(*cq->wc), GFP_KERNEL); - if (!cq->wc) - goto out_destroy_cq; - switch (cq->poll_ctx) { case IB_POLL_DIRECT: cq->comp_handler = ib_cq_completion_direct; @@ -171,13 +164,11 @@ struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private, break; default: ret = -EINVAL; - goto out_free_wc; + goto out_destroy_cq; } return cq; -out_free_wc: - kfree(cq->wc); out_destroy_cq: cq->device->destroy_cq(cq); return ERR_PTR(ret); @@ -208,7 +199,6 @@ void ib_free_cq(struct ib_cq *cq) WARN_ON_ONCE(1); } - kfree(cq->wc); ret = cq->device->destroy_cq(cq); WARN_ON_ONCE(ret); } diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index fd84cda..3538add 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1549,6 +1549,9 @@ struct ib_ah { typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); +/* # of WCs to poll for with a single call to ib_poll_cq */ +#define IB_POLL_BATCH 16 + enum ib_poll_context { IB_POLL_DIRECT, /* caller context, no hw completions */ IB_POLL_SOFTIRQ, /* poll from softirq context */ @@ -1564,7 +1567,7 @@ struct ib_cq { int cqe; atomic_t usecnt; /* count number of work queues */ enum ib_poll_context poll_ctx; - struct ib_wc *wc; + struct ib_wc wc[IB_POLL_BATCH]; union { struct irq_poll iop; struct work_struct work;